Guest User

Registro / Login - DOF2

a guest
Oct 3rd, 2018
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.57 KB | None | 0 0
  1. #include <a_samp>
  2. #include <DOF2>
  3. #include <Pawn.CMD>
  4. #include <Sscanf2>
  5.  
  6. // DIALOGS
  7.  
  8. #define DIALOG_ENTRADA 0
  9. #define DIALOG_REGISTRO 1
  10. #define DIALOG_LOGIN 2
  11.  
  12. // CORES
  13.  
  14. #define Vermelho 0xFF0000AA
  15. #define Amarelo 0xFFFF00AA
  16. #define Azul 0x33AAFFAA
  17.  
  18. // ENUNS
  19.  
  20. enum p_Info
  21. {
  22. Nome[24],
  23. Dinheiro,
  24. Procurado,
  25. Level,
  26. Skin,
  27. Matou,
  28. Morreu
  29. };
  30.  
  31. new Player[MAX_PLAYERS][p_Info];
  32.  
  33. // NEWS
  34.  
  35. new String[128];
  36. new File[35];
  37.  
  38. main()
  39. {
  40. print("\nGAMEMODE - RPG\n\n");
  41. }
  42.  
  43. public OnGameModeInit()
  44. {
  45. SetGameModeText("RPG");
  46. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  47. return 1;
  48. }
  49.  
  50. public OnGameModeExit()
  51. {
  52. DOF2::Exit();
  53. return 1;
  54. }
  55.  
  56. public OnPlayerRequestClass(playerid, classid)
  57. {
  58. ShowPlayerDialog(playerid, DIALOG_ENTRADA, DIALOG_STYLE_MSGBOX, "ENTRADA", "Bem-vindo(a)", "Entrar", "Sair");
  59. return 1;
  60. }
  61.  
  62. public OnPlayerConnect(playerid)
  63. {
  64. GetPlayerName(playerid, Player[playerid][Nome], 24);
  65. return 1;
  66. }
  67.  
  68. public OnPlayerDisconnect(playerid, reason)
  69. {
  70. Salvar(playerid);
  71. return 1;
  72. }
  73.  
  74. public OnPlayerSpawn(playerid)
  75. {
  76. return 1;
  77. }
  78.  
  79. public OnPlayerDeath(playerid, killerid, reason)
  80. {
  81. Player[killerid][Matou]++;
  82. Player[playerid][Morreu]++;
  83. return 1;
  84. }
  85.  
  86. public OnVehicleSpawn(vehicleid)
  87. {
  88. return 1;
  89. }
  90.  
  91. public OnVehicleDeath(vehicleid, killerid)
  92. {
  93. return 1;
  94. }
  95.  
  96. public OnPlayerText(playerid, text[])
  97. {
  98. return 1;
  99. }
  100.  
  101. public OnPlayerCommandText(playerid, cmdtext[])
  102. {
  103. return 0;
  104. }
  105.  
  106. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  107. {
  108. return 1;
  109. }
  110.  
  111. public OnPlayerExitVehicle(playerid, vehicleid)
  112. {
  113. return 1;
  114. }
  115.  
  116. public OnPlayerStateChange(playerid, newstate, oldstate)
  117. {
  118. return 1;
  119. }
  120.  
  121. public OnPlayerEnterCheckpoint(playerid)
  122. {
  123. return 1;
  124. }
  125.  
  126. public OnPlayerLeaveCheckpoint(playerid)
  127. {
  128. return 1;
  129. }
  130.  
  131. public OnPlayerEnterRaceCheckpoint(playerid)
  132. {
  133. return 1;
  134. }
  135.  
  136. public OnPlayerLeaveRaceCheckpoint(playerid)
  137. {
  138. return 1;
  139. }
  140.  
  141. public OnRconCommand(cmd[])
  142. {
  143. return 1;
  144. }
  145.  
  146. public OnPlayerRequestSpawn(playerid)
  147. {
  148. return 1;
  149. }
  150.  
  151. public OnObjectMoved(objectid)
  152. {
  153. return 1;
  154. }
  155.  
  156. public OnPlayerObjectMoved(playerid, objectid)
  157. {
  158. return 1;
  159. }
  160.  
  161. public OnPlayerPickUpPickup(playerid, pickupid)
  162. {
  163. return 1;
  164. }
  165.  
  166. public OnVehicleMod(playerid, vehicleid, componentid)
  167. {
  168. return 1;
  169. }
  170.  
  171. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  172. {
  173. return 1;
  174. }
  175.  
  176. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  177. {
  178. return 1;
  179. }
  180.  
  181. public OnPlayerSelectedMenuRow(playerid, row)
  182. {
  183. return 1;
  184. }
  185.  
  186. public OnPlayerExitedMenu(playerid)
  187. {
  188. return 1;
  189. }
  190.  
  191. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  192. {
  193. return 1;
  194. }
  195.  
  196. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  197. {
  198. return 1;
  199. }
  200.  
  201. public OnRconLoginAttempt(ip[], password[], success)
  202. {
  203. return 1;
  204. }
  205.  
  206. public OnPlayerUpdate(playerid)
  207. {
  208. return 1;
  209. }
  210.  
  211. public OnPlayerStreamIn(playerid, forplayerid)
  212. {
  213. return 1;
  214. }
  215.  
  216. public OnPlayerStreamOut(playerid, forplayerid)
  217. {
  218. return 1;
  219. }
  220.  
  221. public OnVehicleStreamIn(vehicleid, forplayerid)
  222. {
  223. return 1;
  224. }
  225.  
  226. public OnVehicleStreamOut(vehicleid, forplayerid)
  227. {
  228. return 1;
  229. }
  230.  
  231. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  232. {
  233. if(dialogid == DIALOG_ENTRADA)
  234. {
  235. if(!response)
  236. return Kick(playerid);
  237.  
  238. if(!DOF2::FileExists(Conta(playerid)))
  239. {
  240. ShowPlayerDialog(playerid, DIALOG_REGISTRO, DIALOG_STYLE_INPUT, "CONTA", "Insira uma senha para Registrar-se.", "Registrar", "Sair");
  241. }
  242. else
  243. {
  244. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "CONTA", "Insira uma senha para Logar-se.", "Logar", "Sair");
  245. }
  246. return 1;
  247. }
  248. if(dialogid == DIALOG_REGISTRO)
  249. {
  250. if(!response)
  251. return Kick(playerid);
  252.  
  253. if(strlen(inputtext) < 5 || strlen(inputtext) > 20)
  254. {
  255. SendClientMessage(playerid, 0xFF0000AA, "| ERRO | Insira uma senha antes de Registrar-se.");
  256. ShowPlayerDialog(playerid, DIALOG_REGISTRO, DIALOG_STYLE_INPUT, "CONTA", "Insira uma senha para Registrar-se.", "Registrar", "Sair");
  257. }
  258. else
  259. {
  260. DOF2::CreateFile(Conta(playerid));
  261.  
  262. DOF2::SetString(Conta(playerid), "Senha", inputtext);
  263.  
  264. DOF2::SetInt(Conta(playerid), "Dinheiro", Player[playerid][Dinheiro] = 5000);
  265. DOF2::SetInt(Conta(playerid), "Procurado", Player[playerid][Procurado] = 0);
  266. DOF2::SetInt(Conta(playerid), "Level", Player[playerid][Level] = 0);
  267. DOF2::SetInt(Conta(playerid), "Skin", Player[playerid][Skin] = 0);
  268. DOF2::SetInt(Conta(playerid), "Matou", Player[playerid][Matou] = 0);
  269. DOF2::SetInt(Conta(playerid), "Morreu", Player[playerid][Morreu] = 0);
  270.  
  271. DOF2::SaveFile();
  272.  
  273. GivePlayerMoney(playerid, Player[playerid][Dinheiro]);
  274. SetPlayerWantedLevel(playerid, Player[playerid][Procurado]);
  275. SetPlayerScore(playerid, Player[playerid][Level]);
  276. SetPlayerSkin(playerid, Player[playerid][Skin]);
  277.  
  278. SendClientMessage(playerid, 0x33AAFFAA, "| INFO | Registrado(a) com sucesso!");
  279. }
  280. return 1;
  281. }
  282. if(dialogid == DIALOG_LOGIN)
  283. {
  284. if(!response)
  285. return Kick(playerid);
  286.  
  287. if(!strlen(inputtext))
  288. {
  289. SendClientMessage(playerid, 0xFF0000AA, "| ERRO | Insira uma senha antes de Registrar-se.");
  290. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "CONTA", "Insira uma senha para Logar-se.", "Logar", "Sair");
  291. return 1;
  292. }
  293. if(strcmp(inputtext, DOF2::GetString(Conta(playerid), "Senha"), true) == 0)
  294. {
  295. Player[playerid][Dinheiro] = DOF2::GetInt(Conta(playerid), "Dinheiro");
  296. Player[playerid][Procurado] = DOF2::GetInt(Conta(playerid), "Procurado");
  297. Player[playerid][Level] = DOF2::GetInt(Conta(playerid), "Level");
  298. Player[playerid][Skin] = DOF2::GetInt(Conta(playerid), "Skin");
  299. Player[playerid][Matou] = DOF2::GetInt(Conta(playerid), "Matou");
  300. Player[playerid][Morreu] = DOF2::GetInt(Conta(playerid), "Morreu");
  301.  
  302. GivePlayerMoney(playerid, Player[playerid][Dinheiro]);
  303. SetPlayerWantedLevel(playerid, Player[playerid][Procurado]);
  304. SetPlayerScore(playerid, Player[playerid][Level]);
  305. SetPlayerSkin(playerid, Player[playerid][Skin]);
  306.  
  307. SendClientMessage(playerid, 0x33AAFFAA, "| INFO | Logado(a) com sucesso!");
  308. }
  309. else
  310. {
  311. SendClientMessage(playerid, 0xFF0000AA, "| ERRO | Senha Incorreta!");
  312. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "CONTA", "Insira uma senha para Logar-se.", "Logar", "Sair");
  313. return 1;
  314. }
  315. return 1;
  316. }
  317. return 0;
  318. }
  319.  
  320. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  321. {
  322. return 1;
  323. }
  324.  
  325. Conta(playerid)
  326. {
  327. format(File, sizeof(File), "Contas/%s.ini", Player[playerid][Nome]);
  328. return File;
  329. }
  330.  
  331. Salvar(playerid)
  332. {
  333. if(DOF2::FileExists(Conta(playerid)))
  334. {
  335. Player[playerid][Dinheiro] = GetPlayerMoney(playerid);
  336. Player[playerid][Procurado] = GetPlayerWantedLevel(playerid);
  337. Player[playerid][Level] = GetPlayerScore(playerid);
  338. Player[playerid][Skin] = GetPlayerSkin(playerid);
  339.  
  340. DOF2::SetInt(Conta(playerid), "Dinheiro", Player[playerid][Dinheiro]);
  341. DOF2::SetInt(Conta(playerid), "Procurado", Player[playerid][Procurado]);
  342. DOF2::SetInt(Conta(playerid), "Level", Player[playerid][Level]);
  343. DOF2::SetInt(Conta(playerid), "Skin", Player[playerid][Skin]);
  344. DOF2::SetInt(Conta(playerid), "Matou", Player[playerid][Matou]);
  345. DOF2::SetInt(Conta(playerid), "Morreu", Player[playerid][Morreu]);
  346.  
  347. DOF2::SaveFile();
  348.  
  349. Player[playerid][Dinheiro] = 0;
  350. Player[playerid][Procurado] = 0;
  351. Player[playerid][Level] = 0;
  352. Player[playerid][Skin] = 0;
  353. Player[playerid][Matou] = 0;
  354. Player[playerid][Morreu] = 0;
  355. }
  356. return 1;
  357. }
  358.  
  359. // COMANDOS
  360.  
  361. CMD:dargrana(playerid, params[])
  362. {
  363. new id, Money;
  364.  
  365. if(!IsPlayerAdmin(playerid))
  366. return SendClientMessage(playerid, Vermelho, "| ERRO | Você não tem permissão!");
  367.  
  368. if(sscanf(params, "ud", id, Money))
  369. return SendClientMessage(playerid, Vermelho, "| ERRO | Use: /DarGrana [id] [Grana]");
  370.  
  371. if(!IsPlayerConnected(id))
  372. return SendClientMessage(playerid, Vermelho, "| ERRO | ID Inválido!");
  373.  
  374. GivePlayerMoney(id, Money);
  375.  
  376. SendClientMessage(playerid, Amarelo, "| INFO | Comando efetuado com sucesso!");
  377.  
  378. format(String, sizeof(String), "| INFO-SERVER | O(A) Administrador(a) %s (%d) Deu para você {008000}$%d {33AAFF}de Dinheiro!", Player[playerid][Nome], playerid, Money);
  379. SendClientMessage(id, Azul, String);
  380. return 1;
  381. }
  382.  
  383. CMD:darlevel(playerid, params[])
  384. {
  385. new id, Score;
  386.  
  387. if(!IsPlayerAdmin(playerid))
  388. return SendClientMessage(playerid, Vermelho, "| ERRO | Você não tem permissão!");
  389.  
  390. if(sscanf(params, "ud", id, Score))
  391. return SendClientMessage(playerid, Vermelho, "| ERRO | Use: /DarLevel [id] [Level]");
  392.  
  393. if(!IsPlayerConnected(id))
  394. return SendClientMessage(playerid, Vermelho, "| ERRO | ID Inválido!");
  395.  
  396. SetPlayerScore(id, Score);
  397.  
  398. SendClientMessage(playerid, Amarelo, "| INFO | Comando efetuado com sucesso!");
  399.  
  400. format(String, sizeof(String), "| INFO-SERVER | O(A) Administrador(a) %s (%d) Deu para você {FF0000}%d {33AAFF}de Level!", Player[playerid][Nome], playerid, Score);
  401. SendClientMessage(id, Azul, String);
  402. return 1;
  403. }
Advertisement
Add Comment
Please, Sign In to add comment