Advertisement
Guest User

LOG/REG skin

a guest
Oct 22nd, 2017
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.60 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <sscanf2>
  4. #include <YSI\y_ini>
  5.  
  6. #undef MAX_PLAYERS
  7. #define MAX_PLAYERS 60
  8.  
  9. #pragma tabsize 0
  10.  
  11. #define SCM SendClientMessage
  12. #define GPM GivePlayerMoney
  13. #define SCMTA SendClientMessageToAll
  14. #define SPD ShowPlayerDialog
  15.  
  16. #define DIALOG_REGISTER 0
  17. #define DIALOG_LOGIN 1
  18.  
  19. #define USER_PATH "/Nalozi/%s.ini"
  20. enum pData
  21. {
  22.     Cash,
  23.     Sifra,
  24.     Level,
  25.     Skin,
  26.     Administrator,
  27.     VW,
  28.     INT,
  29.     BankaCash,
  30.     VIP,
  31.     ORG,
  32.     ORGRank,
  33.     Asistent,
  34.     Banovan,
  35.     Float:x,
  36.     Float:y,
  37.     Float:z,
  38.     Float:Angle,
  39.     Fonenum
  40. };
  41. #pragma unused Fonenum
  42. new PlayerData[MAX_PLAYERS][pData];
  43. new Nam[MAX_PLAYER_NAME],pName[MAX_PLAYER_NAME];
  44. //============================================================================ >OnPlayerConnect
  45. public OnPlayerConnect(playerid)
  46. {
  47.     SCM(playerid, ZUTA,"SERVER INFO:Ucitavanje podataka iz nase baze, molimo da pricekate!");
  48.     if(fexist(UserPath(playerid)))
  49.     {
  50.         INI_ParseFile(UserPath(playerid),"LoadUser_%s",.bExtra = true,.extra = playerid);
  51.         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");
  52.     }
  53.     else
  54.     {
  55.         SPD(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Dobrodosao na server,molimo te da se registrujes da bi nastavio igru!","Potvrdi","Odustani");
  56.     }
  57.     return 1;
  58. }
  59. //============================================================================ >OnPlayerDialogResponse
  60. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  61. {
  62.     switch(dialogid)
  63.     {
  64.         case DIALOG_REGISTER:
  65.         {
  66.             if(!response) return Kick(playerid);
  67.             if(response)
  68.             {
  69.                 if(!strlen(inputtext)) return SPD(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register:","Pogresna fira,upisite novu!","Potvrdi","Odustani");
  70.                 new INI:File = INI_Open(UserPath(playerid));
  71.                 INI_SetTag(File,"data");
  72.                 INI_WriteInt(File,"Novac",0);
  73.                 INI_WriteInt(File,"Sifra",udb_hash(inputtext));
  74.                 INI_WriteInt(File,"Level",0);
  75.                 INI_WriteInt(File,"Skin",0);
  76.                 INI_WriteInt(File,"Administrator",0);
  77.                 INI_WriteInt(File,"Asistent",0);
  78.                 INI_WriteInt(File,"V.I.P",0);
  79.                 INI_WriteInt(File,"ORG",-1);
  80.                 INI_WriteInt(File,"ORGRank",-1);
  81.                 INI_WriteInt(File,"BankaCash",0);
  82.                 INI_WriteInt(File,"Enterijer",0);
  83.                 INI_WriteInt(File,"VirtualWorld",0);
  84.                 INI_WriteInt(File,"Banovan",0);
  85.                 INI_WriteFloat(File,"Poza-x",0);
  86.                 INI_WriteFloat(File,"Poza-y",0);
  87.                 INI_WriteFloat(File,"Poza-z",0);
  88.                 INI_WriteInt(File,"Angle",0);
  89.                 INI_Close(File);
  90.                 PlayerData[playerid][Sifra] = udb_hash(inputtext);
  91.                 SetSpawnInfo(playerid, -1, 22, 2269.5220,-75.7265,26.7724,177.7747, 0, 0, 0, 0, 0, 0);
  92.                 SpawnPlayer(playerid);
  93.                 GivePlayerMoney(playerid, 350);
  94.                 SetPlayerScore(playerid, 2);
  95.                 SetPlayerSkin(playerid, 22);
  96.             }
  97.         }
  98.         case DIALOG_LOGIN:
  99.         {
  100.             if(!response) return Kick(playerid);
  101.             if(response)
  102.             {
  103.                 if(udb_hash(inputtext) == PlayerData[playerid][Sifra])
  104.                 {
  105.                     INI_ParseFile(UserPath(playerid),"LoadUser_%s",.bExtra = true,.extra = playerid);
  106.                     GPM(playerid,PlayerData[playerid][Cash]);
  107.                     SetPlayerScore(playerid,PlayerData[playerid][Level]);
  108.                     SetPlayerInterior(playerid,PlayerData[playerid][INT]);
  109.                     SetPlayerVirtualWorld(playerid,PlayerData[playerid][VW]);
  110.                     SetSpawnInfo(playerid, -1, PlayerData[playerid][Skin], PlayerData[playerid][x],PlayerData[playerid][y],PlayerData[playerid][z], PlayerData[playerid][Angle], 0, 0, 0, 0, 0, 0);
  111.                     SpawnPlayer(playerid);
  112.                     SetPlayerSkin(playerid, PlayerData[playerid][Skin]);
  113.                     SCM(playerid, ZELENA,"Uspesno si se loginavao");
  114.                 }
  115.                 else
  116.                 {
  117.                 SPD(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login:","Upisali ste pogresnu lozinku!","Potvrdi","Odustani");
  118.                 }
  119.             }
  120.         }
  121.     }
  122.     return 1;
  123. }
  124. //============================================================================ >OnPlayerDisconnect
  125. public OnPlayerDisconnect(playerid,reason)
  126. {
  127.     new INI:File = INI_Open(UserPath(playerid));
  128.     new Float:posx, Float:posy, Float:posz, Float:posa; GetPlayerPos(playerid, posx, posy, posz); GetPlayerFacingAngle(playerid, posa);
  129.     INI_SetTag(File,"data");
  130.     INI_WriteInt(File,"Novac",GetPlayerMoney(playerid));
  131.     INI_WriteInt(File,"Level",GetPlayerScore(playerid));
  132.     INI_WriteInt(File,"Administrator",PlayerData[playerid][Administrator]);
  133.     INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
  134.     INI_WriteInt(File,"Asistent",PlayerData[playerid][Asistent]);
  135.     INI_WriteInt(File,"V.I.P",PlayerData[playerid][VIP]);
  136.     INI_WriteInt(File,"ORG",PlayerData[playerid][ORG]);
  137.     INI_WriteInt(File,"ORGRank",PlayerData[playerid][ORGRank]);
  138.     INI_WriteInt(File,"BankaCash",PlayerData[playerid][BankaCash]);
  139.     INI_WriteInt(File,"Enterijer",GetPlayerInterior(playerid));
  140.     INI_WriteInt(File,"VirtualWorld",GetPlayerVirtualWorld(playerid));
  141.     INI_WriteInt(File,"Banovan",PlayerData[playerid][Banovan]);
  142.     INI_WriteFloat(File,"Poza-x",posx);
  143.     INI_WriteFloat(File,"Poza-y",posy);
  144.     INI_WriteFloat(File,"Poza-z",posz);
  145.     INI_WriteFloat(File,"Angle",posa);
  146.     INI_Close(File);
  147.     return 1;
  148. }
  149. stock udb_hash(buf[])
  150. {
  151.     new length=strlen(buf);
  152.     new s1 = 1;
  153.     new s2 = 0;
  154.     new n;
  155.     for (n=0; n<length; n++)
  156.     {
  157.        s1 = (s1 + buf[n]) % 65521;
  158.        s2 = (s2 + s1)     % 65521;
  159.     }
  160.     return (s2 << 16) + s1;
  161. }
  162.  
  163. public LoadUser_data(playerid,name[],value[])
  164. {
  165.     INI_Int("Novac",PlayerData[playerid][Cash]);
  166.     INI_Int("Sifra",PlayerData[playerid][Sifra]);
  167.     INI_Int("Level",PlayerData[playerid][Level]);
  168.     INI_Int("Skin",PlayerData[playerid][Skin]);
  169.     INI_Int("Administrator",PlayerData[playerid][Administrator]);
  170.     INI_Int("Asistent",PlayerData[playerid][Asistent]);
  171.     INI_Int("V.I.P",PlayerData[playerid][VIP]);
  172.     INI_Int("ORG",PlayerData[playerid][ORG]);
  173.     INI_Int("ORGRank",PlayerData[playerid][ORGRank]);
  174.     INI_Int("BankaCash",PlayerData[playerid][BankaCash]);
  175.     INI_Int("Enterijer",PlayerData[playerid][INT]);
  176.     INI_Int("VirtualWorld",PlayerData[playerid][VW]);
  177.     INI_Int("Banovan",PlayerData[playerid][Banovan]);
  178.     INI_Float("Poza-x",PlayerData[playerid][x]);
  179.     INI_Float("Poza-y",PlayerData[playerid][y]);
  180.     INI_Float("Poza-z",PlayerData[playerid][z]);
  181.     INI_Float("Angle",PlayerData[playerid][Angle]);
  182.     return 1;
  183. }
  184.  
  185. stock UserPath(playerid)
  186. {
  187.     new string[56];
  188.     GetPlayerName(playerid,Nam,sizeof(Nam));
  189.     format(string,sizeof(string),USER_PATH,Nam);
  190.     return string;
  191. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement