Advertisement
Guest User

asdfsaas

a guest
Aug 4th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.48 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <a_mysql>
  4.  
  5. forward OnQueryFinish(gQuery[]);
  6. forward CheckPlayer(playerid);
  7. forward LoginPlayer(playerid);
  8.  
  9. enum pInfo
  10. {
  11.     pAdmin
  12. };
  13. new PlayerInfo[MAX_PLAYERS][pInfo];
  14. new gConnectionHandle, Query[1000], string[128];
  15.  
  16. main()
  17. {
  18.     print("==============================================");
  19.     print("     Skripter:Kicony Version Mod:v0.1         ");
  20.     print("     Maper:Kicony Version Map:v0.1            ");
  21.     print("==============================================");
  22. }
  23.  
  24. public OnGameModeInit()
  25. {
  26.     gConnectionHandle = mysql_connect("localhost", "root", "infinitygaming","");
  27.     mysql_debug(1);
  28.     SetGameModeText("IG:RP by Kicony");
  29.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  30.     return 1;
  31. }
  32.  
  33. public OnGameModeExit()
  34. {
  35.     return 1;
  36. }
  37.  
  38. public OnPlayerRequestClass(playerid, classid)
  39. {
  40.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  41.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  42.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  43.     return 1;
  44. }
  45.  
  46. public OnPlayerConnect(playerid)
  47. {
  48.     mysql_format(gConnectionHandle, Query, " SELECT * FROM `users` = '%e' ",GetName(playerid));
  49.     mysql_function_query(gConnectionHandle, Query, false, "CheckPlayer","d", playerid);
  50.     return 1;
  51. }
  52.  
  53. public OnPlayerDisconnect(playerid, reason)
  54. {
  55.     mysql_format(gConnectionHandle,Query,"UPDATE `users` SET `Money` = %d, `Score` = %d, `Admin` = %d",GetPlayerMoney(playerid),GetPlayerScore(playerid),PlayerInfo[playerid][pAdmin]);
  56.     mysql_function_query(gConnectionHandle, Query, false, "OnQueryFinish","s", Query);
  57.     return 1;
  58. }
  59.  
  60. public OnPlayerSpawn(playerid)
  61. {
  62.     return 1;
  63. }
  64.  
  65. public OnPlayerDeath(playerid, killerid, reason)
  66. {
  67.     return 1;
  68. }
  69.  
  70. public OnVehicleSpawn(vehicleid)
  71. {
  72.     return 1;
  73. }
  74.  
  75. public OnVehicleDeath(vehicleid, killerid)
  76. {
  77.     return 1;
  78. }
  79.  
  80. public OnPlayerText(playerid, text[])
  81. {
  82.     return 1;
  83. }
  84.  
  85. public OnPlayerCommandText(playerid, cmdtext[])
  86. {
  87.     if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  88.     {
  89.         // Do something here
  90.         return 1;
  91.     }
  92.     return 0;
  93. }
  94.  
  95. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  96. {
  97.     return 1;
  98. }
  99.  
  100. public OnPlayerExitVehicle(playerid, vehicleid)
  101. {
  102.     return 1;
  103. }
  104.  
  105. public OnPlayerStateChange(playerid, newstate, oldstate)
  106. {
  107.     return 1;
  108. }
  109.  
  110. public OnPlayerEnterCheckpoint(playerid)
  111. {
  112.     return 1;
  113. }
  114.  
  115. public OnPlayerLeaveCheckpoint(playerid)
  116. {
  117.     return 1;
  118. }
  119.  
  120. public OnPlayerEnterRaceCheckpoint(playerid)
  121. {
  122.     return 1;
  123. }
  124.  
  125. public OnPlayerLeaveRaceCheckpoint(playerid)
  126. {
  127.     return 1;
  128. }
  129.  
  130. public OnRconCommand(cmd[])
  131. {
  132.     return 1;
  133. }
  134.  
  135. public OnPlayerRequestSpawn(playerid)
  136. {
  137.     return 1;
  138. }
  139.  
  140. public OnObjectMoved(objectid)
  141. {
  142.     return 1;
  143. }
  144.  
  145. public OnPlayerObjectMoved(playerid, objectid)
  146. {
  147.     return 1;
  148. }
  149.  
  150. public OnPlayerPickUpPickup(playerid, pickupid)
  151. {
  152.     return 1;
  153. }
  154.  
  155. public OnVehicleMod(playerid, vehicleid, componentid)
  156. {
  157.     return 1;
  158. }
  159.  
  160. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  161. {
  162.     return 1;
  163. }
  164.  
  165. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  166. {
  167.     return 1;
  168. }
  169.  
  170. public OnPlayerSelectedMenuRow(playerid, row)
  171. {
  172.     return 1;
  173. }
  174.  
  175. public OnPlayerExitedMenu(playerid)
  176. {
  177.     return 1;
  178. }
  179.  
  180. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  181. {
  182.     return 1;
  183. }
  184.  
  185. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  186. {
  187.     return 1;
  188. }
  189.  
  190. public OnRconLoginAttempt(ip[], password[], success)
  191. {
  192.     return 1;
  193. }
  194.  
  195. public OnPlayerUpdate(playerid)
  196. {
  197.     return 1;
  198. }
  199.  
  200. public OnPlayerStreamIn(playerid, forplayerid)
  201. {
  202.     return 1;
  203. }
  204.  
  205. public OnPlayerStreamOut(playerid, forplayerid)
  206. {
  207.     return 1;
  208. }
  209.  
  210. public OnVehicleStreamIn(vehicleid, forplayerid)
  211. {
  212.     return 1;
  213. }
  214.  
  215. public OnVehicleStreamOut(vehicleid, forplayerid)
  216. {
  217.     return 1;
  218. }
  219.  
  220. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  221. {
  222.     switch(dialogid)
  223.     {
  224.         case 0:
  225.         {
  226.             if(!response) return Kick(playerid);
  227.             mysql_format(gConnectionHandle, Query," SELECT * FROM `users` WHERE Username = '%e' AND Password = '%e' ",GetName(playerid), inputtext);
  228.             mysql_function_query(gConnectionHandle, Query, false, "LoginPlayer","ds", playerid, inputtext);
  229.         }
  230.         case 1:
  231.         {
  232.             if(!response) return Kick(playerid);
  233.             new IP[50];
  234.             GetPlayerIp(playerid, IP, sizeof(IP));
  235.             mysql_format(gConnectionHandle, Query, "INSERT INTO `users`(`Username`,`Password`,`Money`,`Score`,`Admin`,`IP`) VALUES('%e', md5('%e'), 1000, 0, 0, 0, 0, ('%e')",GetName(playerid), inputtext, IP);
  236.             mysql_function_query(gConnectionHandle, Query, false,"OnQueryFinish","s", Query);
  237.         }
  238.     }
  239.     return 1;
  240. }
  241.  
  242. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  243. {
  244.     return 1;
  245. }
  246. public OnQueryFinish(gQuery[])
  247. {
  248.     printf("Query %s se uspjesno izvrsio!", gQuery);
  249.     return 1;
  250. }
  251. public CheckPlayer(playerid)
  252. {
  253.     mysql_store_result();
  254.     if(mysql_num_rows() == 1)
  255.     {
  256.         format(string,sizeof(string), "Dobrodosao %s\nMolimo prijavite se!",GetName(playerid));
  257.         ShowPlayerDialog(playerid,0,DIALOG_STYLE_PASSWORD, "Prijava",string,"Prijava","Izlaz");
  258.     }
  259.     else
  260.     {
  261.         format(string,sizeof(string), "Dobrodosao %s\nMolimo registruj se!",GetName(playerid));
  262.         ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD,"Registracija",string,"Registracija","Izlaz");
  263.     }
  264.     mysql_free_result();
  265.     return 1;
  266. }
  267. public LoginPlayer(playerid, password)
  268. {
  269.     mysql_store_result();
  270.     if(mysql_num_rows(gConnectionHandle) == 1)
  271.     {
  272.         if(mysql_retrieve_row())
  273.         {
  274.             SetPVarInt(playerid, "WrongPassword", GetPVarInt(playerid, "WrongPassword") +1);
  275.             if(GetPVarInt(playerid, "WrongPassword") == 3)
  276.             {
  277.                 SendClientMessage(playerid, -1, "Pogresili ste lozinku 3 puta");
  278.                 return Kick(playerid);
  279.             }
  280.             mysql_fetch_field_row(string, "Score"); SetPlayerScore(playerid, strval(string));
  281.             mysql_fetch_field_row(string, "Money"); GivePlayerMoney(playerid, strval(string));
  282.             mysql_fetch_field_row(string, "Admin"); PlayerInfo[playerid][pAdmin] = strval(string);
  283.             SendClientMessage(playerid, -1, "Uspjestno se se prijavili");
  284.         }
  285.     }
  286.     else
  287.     {
  288.         format(string,sizeof(string), "Dobrodosao %s\nMolimo prijavite se!",GetName(playerid));
  289.         ShowPlayerDialog(playerid,0,DIALOG_STYLE_PASSWORD, "Prijava",string,"Prijava","Izlaz");
  290.         SendClientMessage(playerid, -1, "Pogresno upisana lozinka");
  291.     }
  292.     mysql_free_result();
  293.     return 1;
  294.    
  295. }
  296. stock GetName(playerid)
  297. {
  298.     new PlayerName[MAX_PLAYER_NAME];
  299.     GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
  300.     return PlayerName;
  301. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement