Guest User

FULL SCRIPT

a guest
Mar 6th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.85 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_ini>
  3.  
  4. #define DIALOG_REGISTER 1
  5. #define DIALOG_LOGIN 2
  6. #define DIALOG_SUCCESS_1 3
  7. #define DIALOG_SUCCESS_2 4
  8.  
  9. #define PATH "/Users/%s.ini"
  10.  
  11. #define COL_WHITE "{FFFFFF}"
  12. #define COL_RED "{F81414}"
  13. #define COL_GREEN "{00FF22}"
  14. #define COL_LIGHTBLUE "{00CED1}"
  15. #define COL_BLUE "{345ACF}"
  16.  
  17. enum pInfo
  18. {
  19. pPass,
  20. pCash,
  21. pScore,
  22. pAdmin,
  23. pKills,
  24. pDeaths
  25. }
  26. new PlayerInfo[MAX_PLAYERS][pInfo];
  27.  
  28. forward LoadUser_data(playerid,name[],value[]);
  29. public LoadUser_data(playerid,name[],value[])
  30. {
  31. INI_Int("Password",PlayerInfo[playerid][pPass]);
  32. INI_Int("Cash",PlayerInfo[playerid][pCash]);
  33. INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  34. INI_Int("Score",PlayerInfo[playerid][pScore]);
  35. INI_Int("Kills",PlayerInfo[playerid][pKills]);
  36. INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
  37. return 1;
  38. }
  39.  
  40. stock UserPath(playerid)
  41. {
  42. new string[128],playername[MAX_PLAYER_NAME];
  43. GetPlayerName(playerid,playername,sizeof(playername));
  44. format(string,sizeof(string),PATH,playername);
  45. return string;
  46. }
  47.  
  48. /*Credits to Dracoblue*/
  49. stock udb_hash(buf[]) {
  50. new length=strlen(buf);
  51. new s1 = 1;
  52. new s2 = 0;
  53. new n;
  54. for (n=0; n<length; n++)
  55. {
  56. s1 = (s1 + buf[n]) % 65521;
  57. s2 = (s2 + s1) % 65521;
  58. }
  59. return (s2 << 16) + s1;
  60. }
  61.  
  62. main()
  63. {
  64. print("\n----------------------------------");
  65. print(" Cops and Robbers");
  66. print("----------------------------------\n");
  67. }
  68.  
  69. public OnGameModeInit()
  70. {
  71. SetGameModeText("Cops And Robbers");
  72. return 1;
  73. }
  74.  
  75. public OnGameModeExit()
  76. {
  77. return 1;
  78. }
  79.  
  80. public OnPlayerRequestClass(playerid, classid)
  81. {
  82. return 1;
  83. }
  84.  
  85. public OnPlayerConnect(playerid)
  86. {
  87. if(fexist(UserPath(playerid)))
  88. {
  89. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  90. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_BLUE"Login",""COL_BLUE"Type your password below to login.","Login","Quit");
  91. }
  92. else
  93. {
  94. ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_BLUE"Registering you're account...",""COL_BLUE"Type your password below to register a new account.","Register","Quit");
  95. }
  96. return 1;
  97. }
  98.  
  99. public OnPlayerDisconnect(playerid, reason)
  100. {
  101. new INI:File = INI_Open(UserPath(playerid));
  102. INI_SetTag(File,"data");
  103. INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  104. INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  105. INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
  106. INI_WriteInt(File,"Score",GetPlayerScore(playerid));
  107. INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
  108. INI_Close(File);
  109. return 1;
  110. }
  111.  
  112. public OnPlayerSpawn(playerid)
  113. {
  114. return 1;
  115. }
  116.  
  117. public OnPlayerDeath(playerid, killerid, reason)
  118. {
  119. PlayerInfo[killerid][pKills]++;
  120. PlayerInfo[playerid][pDeaths]++;
  121. return 1;
  122. }
  123.  
  124. public OnVehicleSpawn(vehicleid)
  125. {
  126. return 1;
  127. }
  128.  
  129. public OnVehicleDeath(vehicleid, killerid)
  130. {
  131. return 1;
  132. }
  133.  
  134. public OnPlayerText(playerid, text[])
  135. {
  136. return 1;
  137. }
  138.  
  139. public OnPlayerCommandText(playerid, cmdtext[])
  140. {
  141. if(!strcmp(cmdtext, "/stats", true))
  142. {
  143. new string[500];
  144. format(string,sizeof(string),"Password: %s | Money: %d | Deaths: %d | Kills: %d | Score: %d | Admin: %d ",PlayerInfo[playerid][pPass],PlayerInfo[playerid][pCash],PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pKills],PlayerInfo[playerid][pScore],PlayerInfo[playerid][pAdmin]);
  145. SendClientMessage(playerid,COL_GREEN,string);
  146. return 1;
  147. }
  148. return 0;
  149.  
  150. }
  151.  
  152. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  153. {
  154. return 1;
  155. }
  156.  
  157. public OnPlayerExitVehicle(playerid, vehicleid)
  158. {
  159. return 1;
  160. }
  161.  
  162. public OnPlayerStateChange(playerid, newstate, oldstate)
  163. {
  164. return 1;
  165. }
  166.  
  167. public OnPlayerEnterCheckpoint(playerid)
  168. {
  169. return 1;
  170. }
  171.  
  172. public OnPlayerLeaveCheckpoint(playerid)
  173. {
  174. return 1;
  175. }
  176.  
  177. public OnPlayerEnterRaceCheckpoint(playerid)
  178. {
  179. return 1;
  180. }
  181.  
  182. public OnPlayerLeaveRaceCheckpoint(playerid)
  183. {
  184. return 1;
  185. }
  186.  
  187. public OnRconCommand(cmd[])
  188. {
  189. return 1;
  190. }
  191.  
  192. public OnPlayerRequestSpawn(playerid)
  193. {
  194. return 1;
  195. }
  196.  
  197. public OnObjectMoved(objectid)
  198. {
  199. return 1;
  200. }
  201.  
  202. public OnPlayerObjectMoved(playerid, objectid)
  203. {
  204. return 1;
  205. }
  206.  
  207. public OnPlayerPickUpPickup(playerid, pickupid)
  208. {
  209. return 1;
  210. }
  211.  
  212. public OnVehicleMod(playerid, vehicleid, componentid)
  213. {
  214. return 1;
  215. }
  216.  
  217. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  218. {
  219. return 1;
  220. }
  221.  
  222. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  223. {
  224. return 1;
  225. }
  226.  
  227. public OnPlayerSelectedMenuRow(playerid, row)
  228. {
  229. return 1;
  230. }
  231.  
  232. public OnPlayerExitedMenu(playerid)
  233. {
  234. return 1;
  235. }
  236.  
  237. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  238. {
  239. return 1;
  240. }
  241.  
  242. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  243. {
  244. return 1;
  245. }
  246.  
  247. public OnRconLoginAttempt(ip[], password[], success)
  248. {
  249. return 1;
  250. }
  251.  
  252. public OnPlayerUpdate(playerid)
  253. {
  254. return 1;
  255. }
  256.  
  257. public OnPlayerStreamIn(playerid, forplayerid)
  258. {
  259. return 1;
  260. }
  261.  
  262. public OnPlayerStreamOut(playerid, forplayerid)
  263. {
  264. return 1;
  265. }
  266.  
  267. public OnVehicleStreamIn(vehicleid, forplayerid)
  268. {
  269. return 1;
  270. }
  271.  
  272. public OnVehicleStreamOut(vehicleid, forplayerid)
  273. {
  274. return 1;
  275. }
  276.  
  277. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  278. {
  279. switch( dialogid )
  280. {
  281. case DIALOG_REGISTER:
  282. {
  283. if (!response) return Kick(playerid);
  284. if(response)
  285. {
  286. if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_GREEN"Registering you're account...",""COL_RED"You have entered an invalid password.\n"COL_BLUE"Type your password below to register a new account.","Register","Quit");
  287. new INI:File = INI_Open(UserPath(playerid));
  288. INI_SetTag(File,"data");
  289. INI_WriteInt(File,"Password",udb_hash(inputtext));
  290. INI_WriteInt(File,"Cash",0);
  291. INI_WriteInt(File,"Admin",0);
  292. INI_WriteInt(File,"Score",0);
  293. INI_WriteInt(File,"Kills",0);
  294. INI_WriteInt(File,"Deaths",0);
  295. INI_Close(File);
  296.  
  297. SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
  298. SpawnPlayer(playerid);
  299. ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_GREEN"Account has been saved!",""COL_GREEN"Welcome! Relog to save your stats!","Ok","");
  300. }
  301. }
  302.  
  303. case DIALOG_LOGIN:
  304. {
  305. if ( !response ) return Kick ( playerid );
  306. if( response )
  307. {
  308. if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
  309. {
  310. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  311. GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
  312. ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_GREEN"You have registered you're account",""COL_GREEN"You have successfully logged in, welcome to LS-CC!","Ok","");
  313. }
  314. else
  315. {
  316. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
  317. }
  318. return 1;
  319. }
  320. }
  321. }
  322. return 1;
  323. }
  324.  
  325. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  326. {
  327. return 1;
  328. }
Advertisement
Add Comment
Please, Sign In to add comment