Guest User

Untitled

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