Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.83 KB | None | 0 0
  1. ///////////////////////////////
  2. ////////// INCLUDES ///////////
  3. ///////////////////////////////
  4. #include <a_samp>
  5. #include <YSI\y_ini>
  6. #include <zcmd>
  7.  
  8.  
  9. ///////////////////////////////
  10. ////////// DEFINES ////////////
  11. ///////////////////////////////
  12. #define VERDE_PADRAO_HEXA "{33DD87}" // COR PADRÃO - USADO: REGISTRO E LOGIN
  13. #define VERMELHO_PADRAO_HEXA "{DD3333}" // COR PADRÃO - USADO: REGISTRO E LOGIN
  14. #define AZUL_PADRAO_SAMP "{A9C4E4}" // COR PADRÃO - USADO: REGISTRO E LOGIN
  15. #define VERDE_PADRAO 0x33DD87FF // COR PADRÃO - USADO: REGISTRO E LOGIN
  16. #define VERMELHO_PADRAO 0xDD3333FF // COR PADRÃO - USADO: REGISTRO E LOGIN
  17. #define DIALOG_REGISTER 1
  18. #define DIALOG_LOGIN 2
  19. #define PATH "Accounts/%s.ini"
  20. #pragma tabsize 0
  21.  
  22. enum pInfo
  23. {
  24. pPass,
  25. pCash,
  26. pAdmin,
  27. pScore,
  28. pBankmoney,
  29. pBanned
  30. }
  31. new PlayerInfo[MAX_PLAYERS][pInfo];
  32. forward LoadUser_data(playerid,name[],value[]);
  33. public LoadUser_data(playerid,name[],value[])
  34. {
  35. INI_Int("Password",PlayerInfo[playerid][pPass]);
  36. INI_Int("Cash",PlayerInfo[playerid][pCash]);
  37. INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
  38. INI_Int("Score",PlayerInfo[playerid][pScore]);
  39. INI_Int("Bankmoney",PlayerInfo[playerid][pBankmoney]);
  40. INI_Int("Banned",PlayerInfo[playerid][pBanned]);
  41. return 1;
  42. }
  43. stock UserPath(playerid)
  44. {
  45. new string[128],playername[MAX_PLAYERS];
  46. GetPlayerName(playerid,playername,sizeof(playername));
  47. format(string,sizeof(string),PATH,playername);
  48. return string;
  49. }
  50. stock udb_hash(buf[])
  51. {
  52. new length=strlen(buf);
  53. new s1 = 1;
  54. new s2 = 0;
  55. new n;
  56. for (n=0; n<length; n++)
  57. {
  58. s1 = (s1 + buf[n]) % 65521;
  59. s2 = (s2 + s1) % 65521;
  60. }
  61. return (s2 << 16) + s1;
  62. }
  63.  
  64.  
  65. ///////////////////////////////
  66. ////////// VARIÁVEIS //////////
  67. ///////////////////////////////
  68.  
  69.  
  70.  
  71. main()
  72. {
  73. print("\n----------------------------------");
  74. print(" Deathmatch Gamemode by Undeath");
  75. print("----------------------------------\n");
  76. }
  77.  
  78. public OnGameModeInit()
  79. {
  80. // Don't use these lines if it's a filterscript
  81. SetGameModeText("Deathmatch");
  82. AddPlayerClass(107,2510.4346,-1678.2344,13.5469,64.6875,0,0,0,0,0,0);
  83. return 1;
  84. }
  85.  
  86. public OnGameModeExit()
  87. {
  88. return 1;
  89. }
  90.  
  91. public OnPlayerRequestClass(playerid, classid)
  92. {
  93. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  94. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  95. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  96. return 1;
  97. }
  98.  
  99. public OnPlayerConnect(playerid)
  100. {
  101. if(fexist(UserPath(playerid)))
  102. {
  103. INI_ParseFile(UserPath(playerid),"LoadUser_%s",.bExtra = true,.extra = playerid);
  104. ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login:","Please enter your password to log in your account!","Login","Quit");
  105. }
  106. else
  107. {
  108. ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"Register:","Please register new account, type you password:","Register","Quit");
  109. }
  110.  
  111.  
  112. return 1;
  113. }
  114.  
  115. public OnPlayerDisconnect(playerid, reason)
  116. {
  117. new INI:File = INI_Open(UserPath(playerid));
  118. INI_SetTag(File,"data");
  119. INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  120. INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  121. INI_WriteInt(File,"Score",GetPlayerScore(playerid));
  122. INI_WriteInt(File,"Bankmoney",PlayerInfo[playerid][pBankmoney]);
  123. INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
  124. INI_Close(File);
  125. return 1;
  126. }
  127.  
  128. public OnPlayerSpawn(playerid)
  129. {
  130. return 1;
  131. }
  132.  
  133. public OnPlayerDeath(playerid, killerid, reason)
  134. {
  135. return 1;
  136. }
  137.  
  138. public OnVehicleSpawn(vehicleid)
  139. {
  140. return 1;
  141. }
  142.  
  143. public OnVehicleDeath(vehicleid, killerid)
  144. {
  145. return 1;
  146. }
  147.  
  148. public OnPlayerText(playerid, text[])
  149. {
  150. return 1;
  151. }
  152.  
  153. public OnPlayerCommandText(playerid, cmdtext[])
  154. {
  155. if (strcmp("/dararma", cmdtext, true, 8) == 0)
  156. {
  157. return 1;
  158. }
  159. return 0;
  160. }
  161.  
  162. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  163. {
  164. return 1;
  165. }
  166.  
  167. public OnPlayerExitVehicle(playerid, vehicleid)
  168. {
  169. return 1;
  170. }
  171.  
  172. public OnPlayerStateChange(playerid, newstate, oldstate)
  173. {
  174. return 1;
  175. }
  176.  
  177. public OnPlayerEnterCheckpoint(playerid)
  178. {
  179. return 1;
  180. }
  181.  
  182. public OnPlayerLeaveCheckpoint(playerid)
  183. {
  184. return 1;
  185. }
  186.  
  187. public OnPlayerEnterRaceCheckpoint(playerid)
  188. {
  189. return 1;
  190. }
  191.  
  192. public OnPlayerLeaveRaceCheckpoint(playerid)
  193. {
  194. return 1;
  195. }
  196.  
  197. public OnRconCommand(cmd[])
  198. {
  199. return 1;
  200. }
  201.  
  202. public OnPlayerRequestSpawn(playerid)
  203. {
  204. return 1;
  205. }
  206.  
  207. public OnObjectMoved(objectid)
  208. {
  209. return 1;
  210. }
  211.  
  212. public OnPlayerObjectMoved(playerid, objectid)
  213. {
  214. return 1;
  215. }
  216.  
  217. public OnPlayerPickUpPickup(playerid, pickupid)
  218. {
  219. return 1;
  220. }
  221.  
  222. public OnVehicleMod(playerid, vehicleid, componentid)
  223. {
  224. return 1;
  225. }
  226.  
  227. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  228. {
  229. return 1;
  230. }
  231.  
  232. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  233. {
  234. return 1;
  235. }
  236.  
  237. public OnPlayerSelectedMenuRow(playerid, row)
  238. {
  239. return 1;
  240. }
  241.  
  242. public OnPlayerExitedMenu(playerid)
  243. {
  244. return 1;
  245. }
  246.  
  247. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  248. {
  249. return 1;
  250. }
  251.  
  252. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  253. {
  254. return 1;
  255. }
  256.  
  257. public OnRconLoginAttempt(ip[], password[], success)
  258. {
  259. return 1;
  260. }
  261.  
  262. public OnPlayerUpdate(playerid)
  263. {
  264. return 1;
  265. }
  266.  
  267. public OnPlayerStreamIn(playerid, forplayerid)
  268. {
  269. return 1;
  270. }
  271.  
  272. public OnPlayerStreamOut(playerid, forplayerid)
  273. {
  274. return 1;
  275. }
  276.  
  277. public OnVehicleStreamIn(vehicleid, forplayerid)
  278. {
  279. return 1;
  280. }
  281.  
  282. public OnVehicleStreamOut(vehicleid, forplayerid)
  283. {
  284. return 1;
  285. }
  286.  
  287. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  288. {
  289. switch(dialogid)
  290. {
  291. case DIALOG_REGISTER:
  292. {
  293. if(!response) return Kick(playerid);
  294. if(response)
  295. {
  296. if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"Register:","Password invalid, type password!","Register","Quit");
  297. if(strlen(inputtext) < 5 || strlen(inputtext) > 20 || !strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"Register:","Entre 5 e 20!","Register","Quit");
  298. new INI:File = INI_Open(UserPath(playerid));
  299. INI_SetTag(File,"data");
  300. INI_WriteInt(File,"Password",udb_hash(inputtext));
  301. INI_WriteInt(File,"Cash",0);
  302. INI_WriteInt(File,"Admin",0);
  303. INI_WriteInt(File,"Score",0);
  304. INI_WriteInt(File,"Bankmoney",0);
  305. INI_WriteInt(File,"Banned",0);
  306. INI_Close(File);
  307.  
  308. SendClientMessage(playerid, 0x19B519FF, "[DOEGE]» {FFFFFF}Registrado Com Sucesso!.");
  309. }
  310. }
  311. case DIALOG_LOGIN:
  312. {
  313. if(!response) return Kick(playerid);
  314. if(response)
  315. {
  316. if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
  317. {
  318. INI_ParseFile(UserPath(playerid),"LoadUser_%s",.bExtra = true,.extra = playerid);
  319. GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
  320. SetPlayerScore(playerid,PlayerInfo[playerid][pScore]);
  321. SendClientMessage(playerid,-1,"You've succsessfully logged in your account!");
  322. }
  323. else
  324. {
  325. ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login:","Password INCORRET, type again!","Login","Quit");
  326. }
  327. }
  328. }
  329. }
  330. return 1;
  331. }
  332.  
  333. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  334. {
  335. return 1;
  336. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement