[POMOC] Nece da se spawnuje na mestu gde je potrebno

Započeo tndj, Januar 04, 2014, 18:57:55 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 2 gostiju pregledaju ovu temu.

Skripta koju koristim: Pratim tutorijal od Balkan Nation ta je skripta
Detaljan opis problema: Radi mi register i login sve ali sada ukucao sam moju poziciju ali nece da se spawnuje na mesto gde sam ja ukucao nego u ono selo me smao baci i padam pa tek onda padnem na zemlju i tako.
Dio skripte #include <a_samp>
#include <dini>


#undef MAX_PLAYERS
#define MAX_PLAYERS 100

#define MAX_LOGIN_FAILS 3

#define SCRIPT_VERSION "v1.0 BETA"
#define LAST_UPDATE "03.01.2014"
#define SCRIPTED_BY "TN-DJ"
#define SERVER_NAME "Test server"

#define bela "{FFFFFF}"
#define crvena "{FF0000}"
#define zelena "{00FF00}"
#define svetloplava "{00FFFF}"
#define tamnoplava "{0000FF}"

#define REGISTER_DIALOG_RULES 1
#define REGISTER_DIALOG_GODINE 2
#define REGISTER_DIALOG_POL 3
#define REGISTER_DIALOG_PASSWORD 4
#define REGISTER_DIALOG_END 5
#define LOGIN_DIALOG_PASSWORD 6

//-------------------------------------new & enum
enum registration
{
Player_Years,  //koliko godina ima igrac
Player_Pass, //lozinka
Player_Sex , //pol igraca
Player_Skin //Skin igraca

}
new rInfo[MAX_PLAYERS][registration];
//-----------------------------------------------

main()
{
print(" ");
print("----------------------------------");
printf(" %s:", SERVER_NAME);
printf(" Verzija: %s:", SCRIPT_VERSION);
printf(" Zadnji update:  %s:", LAST_UPDATE);
printf(" Napravio je: %s:", SCRIPTED_BY);
print("----------------------------------");
print(" ");
}


