Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- #include <YSI\y_ini>
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 60
- #pragma tabsize 0
- #define SCM SendClientMessage
- #define GPM GivePlayerMoney
- #define SCMTA SendClientMessageToAll
- #define SPD ShowPlayerDialog
- #define DIALOG_REGISTER 0
- #define DIALOG_LOGIN 1
- #define USER_PATH "/Nalozi/%s.ini"
- enum pData
- {
- Cash,
- Sifra,
- Level,
- Skin,
- Administrator,
- VW,
- INT,
- BankaCash,
- VIP,
- ORG,
- ORGRank,
- Asistent,
- Banovan,
- Float:x,
- Float:y,
- Float:z,
- Float:Angle,
- Fonenum
- };
- #pragma unused Fonenum
- new PlayerData[MAX_PLAYERS][pData];
- new Nam[MAX_PLAYER_NAME],pName[MAX_PLAYER_NAME];
- //============================================================================ >OnPlayerConnect
- public OnPlayerConnect(playerid)
- {
- SCM(playerid, ZUTA,"SERVER INFO:Ucitavanje podataka iz nase baze, molimo da pricekate!");
- if(fexist(UserPath(playerid)))
- {
- INI_ParseFile(UserPath(playerid),"LoadUser_%s",.bExtra = true,.extra = playerid);
- SPD(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Vas korisnicki nalog je pranadjen u nasoj bazi,molimo te da se loginujes sa odgovrajucom lozinkom!","Potvrdi","Odustani");
- }
- else
- {
- SPD(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Dobrodosao na server,molimo te da se registrujes da bi nastavio igru!","Potvrdi","Odustani");
- }
- return 1;
- }
- //============================================================================ >OnPlayerDialogResponse
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case DIALOG_REGISTER:
- {
- if(!response) return Kick(playerid);
- if(response)
- {
- if(!strlen(inputtext)) return SPD(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register:","Pogresna fira,upisite novu!","Potvrdi","Odustani");
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"data");
- INI_WriteInt(File,"Novac",0);
- INI_WriteInt(File,"Sifra",udb_hash(inputtext));
- INI_WriteInt(File,"Level",0);
- INI_WriteInt(File,"Skin",0);
- INI_WriteInt(File,"Administrator",0);
- INI_WriteInt(File,"Asistent",0);
- INI_WriteInt(File,"V.I.P",0);
- INI_WriteInt(File,"ORG",-1);
- INI_WriteInt(File,"ORGRank",-1);
- INI_WriteInt(File,"BankaCash",0);
- INI_WriteInt(File,"Enterijer",0);
- INI_WriteInt(File,"VirtualWorld",0);
- INI_WriteInt(File,"Banovan",0);
- INI_WriteFloat(File,"Poza-x",0);
- INI_WriteFloat(File,"Poza-y",0);
- INI_WriteFloat(File,"Poza-z",0);
- INI_WriteInt(File,"Angle",0);
- INI_Close(File);
- PlayerData[playerid][Sifra] = udb_hash(inputtext);
- SetSpawnInfo(playerid, -1, 22, 2269.5220,-75.7265,26.7724,177.7747, 0, 0, 0, 0, 0, 0);
- SpawnPlayer(playerid);
- GivePlayerMoney(playerid, 350);
- SetPlayerScore(playerid, 2);
- SetPlayerSkin(playerid, 22);
- }
- }
- case DIALOG_LOGIN:
- {
- if(!response) return Kick(playerid);
- if(response)
- {
- if(udb_hash(inputtext) == PlayerData[playerid][Sifra])
- {
- INI_ParseFile(UserPath(playerid),"LoadUser_%s",.bExtra = true,.extra = playerid);
- GPM(playerid,PlayerData[playerid][Cash]);
- SetPlayerScore(playerid,PlayerData[playerid][Level]);
- SetPlayerInterior(playerid,PlayerData[playerid][INT]);
- SetPlayerVirtualWorld(playerid,PlayerData[playerid][VW]);
- SetSpawnInfo(playerid, -1, PlayerData[playerid][Skin], PlayerData[playerid][x],PlayerData[playerid][y],PlayerData[playerid][z], PlayerData[playerid][Angle], 0, 0, 0, 0, 0, 0);
- SpawnPlayer(playerid);
- SetPlayerSkin(playerid, PlayerData[playerid][Skin]);
- SCM(playerid, ZELENA,"Uspesno si se loginavao");
- }
- else
- {
- SPD(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login:","Upisali ste pogresnu lozinku!","Potvrdi","Odustani");
- }
- }
- }
- }
- return 1;
- }
- //============================================================================ >OnPlayerDisconnect
- public OnPlayerDisconnect(playerid,reason)
- {
- new INI:File = INI_Open(UserPath(playerid));
- new Float:posx, Float:posy, Float:posz, Float:posa; GetPlayerPos(playerid, posx, posy, posz); GetPlayerFacingAngle(playerid, posa);
- INI_SetTag(File,"data");
- INI_WriteInt(File,"Novac",GetPlayerMoney(playerid));
- INI_WriteInt(File,"Level",GetPlayerScore(playerid));
- INI_WriteInt(File,"Administrator",PlayerData[playerid][Administrator]);
- INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
- INI_WriteInt(File,"Asistent",PlayerData[playerid][Asistent]);
- INI_WriteInt(File,"V.I.P",PlayerData[playerid][VIP]);
- INI_WriteInt(File,"ORG",PlayerData[playerid][ORG]);
- INI_WriteInt(File,"ORGRank",PlayerData[playerid][ORGRank]);
- INI_WriteInt(File,"BankaCash",PlayerData[playerid][BankaCash]);
- INI_WriteInt(File,"Enterijer",GetPlayerInterior(playerid));
- INI_WriteInt(File,"VirtualWorld",GetPlayerVirtualWorld(playerid));
- INI_WriteInt(File,"Banovan",PlayerData[playerid][Banovan]);
- INI_WriteFloat(File,"Poza-x",posx);
- INI_WriteFloat(File,"Poza-y",posy);
- INI_WriteFloat(File,"Poza-z",posz);
- INI_WriteFloat(File,"Angle",posa);
- INI_Close(File);
- return 1;
- }
- 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("Novac",PlayerData[playerid][Cash]);
- INI_Int("Sifra",PlayerData[playerid][Sifra]);
- INI_Int("Level",PlayerData[playerid][Level]);
- INI_Int("Skin",PlayerData[playerid][Skin]);
- INI_Int("Administrator",PlayerData[playerid][Administrator]);
- INI_Int("Asistent",PlayerData[playerid][Asistent]);
- INI_Int("V.I.P",PlayerData[playerid][VIP]);
- INI_Int("ORG",PlayerData[playerid][ORG]);
- INI_Int("ORGRank",PlayerData[playerid][ORGRank]);
- INI_Int("BankaCash",PlayerData[playerid][BankaCash]);
- INI_Int("Enterijer",PlayerData[playerid][INT]);
- INI_Int("VirtualWorld",PlayerData[playerid][VW]);
- INI_Int("Banovan",PlayerData[playerid][Banovan]);
- INI_Float("Poza-x",PlayerData[playerid][x]);
- INI_Float("Poza-y",PlayerData[playerid][y]);
- INI_Float("Poza-z",PlayerData[playerid][z]);
- INI_Float("Angle",PlayerData[playerid][Angle]);
- return 1;
- }
- stock UserPath(playerid)
- {
- new string[56];
- GetPlayerName(playerid,Nam,sizeof(Nam));
- format(string,sizeof(string),USER_PATH,Nam);
- return string;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement