Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_REGISTER)
{
if (!response) return Kick(playerid);
if(response)
{
new loginstring[512];
new loginname[64];
GetPlayerName(playerid,loginname,sizeof(loginname));
if(!strlen(inputtext)) return format(loginstring,sizeof(loginstring),"Dobro dosli na Server %s\n\nVi nemate Account na Serveru!\n\nUpisite Password da se registrirate\nForum: Uskoro!\n\nUpisite vasi lozinku...",loginname);
ShowPlayerDialog(playerid,12347,DIALOG_STYLE_PASSWORD,"Registracija",loginstring,"Login","Exit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Novac",550);
INI_WriteInt(File,"Godine",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"GameMaster",0);
INI_WriteInt(File,"Lider",0);
INI_WriteInt(File,"Member",0);
INI_WriteInt(File,"Grad",0);
INI_WriteInt(File,"Posao",0);
INI_WriteInt(File,"Spol",0);
INI_WriteInt(File,"Ban",0);
INI_WriteInt(File,"Broj",0);
INI_WriteInt(File,"Mobitel",0);
INI_WriteInt(File,"Rank",0);
INI_WriteInt(File,"Skin",10);
INI_WriteInt(File,"Level",1);
INI_WriteInt(File,"Respect",0);
INI_WriteInt(File,"SatiIgranja",0);
INI_WriteInt(File,"Donator",0);
INI_WriteInt(File,"Uredjaj",0);
INI_WriteInt(File,"CheesBurgerRacun",0);
INI_WriteInt(File,"CheesBurger",0);
INI_WriteInt(File,"TopliSendvicRacun",0);
INI_WriteInt(File,"TopliSendvic",0);
INI_WriteInt(File,"BurgerRacun",0);
INI_WriteInt(File,"Burger",0);
INI_WriteInt(File,"Biznis",255);
INI_WriteInt(File,"PostanskiUred",0);
INI_WriteInt(File,"Kuca",255);
INI_WriteInt(File,"Droga",0);
INI_WriteInt(File,"Materijali",0);
INI_WriteInt(File,"NovacKuca",0);
INI_WriteInt(File,"DrogaKuca",0);
INI_WriteInt(File,"MaterijaliKuca",0);
INI_WriteInt(File,"Model",7);
INI_WriteInt(File,"IlegalniPosao",0);
INI_WriteInt(File,"Bolest",0);
INI_Close(File);
}
}
if(dialogid == DIALOG_LOGIN)
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
new loginname[64];
GetPlayerName(playerid,loginname,sizeof(loginname));
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pNovac]);
SetSpawnInfo(playerid, 0, 0, 1554.6641,-1676.0160,16.1953, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
else
{
new loginstring[512];
new loginname[64];
GetPlayerName(playerid,loginname,sizeof(loginname));
format(loginstring,sizeof(loginstring),"Dobro dosli natrag na Server %s\n\nUpisali ste krivu sifru\n\nVi imate Account na Serveru!\n\nUpisite tocan Password da se Logirate\nForum: Uskoro!\n\nUpisite vasi lozinku...",loginname);
SPD(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Kriva sifra | Login",loginstring,"Login","Odustani");
SpawnPlayer(playerid);
}
}
}
return 1;
}
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
new loginstring[512];
new loginname[64];
GetPlayerName(playerid,loginname,sizeof(loginname));
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
format(loginstring,sizeof(loginstring),"Dobro dosli natrag na Server %s\n\nVi imate Account na Serveru!\n\nUpisite Password da se Logirate\nForum: Uskoro!\n\nUpisite vasi lozinku...",loginname);
SPD(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login",loginstring,"Login","Odustani");
SpawnPlayer(playerid);
}
else
{
new loginstring[512];
new loginname[64];
GetPlayerName(playerid,loginname,sizeof(loginname));
format(loginstring,sizeof(loginstring),"Dobro dosli na Server %s\n\nVi nemate Account na Serveru!\n\nUpisite Password da se registrirate\nForum: Uskoro!\n\nUpisite vasi lozinku...",loginname);
SPD(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"Registracija",loginstring,"Registracija","Odustani");
}
//Poslovi
CistiUlicu[playerid] = 0;
Posta1Ruta1[playerid] = 0;
Posta1Ruta2[playerid] = 0;
Posta1Ruta3[playerid] = 0;
Posta2Ruta1[playerid] = 0;
Smetlar[playerid] = 0;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Novac",GetPlayerMoney(playerid));
INI_WriteInt(File,"Godine",PlayerInfo[playerid][pGodine]);
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"GameMaster",PlayerInfo[playerid][pGameMaster]);
INI_WriteInt(File,"Lider",PlayerInfo[playerid][pLider]);
INI_WriteInt(File,"Member",PlayerInfo[playerid][pTeam]);
INI_WriteInt(File,"Grad",PlayerInfo[playerid][pGrad]);
INI_WriteInt(File,"Posao",PlayerInfo[playerid][pPosao]);
INI_WriteInt(File,"Spol",PlayerInfo[playerid][pSpol]);
INI_WriteInt(File,"Ban",PlayerInfo[playerid][pBan]);
INI_WriteInt(File,"Broj",PlayerInfo[playerid][pBroj]);
INI_WriteInt(File,"Mobitel",PlayerInfo[playerid][pMobitel]);
INI_WriteInt(File,"Rank",PlayerInfo[playerid][pRank]);
INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
INI_WriteInt(File,"Respect",PlayerInfo[playerid][pRespect]);
INI_WriteInt(File,"SatiIgranja",PlayerInfo[playerid][pSatiIgranja]);
INI_WriteInt(File,"Donator",PlayerInfo[playerid][pDonator]);
INI_WriteInt(File,"Uredjaj",PlayerInfo[playerid][pUredjaj]);
INI_WriteInt(File,"CheesBurgerRacun",PlayerInfo[playerid][pCheesBurgerRacun]);
INI_WriteInt(File,"CheesBurger",PlayerInfo[playerid][pCheesBurger]);
INI_WriteInt(File,"TopliSendvicRacun",PlayerInfo[playerid][pTopliSendvicRacun]);
INI_WriteInt(File,"TopliSendvic",PlayerInfo[playerid][pTopliSendvic]);
INI_WriteInt(File,"BurgerRacun",PlayerInfo[playerid][pBurgerRacun]);
INI_WriteInt(File,"Burger",PlayerInfo[playerid][pBurger]);
INI_WriteInt(File,"Biznis",PlayerInfo[playerid][pPbiskey]);
INI_WriteInt(File,"PostanskiUred",PlayerInfo[playerid][pPostanskiUred]);
INI_WriteInt(File,"Kuca",PlayerInfo[playerid][pPhousekey]);
INI_WriteInt(File,"Droga",PlayerInfo[playerid][pDroga]);
INI_WriteInt(File,"Materijali",PlayerInfo[playerid][pMaterijali]);
INI_WriteInt(File,"NovacKuca",PlayerInfo[playerid][NovacKuca]);
INI_WriteInt(File,"DrogaKuca",PlayerInfo[playerid][DrogaKuca]);
INI_WriteInt(File,"MaterijaliKuca",PlayerInfo[playerid][MaterijaliKuca]);
INI_WriteInt(File,"Model",PlayerInfo[playerid][pModel]);
INI_WriteInt(File,"IlegalniPosao",PlayerInfo[playerid][pIlegalniPosao]);
INI_WriteInt(File,"Bolest",PlayerInfo[playerid][pBolest]);
INI_Close(File);
return 1;
}
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
stock udb_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Novac",PlayerInfo[playerid][pNovac]);
INI_Int("Godine",PlayerInfo[playerid][pGodine]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("GameMaster",PlayerInfo[playerid][pGameMaster]);
INI_Int("Member",PlayerInfo[playerid][pTeam]);
INI_Int("Grad",PlayerInfo[playerid][pGrad]);
INI_Int("Posao",PlayerInfo[playerid][pPosao]);
INI_Int("Spol",PlayerInfo[playerid][pSpol]);
INI_Int("Ban",PlayerInfo[playerid][pBan]);
INI_Int("Broj",PlayerInfo[playerid][pBroj]);
INI_Int("Mobitel",PlayerInfo[playerid][pMobitel]);
INI_Int("Rank",PlayerInfo[playerid][pRank]);
INI_Int("Skin",PlayerInfo[playerid][pSkin]);
INI_Int("Level",PlayerInfo[playerid][pLevel]);
INI_Int("Respect",PlayerInfo[playerid][pRespect]);
INI_Int("SatiIgranja",PlayerInfo[playerid][pSatiIgranja]);
INI_Int("Donator",PlayerInfo[playerid][pDonator]);
INI_Int("Uredjaj",PlayerInfo[playerid][pUredjaj]);
INI_Int("CheesBurgerRacun",PlayerInfo[playerid][pCheesBurgerRacun]);
INI_Int("CheesBurger",PlayerInfo[playerid][pCheesBurger]);
INI_Int("TopliSendvicRacun",PlayerInfo[playerid][pTopliSendvicRacun]);
INI_Int("TopliSendvic",PlayerInfo[playerid][pTopliSendvic]);
INI_Int("BurgerRacun",PlayerInfo[playerid][pBurgerRacun]);
INI_Int("Burger",PlayerInfo[playerid][pBurger]);
INI_Int("Biznis",PlayerInfo[playerid][pPbiskey]);
INI_Int("PostanskiUred",PlayerInfo[playerid][pPostanskiUred]);
INI_Int("Kuca",PlayerInfo[playerid][pPhousekey]);
INI_Int("Droga",PlayerInfo[playerid][pDroga]);
INI_Int("Materijali",PlayerInfo[playerid][pMaterijali]);
INI_Int("NovacKuca",PlayerInfo[playerid][NovacKuca]);
INI_Int("DrogaKuca",PlayerInfo[playerid][DrogaKuca]);
INI_Int("MaterijaliKuca",PlayerInfo[playerid][MaterijaliKuca]);
INI_Int("Model",PlayerInfo[playerid][pModel]);
INI_Int("IlegalniPosao",PlayerInfo[playerid][pIlegalniPosao]);
INI_Int("Bolest",PlayerInfo[playerid][pBolest]);
return 1;
}
#define PATH "/Users/%s.ini"
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_REGISTER)
{
if (!response) return Kick(playerid);
if(response)
{
new loginstring[512];
new loginname[64];
GetPlayerName(playerid,loginname,sizeof(loginname));
if(!strlen(inputtext)) return format(loginstring,sizeof(loginstring),"Dobro dosli na Server %s\n\nVi nemate Account na Serveru!\n\nUpisite Password da se registrirate\nForum: Uskoro!\n\nUpisite vasi lozinku...",loginname);
ShowPlayerDialog(playerid,12347,DIALOG_STYLE_PASSWORD,"Registracija",loginstring,"Login","Exit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Novac",550);
INI_WriteInt(File,"Godine",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"GameMaster",0);
INI_WriteInt(File,"Lider",0);
INI_WriteInt(File,"Member",0);
INI_WriteInt(File,"Grad",0);
INI_WriteInt(File,"Posao",0);
INI_WriteInt(File,"Spol",0);
INI_WriteInt(File,"Ban",0);
INI_WriteInt(File,"Broj",0);
INI_WriteInt(File,"Mobitel",0);
INI_WriteInt(File,"Rank",0);
INI_WriteInt(File,"Skin",10);
INI_WriteInt(File,"Level",1);
INI_WriteInt(File,"Respect",0);
INI_WriteInt(File,"SatiIgranja",0);
INI_WriteInt(File,"Donator",0);
INI_WriteInt(File,"Uredjaj",0);
INI_WriteInt(File,"CheesBurgerRacun",0);
INI_WriteInt(File,"CheesBurger",0);
INI_WriteInt(File,"TopliSendvicRacun",0);
INI_WriteInt(File,"TopliSendvic",0);
INI_WriteInt(File,"BurgerRacun",0);
INI_WriteInt(File,"Burger",0);
INI_WriteInt(File,"Biznis",255);
INI_WriteInt(File,"PostanskiUred",0);
INI_WriteInt(File,"Kuca",255);
INI_WriteInt(File,"Droga",0);
INI_WriteInt(File,"Materijali",0);
INI_WriteInt(File,"NovacKuca",0);
INI_WriteInt(File,"DrogaKuca",0);
INI_WriteInt(File,"MaterijaliKuca",0);
INI_WriteInt(File,"Model",7);
INI_WriteInt(File,"IlegalniPosao",0);
INI_WriteInt(File,"Bolest",0);
INI_Close(File);
}
return 1;
}
if(dialogid == DIALOG_LOGIN)
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
new loginname[64];
GetPlayerName(playerid,loginname,sizeof(loginname));
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pNovac]);
SetSpawnInfo(playerid, 0, 0, 1554.6641,-1676.0160,16.1953, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
else
{
new loginstring[512];
new loginname[64];
GetPlayerName(playerid,loginname,sizeof(loginname));
format(loginstring,sizeof(loginstring),"Dobro dosli natrag na Server %s\n\nUpisali ste krivu sifru\n\nVi imate Account na Serveru!\n\nUpisite tocan Password da se Logirate\nForum: Uskoro!\n\nUpisite vasi lozinku...",loginname);
SPD(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Kriva sifra | Login",loginstring,"Login","Odustani");
SpawnPlayer(playerid);
}
return 1;
}
return 1;
}
return 1;
}