public OnGameModeInit()
{
AddPlayerClass(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
return 1;
}

public OnPlayerConnect(playerid)
{
//stavljanje defaultnih pvarova (//statistika)
SetPVarInt(playerid, "is_logged", 0); // govori da li je igrac uloguvan
SetPVarInt(playerid, "godine", -1); //Koliko igrac ima godina
SetPVarInt(playerid, "pol", -1); //koj je pol igrac
SetPVarInt(playerid, "skin", -1); //koji je skin igraca
SetPVarInt(playerid, "login_fail", -1); //govori koliko je p[uta igrac pogresio lozinku na logovanju
SetPVarInt(playerid, "first_spawn", 1); //govori da se igrac prvi put spawna
SetPVarInt(playerid, "is_spawned", 0); //govori da li je igrac spawnovan
//-----------------------------------------------------------
new str[256]; format(str, sizeof(str), "/Users/Stats/%s.ini", pName(playerid));
//Proveravamo da li je korisnik registrovan
if(!dini_Exists(str))

{
SetupPlayerForRegister(playerid);


}
else

{
SetupPlayerForLogin(playerid);


}
//----------------------------------------
return 1;
}
//------------------------------------------------ OnDialogResponse
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
//Dialog pravila registracije
if(dialogid ==  REGISTER_DIALOG_RULES)

{
if(!response) return Kick(playerid);
new str[64], str2[128];
format(str, sizeof(str), ""svetloplava"%s - Godine", SERVER_NAME);
format(str2, sizeof(str2), ""bela"%s \n Upisi koliko imas godina:", pName(playerid));
ShowPlayerDialog(playerid, REGISTER_DIALOG_GODINE, DIALOG_STYLE_INPUT, str, str2, "Dalje", "Odustani");
//Dialog za godine na registraciji


}
else if(dialogid == REGISTER_DIALOG_GODINE)

{
if(!response) return Kick(playerid);
new godine = strval(inputtext);
if(!strlen(inputtext))

{
new str[64], str2[128];
format(str, sizeof(str), ""svetloplava"%s - Godine", SERVER_NAME);
format(str2, sizeof(str2), ""bela"%s \n Upisi koliko imas godina:", pName(playerid));
ShowPlayerDialog(playerid, REGISTER_DIALOG_GODINE, DIALOG_STYLE_INPUT, str, str2, "Dalje", "Odustani");
return 1;


}
if(godine < 10 || godine > 100)

{
new str[64], str2[128];
format(str, sizeof(str), ""svetloplava"%s - Godine", SERVER_NAME);
format(str2, sizeof(str2), ""bela"%s \n Upisi koliko imas godina:\n\n"crvena"Kako bi igrao na ovom serveru moras imati izmdeju 10 i 100 godina", pName(playerid));
ShowPlayerDialog(playerid, REGISTER_DIALOG_GODINE, DIALOG_STYLE_INPUT, str, str2, "Dalje", "Odustani");
return 1;


}
rInfo[playerid][Player_Years] = godine;
//----------------------------------------------------------------------
new str[64];
format(str, sizeof(str), ""svetloplava"%s - Izbor pola", SERVER_NAME);
ShowPlayerDialog(playerid, REGISTER_DIALOG_POL, DIALOG_STYLE_LIST, str, "Musko\nZensko", "Dalje", "Odustani");
//----------------------------------------------------------------------
//dialog za izbor pola


}
else if(dialogid == REGISTER_DIALOG_POL)

{
if(!response) return Kick(playerid);
rInfo[playerid][Player_Sex] = listitem;
if(listitem == 0)
{
rInfo[playerid][Player_Skin] = 2;

}
else if(listitem == 1)
{
rInfo[playerid][Player_Skin] = 12;

}
new str[64], str2[128];
format(str, sizeof(str), ""svetloplava"%s - Lozinka", SERVER_NAME);
format(str2, sizeof(str2), ""bela"%s \n Upisi lozinku:", pName(playerid));
ShowPlayerDialog(playerid, REGISTER_DIALOG_PASSWORD, DIALOG_STYLE_PASSWORD, str, str2, "Dalje", "Odustani");
//--------------------------------------------------------------------------
//Dialogi za uposivanje lozinke pri registraciji


}
else if(dialogid == REGISTER_DIALOG_PASSWORD)

{
if(!response) return Kick(playerid);
if(!strlen(inputtext) || (strlen(inputtext) < 5 || strlen(inputtext) > 24))

{
new str[64], str2[128];
format(str, sizeof(str), ""svetloplava"%s - Lozinka", SERVER_NAME);
format(str2, sizeof(str2), ""bela"%s \n Upisi lozinku:\n\n"crvena"Moras upisati lozinku vecu od 5 a manje od 24 karaktera !", pName(playerid));
ShowPlayerDialog(playerid, REGISTER_DIALOG_PASSWORD, DIALOG_STYLE_PASSWORD, str, str2, "Dalje", "Odustani");
return 1;

}
rInfo[playerid][Player_Pass] = udb_hash(inputtext);
new str[64], str2[512];
format(str, sizeof(str), ""svetloplava"%s - Kraj", SERVER_NAME);
format(str2, sizeof(str2), ""bela"%s\nNapisani podaci:"svetloplava"\nIme:"bela"%s\n"svetloplava"Lozinka:"bela"%s\n"svetloplava"Godine:"bela"%s\n"svetloplava"Pol:"bela"%s\n\nZavrsili ste registraciju kliknite na zavrsi kako bi zapoceli igru", pName(playerid), pName(playerid), inputtext, rInfo[playerid][Player_Years], GetSexName(rInfo[playerid][Player_Sex]));
ShowPlayerDialog(playerid, REGISTER_DIALOG_END, DIALOG_STYLE_MSGBOX, str, str2, "Zavrsi", "Ponovi");
//--------------------------------------------------------------------------
//Dialog za zavrsetak registracije


}
else if(dialogid == REGISTER_DIALOG_END)

{
if(!response) return SetupPlayerForRegister(playerid);
//stvaramo file u koji spremamo statistiku
new str[256];
format(str, sizeof(str), "/Users/Stats/%s.ini", pName(playerid));
dini_Create(str);
//----------------------------------------------------------------------
//Stvaramo statistiku koju upisujemo igracu u fille
dini_IntSet(str, "password", rInfo[playerid][Player_Pass]);
dini_IntSet(str, "godine", rInfo[playerid][Player_Years]);
dini_IntSet(str, "pol", rInfo[playerid][Player_Sex]);
dini_IntSet(str, "skin", rInfo[playerid][Player_Skin]);
dini_FloatSet(str, "posx", 1642.640625);
dini_FloatSet(str, "posy", -2334.723388);
dini_FloatSet(str, "posz", 13.546875);
dini_FloatSet(str, "posa", 1.009881);
dini_IntSet(str, "interior", 0);
dini_IntSet(str, "vw", 0);
//----------------------------------------------------------------------
//pirkazujemo igracu dialog da se uloguje
SetupPlayerForLogin(playerid);
//----------------------------------------------------------------------
//----------------------------------------------------------------------

}
else if(dialogid == LOGIN_DIALOG_PASSWORD)
{
if(!response) return Kick(playerid);
if(!strlen(inputtext)) return SetupPlayerForLogin(playerid);
new str[64];
format(str, sizeof(str), "/Users/Stats/%s.ini", pName(playerid));
if(udb_hash(inputtext) != dini_Int(str, "password"))
{
SetPVarInt(playerid, "login_fail", GetPVarInt(playerid, "login_fail")+1);
if(GetPVarInt(playerid, "login_fail") == MAX_LOGIN_FAILS) return Kick(playerid);
SetupPlayerForLogin(playerid);
return 1;

}
else
{
LoginPlayer(playerid);
return 1;
}
//----------------------------------------------------------------------
//
//}
//else if(dialogid == DIALOG_ID)
//
//{
// return 1;
}
return 1;
}
//------------------------------------------------------------------------------
public OnPlayerSpawn(playerid){
//Namestamo var da je spawnan
SetPVarInt(playerid, "is_spawned", 1);
//--------------------------------------------------------------------------
//ako se igrac ulogova pa mora da se spawna
if(GetPVarInt(playerid, "firstspawn") == 1){
        new str[64];
format(str, sizeof(str), "/Users/Stats/%s.ini", pName(playerid));
SetPVarInt(playerid, "firstspawn", 0);
    SetPlayerPos(playerid, dini_Float(str, "posx"), dini_Float(str, "posy"), dini_Float(str, "posz"));
SetPlayerFacingAngle(playerid, dini_Float(str, "posa"));
SetPlayerInterior(playerid, dini_Int(str, "interior"));
SetPlayerVirtualWorld(playerid, dini_Int(str, "vw"));
return 1; }
//--------------------------------------------------------------------------
return 1;}
//------------------------------------------------------------------------------
public OnPlayerDeath(playerid, killerid, reason){
    //Namestamo var da nije  je spawnan
SetPVarInt(playerid, "is_spawned", 0);
return 1; }
//------------------------------------------------------------------------------
public OnPlayerDisconnect(playerid, reason){
//Ako se igrac diskonektuje spremamo u statitiku
LogOutPlayer(playerid);
//--------------------------------------------------------------------------
return 1; }
//------------------------------------------------------------------------------
//------------------------------------------------Dobiti igracevo ime
stock pName(playerid)
{
new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));return name;
}
//---------------------------------------------------------------------
//------------------------------------------------SetupPlayerForRegister
stock SetupPlayerForRegister(playerid)
{
new str[64], str2[512];
format(str, sizeof(str), ""svetloplava"%s - Pravila", SERVER_NAME);
format(str2, sizeof(str2), ""bela"%s \nZelimo ti dobrodoslicu na server !\n\nKako bi igrao moras prihvatiti dole navedena pravila:\n\n1. Zabranjeno je ubijanje igraca bez ikakvog razloga !\n2. Zabranjeno je koriscenje bilo kakvih scripti i bugova !\n3. Zabranjeno je vredjanje !\n\nDa li prihvatas pravila?");
ShowPlayerDialog(playerid, REGISTER_DIALOG_RULES, DIALOG_STYLE_MSGBOX, str, str2, "Prihvatam", "Odbijam");
return 1;
}
//--------------------------------------------------------------------------
//------------------------------------------------SetupPlayerForLogin
stock SetupPlayerForLogin(playerid)
{
new str[64], str2[256];
format(str, sizeof(str), ""svetloplava"%s - Ulogujte se na", SERVER_NAME);
format(str2, sizeof(str2), ""bela"%s, \nDobro dosli natrag na server\n\nKako bi nastavili sa igrom\nmolimo ukucajte vasu lozinku:", pName(playerid));
ShowPlayerDialog(playerid, LOGIN_DIALOG_PASSWORD, DIALOG_STYLE_PASSWORD, str, str2, "Prihvatam", "Odbijam");
return 1;
}
//--------------------------------------------------------------------------
//-------------------------------------------------Udb_hash
stock udb_hash(buf[])
{
new length=strlen(buf), s1 = 1, s2 = 0, n;
for (n=0; n<length; n++)

{
s1 = (s1 + buf[n]) % 65521; s2 = (s2 + s1) % 65521;

}
return (s2 << 16) +s1;
}
//------------------------------------------------------------------------------
//--------------------------------------------------Get ime iz pola igraca
stock GetSexName(sex)
{
new str[12];
if(sex == 0)

{
format(str, sizeof(str), "Musko");


}
else if(sex == 1)

{
format(str, sizeof(str), "Zensko");


}
return str;
}
//------------------------------------------------------------------------------
//--------------------------------------------------LoginPlayer
stock LoginPlayer(playerid)
{
new str[64];
format(str, sizeof(str), "/Users/Stats/%s.ini", pName(playerid));
//Ucitavamo statistiku
SetPVarInt(playerid, "is_logged", 1);
SetPVarInt(playerid, "godine", dini_Int(str, "godine"));
SetPVarInt(playerid, "pol",dini_Int(str, "pol"));
SetPVarInt(playerid, "skin",dini_Int(str, "skin"));
//-----------------------------------------------Namestamo ostale stvari na serveru
SetPlayerSkin(playerid, GetPVarInt(playerid, "skin"));
//-----------------------------------------------Saljemo poruku da se konektovao na server
new str2[128];
ClearText(playerid);
format(str2, sizeof(str2), ""svetloplava"%s"bela", dobrodosao natrag na %s !", pName(playerid), SERVER_NAME);
SendClientMessage(playerid, -1, str2);
SendClientMessage(playerid, -1, ""bela"Uspesno si se uloguvao zelimo ti igodnu igru !");
//--------------------------------------------------------------------------
return 1;
}
//------------------------------------------------------------------------------
//-----------------------------Clear text funkcija
stock ClearText(playerid)
{
for(new i;i<100;i++)
{
SendClientMessage(playerid, -1, ""bela" ");
}
return 1;
}
//------------------------------------------------------------------------------
//-------------------------------LogOutPlayer
stock LogOutPlayer(playerid)
{
    new str[64];
format(str, sizeof(str), "/Users/Stats/%s.ini", pName(playerid));
if(GetPVarInt(playerid, "is_logged") == 1)
{
dini_IntSet(str, "godine", GetPVarInt(playerid, "godine"));
dini_IntSet(str, "pol",  GetPVarInt(playerid, "pol"));
dini_IntSet(str, "skin",  GetPVarInt(playerid, "skin"));
if(GetPVarInt(playerid, "is_spawned") == 1)
{
new Float:posx, Float:posy, Float:posz, Float:posa;
GetPlayerPos(playerid, posx, posy, posz);
GetPlayerFacingAngle(playerid, posa);
dini_FloatSet(str, "posx", posx);
dini_FloatSet(str, "posy", posy);
dini_FloatSet(str, "posz", posz);
dini_FloatSet(str, "posa", posa);
dini_IntSet(str, "interior", GetPlayerInterior(playerid));
dini_IntSet(str, "vw", GetPlayerVirtualWorld(playerid));
}

}
return 1;
}

//------------------------------------------------------------------------------ [CODE]

Hvala unapred