Guest User

Sistema de RegLogin TextDraw

a guest
Nov 2nd, 2014
1,900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.19 KB | None | 0 0
  1. //Includes
  2. #include <a_samp>
  3. #include <YSI\y_ini>
  4. //TextDraws
  5. new Text:log0;
  6. new Text:log1;
  7. new Text:log2;
  8. new Text:log3;
  9. new Text:log4;
  10. new Text:log5;
  11. new Text:log6;
  12. new Text:log7;
  13. new Text:log8;
  14. new Text:log9;
  15. new Text:log10;
  16. new Text:log11;
  17. new Text:log12;
  18. //Defines Macros
  19. #define SCM SendClientMessage
  20. #define SCMA SendClientMessageToAll
  21. //Defines Dialogos
  22. #define DialogoLogar 1
  23. #define DialogoRegistrar 2
  24. #define DialogoSiteForum 3
  25. #define DialogoRadio 4
  26. //Define Lugar Dos Arquivos
  27. #define ArquivoEnviar "/Contas/%s.ini"
  28. //Enum
  29. enum JogadorInfo
  30. {
  31. Senha,
  32. Level,
  33. Dinheiro,
  34. Matou,
  35. Morreu,
  36. }
  37. //News==========================================================================
  38. new Jogador[MAX_PLAYERS][JogadorInfo];
  39. //Stocks========================================================================
  40. stock nomePlayer(playerid)
  41. {
  42. new PlayerName[21];
  43. GetPlayerName(playerid, PlayerName, 21);
  44. return PlayerName;
  45. }
  46. stock udb_hash(buf[]) {//DracoBlue Créditos
  47. new length=strlen(buf);
  48. new s1 = 1;
  49. new s2 = 0;
  50. new n;
  51. for (n=0; n<length; n++)
  52. {
  53. s1 = (s1 + buf[n]) % 65521;
  54. s2 = (s2 + s1) % 65521;
  55. }
  56. return (s2 << 16) + s1;
  57. }
  58. stock Arquivo(playerid)
  59. {
  60. new Arquivoo[128], Nome[MAX_PLAYER_NAME];
  61. GetPlayerName(playerid, Nome, sizeof(Nome));
  62. format(Arquivoo, sizeof(Arquivoo), ArquivoEnviar, Nome);
  63. return Arquivoo;
  64. }
  65. stock SalvarConta(playerid)
  66. {
  67. new INI:File = INI_Open(Arquivo(playerid));
  68. INI_SetTag(File, "[DADOS]");
  69. INI_WriteInt(File,"Level", GetPlayerScore(playerid));
  70. INI_WriteInt(File,"Dinheiro", GetPlayerMoney(playerid));
  71. INI_WriteInt(File,"Matou", Jogador[playerid][Matou]);
  72. INI_WriteInt(File,"Morreu", Jogador[playerid][Morreu]);
  73. return 1;
  74. }
  75. //Forwards
  76. forward carregarconta_user(playerid, name[], value[]);
  77. //Publics
  78. public carregarconta_user(playerid, name[], value[])
  79. {
  80. INI_Int("Senha", Jogador[playerid][Senha]);
  81. INI_Int("Level", Jogador[playerid][Level]);
  82. INI_Int("Dinheiro", Jogador[playerid][Dinheiro]);
  83. INI_Int("Matou", Jogador[playerid][Matou]);
  84. INI_Int("Morreu", Jogador[playerid][Morreu]);
  85. return 1;
  86. }
  87. //Não retire os Créditos por favor...
  88. public OnGameModeInit()
  89. {
  90. print("========================================================");
  91. print("| Registro/Login TextDraw Descarregado com Sucesso |");
  92. print("| Feito Por PedexM |");
  93. print("| Não retire os Créditos |");
  94. print("| Carregando 25% |");
  95. print("| Carregando 50% |");
  96. print("| Carregando 75% |");
  97. print("| Carregado Com Sucesso 100% |");
  98. print("| Utilize com Moderação |");
  99. print("========================================================\n");
  100. TextDrawSetSelectable(Text:log1, 1);
  101. TextDrawSetSelectable(Text:log2, 1);
  102. TextDrawSetSelectable(Text:log3, 1);
  103. TextDrawSetSelectable(Text:log4, 1);
  104. TextDrawSetSelectable(Text:log5, 1);
  105.  
  106. log0 = TextDrawCreate(-27.199996, -4.480003, "loadsc11:loadsc11");
  107. TextDrawLetterSize(log0, 0.087199, 0.343465);
  108. TextDrawTextSize(log0, 214.399948, 592.105712);
  109. TextDrawAlignment(log0, 1);
  110. TextDrawColor(log0, 606480127);
  111. TextDrawSetShadow(log0, 0);
  112. TextDrawSetOutline(log0, 0);
  113. TextDrawFont(log0, 4);
  114.  
  115. log1 = TextDrawCreate(31.200004, 62.720184, "Logar");
  116. TextDrawLetterSize(log1, 0.602000, 2.802133);
  117. TextDrawAlignment(log1, 1);
  118. TextDrawColor(log1, 16777215);
  119. TextDrawSetShadow(log1, 0);
  120. TextDrawSetOutline(log1, -1);
  121. TextDrawBackgroundColor(log1, 51);
  122. TextDrawFont(log1, 2);
  123. TextDrawSetProportional(log1, 1);
  124. TextDrawSetSelectable(log1, true);
  125.  
  126. log2 = TextDrawCreate(29.600002, 97.813339, "Registrar");
  127. TextDrawLetterSize(log2, 0.530800, 2.831998);
  128. TextDrawAlignment(log2, 1);
  129. TextDrawColor(log2, 16777215);
  130. TextDrawSetShadow(log2, 0);
  131. TextDrawSetOutline(log2, 1);
  132. TextDrawBackgroundColor(log2, 51);
  133. TextDrawFont(log2, 2);
  134. TextDrawSetProportional(log2, 1);
  135. TextDrawSetSelectable(log2, true);
  136.  
  137. log3 = TextDrawCreate(30.400003, 133.653289, "Site/Forum");
  138. TextDrawLetterSize(log3, 0.522000, 2.518399);
  139. TextDrawAlignment(log3, 1);
  140. TextDrawColor(log3, 16777215);
  141. TextDrawSetShadow(log3, 0);
  142. TextDrawSetOutline(log3, 1);
  143. TextDrawBackgroundColor(log3, 51);
  144. TextDrawFont(log3, 2);
  145. TextDrawSetProportional(log3, 1);
  146. TextDrawSetSelectable(log3, true);
  147.  
  148. log4 = TextDrawCreate(29.600002, 165.013275, "Radio");
  149. TextDrawLetterSize(log4, 0.489200, 2.675200);
  150. TextDrawAlignment(log4, 1);
  151. TextDrawColor(log4, 16777215);
  152. TextDrawSetShadow(log4, 0);
  153. TextDrawSetOutline(log4, 1);
  154. TextDrawBackgroundColor(log4, 51);
  155. TextDrawFont(log4, 2);
  156. TextDrawSetProportional(log4, 1);
  157. TextDrawSetSelectable(log4, true);
  158.  
  159. log5 = TextDrawCreate(29.600004, 199.360015, "Sair");
  160. TextDrawLetterSize(log5, 0.462800, 2.555732);
  161. TextDrawAlignment(log5, 1);
  162. TextDrawColor(log5, -2147483393);
  163. TextDrawSetShadow(log5, 0);
  164. TextDrawSetOutline(log5, 1);
  165. TextDrawBackgroundColor(log5, 51);
  166. TextDrawFont(log5, 2);
  167. TextDrawSetProportional(log5, 1);
  168.  
  169. log6 = TextDrawCreate(115.599998, 67.953330, "usebox");
  170. TextDrawLetterSize(log6, 0.000000, 1.935185);
  171. TextDrawTextSize(log6, 24.400001, 0.000000);
  172. TextDrawAlignment(log6, 1);
  173. TextDrawColor(log6, 0);
  174. TextDrawUseBox(log6, true);
  175. TextDrawBoxColor(log6, 102);
  176. TextDrawSetShadow(log6, 0);
  177. TextDrawSetOutline(log6, 0);
  178. TextDrawFont(log6, 0);
  179.  
  180. log7 = TextDrawCreate(158.800003, 103.046669, "usebox");
  181. TextDrawLetterSize(log7, 0.000000, 1.920370);
  182. TextDrawTextSize(log7, 22.000003, 0.000000);
  183. TextDrawAlignment(log7, 1);
  184. TextDrawColor(log7, 0);
  185. TextDrawUseBox(log7, true);
  186. TextDrawBoxColor(log7, 102);
  187. TextDrawSetShadow(log7, 0);
  188. TextDrawSetOutline(log7, 0);
  189. TextDrawFont(log7, 0);
  190.  
  191. log8 = TextDrawCreate(169.999938, 138.886672, "usebox");
  192. TextDrawLetterSize(log8, 0.000000, 1.585554);
  193. TextDrawTextSize(log8, 22.800001, 0.000000);
  194. TextDrawAlignment(log8, 1);
  195. TextDrawColor(log8, 0);
  196. TextDrawUseBox(log8, true);
  197. TextDrawBoxColor(log8, 102);
  198. TextDrawSetShadow(log8, 0);
  199. TextDrawSetOutline(log8, 0);
  200. TextDrawFont(log8, 0);
  201.  
  202. log9 = TextDrawCreate(98.800003, 171.739990, "usebox");
  203. TextDrawLetterSize(log9, 0.000000, 1.508518);
  204. TextDrawTextSize(log9, 24.400001, 0.000000);
  205. TextDrawAlignment(log9, 1);
  206. TextDrawColor(log9, 0);
  207. TextDrawUseBox(log9, true);
  208. TextDrawBoxColor(log9, 102);
  209. TextDrawSetShadow(log9, 0);
  210. TextDrawSetOutline(log9, 0);
  211. TextDrawFont(log9, 0);
  212.  
  213. log10 = TextDrawCreate(79.600006, 203.099990, "usebox");
  214. TextDrawLetterSize(log10, 0.000000, 1.923335);
  215. TextDrawTextSize(log10, 24.400001, 0.000000);
  216. TextDrawAlignment(log10, 1);
  217. TextDrawColor(log10, 0);
  218. TextDrawUseBox(log10, true);
  219. TextDrawBoxColor(log10, 102);
  220. TextDrawSetShadow(log10, 0);
  221. TextDrawSetOutline(log10, 0);
  222. TextDrawFont(log10, 0);
  223.  
  224. log11 = TextDrawCreate(12.000023, 23.893346, "Guia Caminhoneiro");
  225. TextDrawLetterSize(log11, 0.526800, 3.653332);
  226. TextDrawAlignment(log11, 1);
  227. TextDrawColor(log11, 201411327);
  228. TextDrawSetShadow(log11, 0);
  229. TextDrawSetOutline(log11, 1);
  230. TextDrawBackgroundColor(log11, 51);
  231. TextDrawFont(log11, 1);
  232. TextDrawSetProportional(log11, 1);
  233.  
  234. log12 = TextDrawCreate(12.799993, 3.733348, "Seja Bem Vindo!!");
  235. TextDrawLetterSize(log12, 0.539600, 2.227199);
  236. TextDrawAlignment(log12, 1);
  237. TextDrawColor(log12, -2147483393);
  238. TextDrawSetShadow(log12, 0);
  239. TextDrawSetOutline(log12, 1);
  240. TextDrawBackgroundColor(log12, 51);
  241. TextDrawFont(log12, 1);
  242. TextDrawSetProportional(log12, 1);
  243.  
  244. return 1;
  245. }
  246. public OnGameModeExit()
  247. {
  248. return 1;
  249. }
  250. public OnPlayerConnect(playerid)
  251. {
  252. SelectTextDraw(playerid , 0xFFFFFFFF);
  253. TextDrawShowForPlayer(playerid, log0);
  254. TextDrawShowForPlayer(playerid, log1);
  255. TextDrawShowForPlayer(playerid, log2);
  256. TextDrawShowForPlayer(playerid, log3);
  257. TextDrawShowForPlayer(playerid, log4);
  258. TextDrawShowForPlayer(playerid, log5);
  259. TextDrawShowForPlayer(playerid, log6);
  260. TextDrawShowForPlayer(playerid, log7);
  261. TextDrawShowForPlayer(playerid, log8);
  262. TextDrawShowForPlayer(playerid, log9);
  263. TextDrawShowForPlayer(playerid, log10);
  264. TextDrawShowForPlayer(playerid, log11);
  265. TextDrawShowForPlayer(playerid, log12);
  266. return 1;
  267. }
  268. public OnPlayerDisconnect(playerid, reason)
  269. {
  270. SalvarConta(playerid);
  271. return 1;
  272. }
  273. public OnPlayerDeath(playerid, killerid, reason)
  274. {
  275. Jogador[killerid][Matou] ++;
  276. Jogador[playerid][Morreu] ++;
  277. return 1;
  278. }
  279. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  280. {
  281. switch(dialogid)
  282. {
  283. case DialogoRadio:
  284. {
  285. if(response)
  286. {
  287. switch(listitem)
  288. {
  289. case 0:PlayAudioStreamForPlayer(playerid, "http://dc624.4shared.com/img/3501371429/2e84643c/dlink__2Fdownload_2FHrH70Wdz_3Ftsid_3D20141103-015903-f427ece7_26lgfp_3D6000_26sbsr_3D474e4d3212d540ebab4b428aa97be3ed5bb46df75e8ff277/preview.mp3");
  290. case 1:PlayAudioStreamForPlayer(playerid, "http://dc591.4shared.com/img/4813626005/5f5129aa/dlink__2Fdownload_2F_5FmeLhPAkce_3Ftsid_3D20141103-020134-4fb5122d_26lgfp_3D6000_26sbsr_3D2e35c168350fa6afa41c699b297150d51c3152bb425df5b6/preview.mp3");
  291. case 2:PlayAudioStreamForPlayer(playerid, "http://dc722.4shared.com/img/4838460613/76a5cafc/dlink__2Fdownload_2FbBDyQZVYce_3Ftsid_3D20141103-020256-5011ea1a_26lgfp_3D6000_26sbsr_3D3f0ba072080069baefae2202ffad233c57d36dc7338fc0e7/preview.mp3");
  292. }
  293. }
  294. }
  295. case DialogoRegistrar:
  296. {
  297. if(!response) return Kick(playerid);
  298. if(response)
  299. {
  300. if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DialogoRegistrar, DIALOG_STYLE_INPUT, "Registro","Bem vindo ao Servidor Estúdos\nStatus: Não-Registrada\nColoque sua senha aqui em baixo para se registrar","Registrar","Sair");
  301. new INI:File = INI_Open(Arquivo(playerid));
  302. INI_SetTag(File, "[DADOS]");
  303. INI_WriteInt(File, "Senha", udb_hash(inputtext));
  304. INI_WriteInt(File, "Level", 0);
  305. INI_WriteInt(File, "Dinheiro", 0);
  306. INI_WriteInt(File, "Matou", 0);
  307. INI_WriteInt(File, "Morreu", 0);
  308. INI_Close(File);
  309. SCM(playerid, -1, "{FFFF00}[Server]{BDBDBD}Você se registrou com Sucesso,Aproveite os Benéficios do Nosso Servidor");
  310. }
  311. }
  312. case DialogoLogar:
  313. {
  314. if(!response) return Kick(playerid);
  315. if(response)
  316. {
  317. if(udb_hash(inputtext) == Jogador[playerid][Senha])
  318. {
  319. INI_ParseFile(Arquivo(playerid),"carregarconta_%s", .bExtra = true, .extra = playerid);
  320. GivePlayerMoney(playerid, Jogador[playerid][Dinheiro]);
  321. SetPlayerScore(playerid, Jogador[playerid][Level]);
  322. SCM(playerid, -1, "{FFFF00}[Server]{BDBDBD}Você logou com Sucesso, Aproveite os Benéficios que o Nosso Servidor Tem!!");
  323. }
  324. else
  325. {
  326. ShowPlayerDialog(playerid, DialogoLogar, DIALOG_STYLE_INPUT, "Login","Sua senha está incorreta,Corrija sua senha e entre\nStatus: Registrado\nColoque sua senha aqui em baixo para Logar","Entrar","Sair");
  327. }
  328. return 1;
  329. }
  330. }
  331. }
  332. return 1;
  333. }
  334. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  335. {
  336. if(clickedid == log1)
  337. {
  338. if(fexist(Arquivo(playerid)))
  339. {
  340. INI_ParseFile(Arquivo(playerid), "carregarconta_%s", .bExtra = true, .extra = playerid);
  341. ShowPlayerDialog(playerid, DialogoLogar, DIALOG_STYLE_INPUT, "Logar","{6E6E6E}Bem Vindo de Volta Ao Servidor {C97E6F} ForumSamp\n{6E6E6E}Status: {00FF00}Registrado\n{6E6E6E}Coloque sua senha aqui em baixo para Logar","Entrar","Sair");
  342. }
  343. else
  344. {
  345. ShowPlayerDialog(playerid, DialogoRegistrar, DIALOG_STYLE_INPUT, "Registro","{6E6E6E}Bem vindo ao Servidor {C97E6F}ForumSamp\n{6E6E6E}Status: {FF0000}Não-Registrada\n{6E6E6E}Coloque sua senha aqui em baixo para se registrar","Registrar","Sair");
  346. }
  347. TextDrawHideForPlayer(playerid, log0);
  348. TextDrawHideForPlayer(playerid,log1);
  349. TextDrawHideForPlayer(playerid,log2);
  350. TextDrawHideForPlayer(playerid,log3);
  351. TextDrawHideForPlayer(playerid,log4);
  352. TextDrawHideForPlayer(playerid,log5);
  353. TextDrawHideForPlayer(playerid,log6);
  354. TextDrawHideForPlayer(playerid,log7);
  355. TextDrawHideForPlayer(playerid,log8);
  356. TextDrawHideForPlayer(playerid,log9);
  357. TextDrawHideForPlayer(playerid,log10);
  358. TextDrawHideForPlayer(playerid,log11);
  359. TextDrawHideForPlayer(playerid,log12);
  360. }
  361. if(clickedid == log2)
  362. {
  363. if(fexist(Arquivo(playerid)))
  364. {
  365. INI_ParseFile(Arquivo(playerid), "carregarconta_%s", .bExtra = true, .extra = playerid);
  366. ShowPlayerDialog(playerid, DialogoLogar, DIALOG_STYLE_INPUT, "Login","{6E6E6E}Bem Vindo de Volta Ao Servidor {C97E6F} ForumSamp\n{6E6E6E}Status: {00FF00}Registrado\n{6E6E6E}Coloque sua senha aqui em baixo para Logar","Entrar","Sair");
  367. }
  368. else
  369. {
  370. ShowPlayerDialog(playerid, DialogoRegistrar, DIALOG_STYLE_INPUT, "Registro","{6E6E6E}Bem vindo ao Servidor {C97E6F}ForumSamp\n{6E6E6E}Status: {FF0000}Não-Registrada\n{6E6E6E}Coloque sua senha aqui em baixo para se registrar","Registrar","Sair");
  371. }
  372. TextDrawHideForPlayer(playerid, log0);
  373. TextDrawHideForPlayer(playerid,log1);
  374. TextDrawHideForPlayer(playerid,log2);
  375. TextDrawHideForPlayer(playerid,log3);
  376. TextDrawHideForPlayer(playerid,log4);
  377. TextDrawHideForPlayer(playerid,log5);
  378. TextDrawHideForPlayer(playerid,log6);
  379. TextDrawHideForPlayer(playerid,log7);
  380. TextDrawHideForPlayer(playerid,log8);
  381. TextDrawHideForPlayer(playerid,log9);
  382. TextDrawHideForPlayer(playerid,log10);
  383. TextDrawHideForPlayer(playerid,log11);
  384. TextDrawHideForPlayer(playerid,log12);
  385. }
  386. if(clickedid == log5)
  387. {
  388. Kick(playerid);
  389. }
  390. if(clickedid == log4)
  391. {
  392. ShowPlayerDialog(playerid, DialogoRadio, DIALOG_STYLE_LIST, "Rádios","Chris Brown - Don't Wake Me Up\nNirvana - Smeel Like Time Spirit\nThe Wanted - Glad You Came","Selecionar","Sair");
  393. }
  394. if(clickedid == log3)
  395. {
  396. ShowPlayerDialog(playerid, DialogoSiteForum, DIALOG_STYLE_MSGBOX, "Fórum/Site","{FF0000}www.forum.sa-mp.com\n Acesse Agora,O Melhor Portal De Ajudas e Dúvidas para SAMP!","Ok","");
  397. }
  398. return 1;
  399. }
  400. public OnPlayerRequestClass(playerid, classid)
  401. {
  402. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  403. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  404. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  405. return 1;
  406. }
Advertisement
Add Comment
Please, Sign In to add comment