Advertisement
Guest User

Sistema Login/Registro + TextDraw + Mysql

a guest
Feb 3rd, 2015
3,566
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.87 KB | None | 0 0
  1. #include <a_samp>
  2. #include <a_mysql>
  3. #include <zcmd>
  4.  
  5. // == Configurações do FS
  6. // => Mysql
  7. #define Host "localhost"
  8. #define Usuario "root"
  9. #define DataBase "samp"
  10. #define Senha ""
  11.  
  12. //Registro
  13. #define SKIN_INICIAL 26 //Mude para a skin desejada
  14. #define LEVEL_INICIAL 1 // ||
  15. #define DINHEIRO_INICIAL 5000 // ||
  16.  
  17. #define POSX_INICIAL 1721.8422 //Pos X de spawn de registro
  18. #define POSY_INICIAL -1880.1793 //Pos Y de spawn de registro
  19. #define POSZ_INICIAL 13.5649 //Pos Z de spawn de registro
  20.  
  21. #define WHATSAPP "edite" // troque pelo whats desejado
  22. #define FORUM "edite" // troque pelo seu endereço do forum
  23.  
  24. #define DIALOG_REGISTRO 100
  25. #define DIALOG_SEXO 101
  26. #define DIALOG_IDADE 102
  27. #define DIALOG_SENHA 103
  28. #define DIALOG_NICK 104
  29.  
  30. #define DIALOG_LOGIN 200
  31. #define DIALOG_FORUM 201
  32. #define DIALOG_WHATS 202
  33. #define SKIN_USADA PlayerInfo[playerid][Skin]
  34.  
  35. new Conexao;
  36. new DigitouSenha[MAX_PLAYERS], DigitouSexo[MAX_PLAYERS];
  37. new DigitouIdade[MAX_PLAYERS], DigitouLogin[MAX_PLAYERS];
  38. new ClicouWhats[MAX_PLAYERS], ClicouForum[MAX_PLAYERS];
  39.  
  40. new Text:Draw_Fundo[MAX_PLAYERS][8];
  41. new Text:Draw_Registro[MAX_PLAYERS][7];
  42. new Text:Draw_Login[MAX_PLAYERS][7];
  43.  
  44. enum pInfo
  45. {
  46. ID,
  47. pPassword[129],
  48. Sexo,
  49. Idade,
  50. Dinheiro,
  51. Skin,
  52. Matou,
  53. Morreu,
  54. Level,
  55. Admin,
  56. Float:Pos[3],
  57. bool:Logado
  58. };
  59. new PlayerInfo[MAX_PLAYERS][pInfo];
  60.  
  61.  
  62. public OnFilterScriptInit()
  63. {
  64. print("\n--------------------------------------");
  65. print(" FS Registro/Login por Cleyson Stein");
  66. print("--------------------------------------\n");
  67.  
  68. Conexao = mysql_connect(Host, Usuario, DataBase, Senha);
  69. mysql_query(Conexao, "CREATE TABLE IF NOT EXISTS `usuarios`(`ID`int AUTO_INCREMENT PRIMARY KEY, `Nome` varchar(24) NOT NULL, `Senha` varchar(129) NOT NULL, `Admin` int(11) NOT NULL, `Sexo` int(11) NOT NULL, `Idade` int(11) NOT NULL, `Dinheiro` int(11) NOT NULL, `Skin` int(11) NOT NULL, `Matou` int(11) NOT NULL, `Morreu` int(11) NOT NULL, `PosX` float NOT NULL,`PosY` float NOT NULL,`PosZ` float NOT NULL)", false);
  70. return 1;
  71. }
  72.  
  73. public OnFilterScriptExit()
  74. {
  75. for(new i = 0; i < MAX_PLAYERS; i++)
  76. {
  77. SalvarDados(i);
  78. }
  79. mysql_close(Conexao);
  80. return 1;
  81. }
  82.  
  83. public OnPlayerRequestClass(playerid, classid)
  84. {
  85. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  86. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  87. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  88. return 1;
  89. }
  90.  
  91. public OnPlayerConnect(playerid)
  92. {
  93. CriarTextDraw(playerid);
  94. new Query[70];
  95. mysql_format(Conexao, Query, sizeof(Query), "SELECT * FROM usuarios WHERE Nome='%e'", Nome(playerid));
  96. mysql_tquery(Conexao, Query, "Mysql_Verificar", "d", playerid);
  97. return 1;
  98. }
  99.  
  100. forward Mysql_Verificar(playerid);
  101. public Mysql_Verificar(playerid)
  102. {
  103. SelectTextDraw(playerid, 0xFF0000FF);
  104. TextDrawShowForPlayer(playerid, Draw_Fundo[playerid][0]);
  105. TextDrawShowForPlayer(playerid, Draw_Fundo[playerid][1]);
  106. TextDrawShowForPlayer(playerid, Draw_Fundo[playerid][2]);
  107. TextDrawShowForPlayer(playerid, Draw_Fundo[playerid][3]);
  108. TextDrawShowForPlayer(playerid, Draw_Fundo[playerid][4]);
  109. TextDrawShowForPlayer(playerid, Draw_Fundo[playerid][5]);
  110. TextDrawShowForPlayer(playerid, Draw_Fundo[playerid][6]);
  111. TextDrawShowForPlayer(playerid, Draw_Fundo[playerid][7]);
  112.  
  113. if(cache_get_row_count(Conexao) == 1)
  114. {
  115. new tmp[129];
  116. cache_get_field_content(0, "Senha", tmp); format(PlayerInfo[playerid][pPassword], 129, "%s", tmp);
  117. PlayerInfo[playerid][ID] = cache_get_field_content_int(0, "ID");
  118. PlayerInfo[playerid][Skin] = cache_get_field_content_int(0, "Skin");
  119.  
  120. TextDrawShowForPlayer(playerid, Draw_Login[playerid][0]);
  121. TextDrawShowForPlayer(playerid, Draw_Login[playerid][1]);
  122. TextDrawShowForPlayer(playerid, Draw_Login[playerid][2]);
  123. TextDrawShowForPlayer(playerid, Draw_Login[playerid][3]);
  124. TextDrawShowForPlayer(playerid, Draw_Login[playerid][4]);
  125. TextDrawShowForPlayer(playerid, Draw_Login[playerid][5]);
  126.  
  127. } else {
  128.  
  129. TextDrawShowForPlayer(playerid, Draw_Registro[playerid][0]);
  130. TextDrawShowForPlayer(playerid, Draw_Registro[playerid][1]);
  131. TextDrawShowForPlayer(playerid, Draw_Registro[playerid][2]);
  132. TextDrawShowForPlayer(playerid, Draw_Registro[playerid][3]);
  133. TextDrawShowForPlayer(playerid, Draw_Registro[playerid][4]);
  134. TextDrawShowForPlayer(playerid, Draw_Registro[playerid][5]);
  135. }
  136. return 1;
  137. }
  138.  
  139.  
  140. public OnPlayerDisconnect(playerid, reason)
  141. {
  142. SalvarDados(playerid);
  143. return 1;
  144. }
  145.  
  146. public OnPlayerDeath(playerid, killerid, reason)
  147. {
  148. PlayerInfo[playerid][Morreu]++;
  149. PlayerInfo[killerid][Matou]++;
  150. return 1;
  151. }
  152.  
  153. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  154. {
  155. new Msg_format[128];
  156. switch(dialogid)
  157. {
  158. case DIALOG_REGISTRO:
  159. {
  160. if(!response) return SendClientMessage(playerid, -1, "Você não quis digitar uma senha");
  161. if(strlen(inputtext) < 4 || strlen(inputtext) > 16)
  162. {
  163. SendClientMessage(playerid, -1, "Sua senha deve conter entre 4 e 16 caracteres!!!");
  164. ShowPlayerDialog(playerid, DIALOG_REGISTRO, DIALOG_STYLE_PASSWORD, "Digite uma senha:", "Digite uma senha abaixo para registrar-se.\n\nObs: Ela deve conter no mínimo 4 e no máximo 16 caracteres.", "Registrar", "Voltar");
  165. return 1;
  166. }
  167. if(response)
  168. {
  169. DigitouSenha[playerid] = 1;
  170. TextDrawSetString(Draw_Registro[playerid][2], inputtext);
  171. new Query[200];
  172. mysql_format(Conexao, Query, sizeof(Query), "INSERT INTO `usuarios` (`Nome`, `Senha`) VALUES ('%e','%e')", Nome(playerid), inputtext);
  173. mysql_tquery(Conexao, Query, "DadosRegistrados", "i", playerid);
  174. return 1;
  175. }
  176. return 1;
  177. }
  178.  
  179. case DIALOG_SEXO:
  180. {
  181. if(!response)
  182. {
  183. DigitouSexo[playerid] = 1;
  184. SendClientMessage(playerid, -1, "Seu sexo é feminino.");
  185. TextDrawSetString(Draw_Registro[playerid][3], "Feminino");
  186. PlayerInfo[playerid][Sexo] = 1;
  187. } else {
  188. DigitouSexo[playerid] = 1;
  189. SendClientMessage(playerid, -1, "Seu sexo é masculino.");
  190. TextDrawSetString(Draw_Registro[playerid][3], "Masculino");
  191. PlayerInfo[playerid][Sexo] = 2;
  192. }
  193. return 1;
  194. }
  195.  
  196. case DIALOG_IDADE:
  197. {
  198. if(!response) return SendClientMessage(playerid, -1, "Você não quis digitar a idade do seu personagem.");
  199. if(!strlen(inputtext))
  200. {
  201. SendClientMessage(playerid, -1, "Você não digitou nada, digite uma idade!");
  202. ShowPlayerDialog(playerid, DIALOG_IDADE, DIALOG_STYLE_INPUT, "Digite sua idade", "Digite a idade do seu personagem abaixo.\n\nObs: Mínimo 12 e máximo 80 anos.", "Registrar", "Voltar");
  203. return 1;
  204. }
  205. if(strval(inputtext) < 10 || strval(inputtext) > 100)
  206. {
  207. SendClientMessage(playerid, -1, "Sua idade deve ser entre 10 e 100 anos.");
  208. ShowPlayerDialog(playerid, DIALOG_IDADE, DIALOG_STYLE_INPUT, "Digite sua idade", "Digite a idade do seu personagem abaixo.\n\nObs: Mínimo 12 e máximo 80 anos.", "Registrar", "Voltar");
  209. return 1;
  210. }
  211. DigitouIdade[playerid] = 1;
  212. TextDrawSetString(Draw_Registro[playerid][4], inputtext);
  213. PlayerInfo[playerid][Idade] = strval(inputtext);
  214. return 1;
  215. }
  216.  
  217. case DIALOG_LOGIN:
  218. {
  219. if(!response) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Digite sua senha:", "Você já é um player registrado, digite uma senha abaixo para logar-se", "Logar", "Voltar");
  220. if(!strcmp(PlayerInfo[playerid][pPassword], inputtext, true, 129))
  221. {
  222. DigitouLogin[playerid] = 1;
  223. TextDrawSetString(Draw_Login[playerid][2], inputtext);
  224. } else {
  225. SendClientMessage(playerid, -1, "[ERRO] Senha incorreta !");
  226. ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Digite sua senha:", "Você já é um player registrado, digite uma senha abaixo para logar-se", "Logar", "Voltar");
  227. }
  228. return 1;
  229. }
  230. case DIALOG_SENHA:
  231. {
  232. if(!response) return SendClientMessage(playerid, -1, "Você não quis digitar uma senha");
  233. if(strlen(inputtext) < 4 || strlen(inputtext) > 16)
  234. {
  235. SendClientMessage(playerid, -1, "Sua senha deve conter entre 4 e 16 caracteres!!!");
  236. ShowPlayerDialog(playerid, DIALOG_SENHA, DIALOG_STYLE_PASSWORD, "Digite uma senha:", "Digite sua nova senha abaixo\n\nObs: Ela deve conter no mínimo 4 e no máximo 16 caracteres.", "Trocar", "Voltar");
  237. return 1;
  238. }
  239. if(response)
  240. {
  241. new Query[120];
  242. mysql_format(Conexao, Query, sizeof(Query), "UPDATE `usuarios` SET `Senha`='%e' WHERE `ID`='%d'",inputtext, PlayerInfo[playerid][ID]);
  243. mysql_tquery(Conexao, Query,"","");
  244. format(Msg_format, sizeof(Msg_format), "Sua senha foi alterada com sucesso, nova senha: %s!!!", inputtext);
  245. SendClientMessage(playerid, -1, Msg_format);
  246. return 1;
  247. }
  248. return 1;
  249. }
  250. case DIALOG_NICK:
  251. {
  252. if(!response) return SendClientMessage(playerid, -1, "Você não quis digitar uma senha");
  253. if(strlen(inputtext) > 25)
  254. {
  255. SendClientMessage(playerid, -1, "Seu novo nick name deve conter ate 25 caracteres!!!");
  256. ShowPlayerDialog(playerid, DIALOG_NICK, DIALOG_STYLE_PASSWORD, "Digite um novo nick:", "Digite seu novo nick abaixo\n\nObs: Ele deve conter no máximo 25 caracteres.", "Trocar", "Voltar");
  257. return 1;
  258. }
  259. if(response)
  260. {
  261. SetPlayerName(playerid, inputtext);
  262. new Query[120];
  263. mysql_format(Conexao, Query, sizeof(Query), "UPDATE `usuarios` SET `Nome`='%e' WHERE `ID`='%d'", inputtext, PlayerInfo[playerid][ID]);
  264. mysql_tquery(Conexao, Query,"","");
  265. format(Msg_format, sizeof(Msg_format), "Seu nick foi alterado com sucesso, novo nick: %s!!!", inputtext);
  266. SendClientMessage(playerid, -1, Msg_format);
  267. return 1;
  268. }
  269. return 1;
  270. }
  271. }
  272. return 1;
  273. }
  274.  
  275. forward Mysql_Carregar(playerid);
  276. public Mysql_Carregar(playerid)
  277. {
  278. PlayerInfo[playerid][Admin] = cache_get_field_content_int(0, "Admin");
  279. PlayerInfo[playerid][Sexo] = cache_get_field_content_int(0, "Sexo");
  280. PlayerInfo[playerid][Idade] = cache_get_field_content_int(0, "Idade");
  281. PlayerInfo[playerid][Dinheiro] = cache_get_field_content_int(0, "Dinheiro");
  282. PlayerInfo[playerid][Skin] = cache_get_field_content_int(0, "Skin");
  283. PlayerInfo[playerid][Matou] = cache_get_field_content_int(0, "Matou");
  284. PlayerInfo[playerid][Morreu] = cache_get_field_content_int(0, "Morreu");
  285. PlayerInfo[playerid][Pos][0] = cache_get_field_content_int(0, "PosX");
  286. PlayerInfo[playerid][Pos][1] = cache_get_field_content_int(0, "PosY");
  287. PlayerInfo[playerid][Pos][2] = cache_get_field_content_int(0, "PosZ");
  288. CarregarDados(playerid);
  289. return 1;
  290. }
  291.  
  292. stock SalvarDados(playerid)
  293. {
  294. if(PlayerInfo[playerid][Logado] == false) return 1;
  295. new Float:X, Float:Y, Float:Z, Query[320];
  296. GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
  297. mysql_format(Conexao, Query, sizeof(Query), "UPDATE `usuarios` SET `Admin`='%d', `Sexo`='%d', `Idade`='%d', `Dinheiro`='%d', `Skin`='%d', `Matou`='%d', `Morreu`='%d', `PosX`=%.1f, `PosY`=%.1f, `PosZ`=%.1f WHERE `ID`='%d'",
  298. PlayerInfo[playerid][Admin],
  299. PlayerInfo[playerid][Sexo],
  300. PlayerInfo[playerid][Idade],
  301. GetPlayerMoney(playerid),
  302. PlayerInfo[playerid][Skin],
  303. PlayerInfo[playerid][Matou],
  304. PlayerInfo[playerid][Morreu],
  305. Float:X,
  306. Float:Y,
  307. Float:Z,
  308. PlayerInfo[playerid][ID]);
  309. mysql_tquery(Conexao, Query,"DadosSalvos","d", playerid);
  310. return 1;
  311. }
  312.  
  313. stock CarregarDados(playerid)
  314. {
  315. TirarTextDraw(playerid);
  316. CancelSelectTextDraw(playerid);
  317. SetPlayerScore(playerid, PlayerInfo[playerid][Level]);
  318. GivePlayerMoney(playerid, PlayerInfo[playerid][Dinheiro]);
  319. SetSpawnInfo(playerid, 0, PlayerInfo[playerid][Skin], PlayerInfo[playerid][Pos][0], PlayerInfo[playerid][Pos][1], PlayerInfo[playerid][Pos][2], 269.15, 0, 0, 0, 0, 0, 0);
  320. SpawnPlayer(playerid);
  321. SendClientMessage(playerid, -1, "Sua conta foi carregada com sucesso!");
  322. PlayerInfo[playerid][Logado] = true;
  323. return 1;
  324. }
  325.  
  326. forward DadosRegistrados(playerid);
  327. public DadosRegistrados(playerid)
  328. {
  329. PlayerInfo[playerid][ID] = cache_insert_id();
  330. printf("-> Nova conta registrada ID: %d", PlayerInfo[playerid][ID]);
  331. return 1;
  332. }
  333.  
  334. forward DadosSalvos(playerid);
  335. public DadosSalvos(playerid)
  336. {
  337. printf("-> Conta salva ID: %d", PlayerInfo[playerid][ID]);
  338. return 1;
  339. }
  340.  
  341. stock Nome(playerid)
  342. {
  343. new name[MAX_PLAYER_NAME];
  344. return(GetPlayerName(playerid, name, sizeof(name)), name);
  345. }
  346.  
  347. stock CriarTextDraw(playerid)
  348. {
  349. // == Text draws box fundo ou seja nao irao alterar se for login ou registro
  350. Draw_Fundo[playerid][0] = TextDrawCreate(130.000000, 80.000000, "#");
  351. TextDrawBackgroundColor(Draw_Fundo[playerid][0], 255);
  352. TextDrawFont(Draw_Fundo[playerid][0], 0);
  353. TextDrawLetterSize(Draw_Fundo[playerid][0], 0.800000, 30.799999);
  354. TextDrawColor(Draw_Fundo[playerid][0], -1);
  355. TextDrawSetOutline(Draw_Fundo[playerid][0], 0);
  356. TextDrawSetProportional(Draw_Fundo[playerid][0], 1);
  357. TextDrawSetShadow(Draw_Fundo[playerid][0], 1);
  358. TextDrawUseBox(Draw_Fundo[playerid][0], 1);
  359. TextDrawBoxColor(Draw_Fundo[playerid][0], -120);
  360. TextDrawTextSize(Draw_Fundo[playerid][0], 508.000000, 81.000000);
  361.  
  362. Draw_Fundo[playerid][1] = TextDrawCreate(130.000000, 80.000000, "#");
  363. TextDrawBackgroundColor(Draw_Fundo[playerid][1], 255);
  364. TextDrawFont(Draw_Fundo[playerid][1], 0);
  365. TextDrawLetterSize(Draw_Fundo[playerid][1], 0.800000, 2.299995);
  366. TextDrawColor(Draw_Fundo[playerid][1], -1);
  367. TextDrawSetOutline(Draw_Fundo[playerid][1], 0);
  368. TextDrawSetProportional(Draw_Fundo[playerid][1], 1);
  369. TextDrawSetShadow(Draw_Fundo[playerid][1], 1);
  370. TextDrawUseBox(Draw_Fundo[playerid][1], 1);
  371. TextDrawBoxColor(Draw_Fundo[playerid][1], 102);
  372. TextDrawTextSize(Draw_Fundo[playerid][1], 508.000000, 81.000000);
  373.  
  374. Draw_Fundo[playerid][2] = TextDrawCreate(130.000000, 337.000000, "#");
  375. TextDrawBackgroundColor(Draw_Fundo[playerid][2], 255);
  376. TextDrawFont(Draw_Fundo[playerid][2], 0);
  377. TextDrawLetterSize(Draw_Fundo[playerid][2], 0.800000, 2.299995);
  378. TextDrawColor(Draw_Fundo[playerid][2], -1);
  379. TextDrawSetOutline(Draw_Fundo[playerid][2], 0);
  380. TextDrawSetProportional(Draw_Fundo[playerid][2], 1);
  381. TextDrawSetShadow(Draw_Fundo[playerid][2], 1);
  382. TextDrawUseBox(Draw_Fundo[playerid][2], 1);
  383. TextDrawBoxColor(Draw_Fundo[playerid][2], 102);
  384. TextDrawTextSize(Draw_Fundo[playerid][2], 508.000000, 81.000000);
  385.  
  386. Draw_Fundo[playerid][3] = TextDrawCreate(123.000000, 96.000000, "-");
  387. TextDrawBackgroundColor(Draw_Fundo[playerid][3], 255);
  388. TextDrawFont(Draw_Fundo[playerid][3], 1);
  389. TextDrawLetterSize(Draw_Fundo[playerid][3], 27.550069, 0.899999);
  390. TextDrawColor(Draw_Fundo[playerid][3], 65535);
  391. TextDrawSetOutline(Draw_Fundo[playerid][3], 1);
  392. TextDrawSetProportional(Draw_Fundo[playerid][3], 1);
  393.  
  394. Draw_Fundo[playerid][4] = TextDrawCreate(123.000000, 331.000000, "-");
  395. TextDrawBackgroundColor(Draw_Fundo[playerid][4], 255);
  396. TextDrawFont(Draw_Fundo[playerid][4], 1);
  397. TextDrawLetterSize(Draw_Fundo[playerid][4], 27.550069, 0.899999);
  398. TextDrawColor(Draw_Fundo[playerid][4], 65535);
  399. TextDrawSetOutline(Draw_Fundo[playerid][4], 1);
  400. TextDrawSetProportional(Draw_Fundo[playerid][4], 1);
  401.  
  402. Draw_Fundo[playerid][5] = TextDrawCreate(255.000000, 77.000000, "~b~Bem Vindo");
  403. TextDrawBackgroundColor(Draw_Fundo[playerid][5], 255);
  404. TextDrawFont(Draw_Fundo[playerid][5], 0);
  405. TextDrawLetterSize(Draw_Fundo[playerid][5], 0.959999, 2.299998);
  406. TextDrawColor(Draw_Fundo[playerid][5], -1);
  407. TextDrawSetOutline(Draw_Fundo[playerid][5], 0);
  408. TextDrawSetProportional(Draw_Fundo[playerid][5], 1);
  409. TextDrawSetShadow(Draw_Fundo[playerid][5], 1);
  410.  
  411. Draw_Fundo[playerid][6] = TextDrawCreate(256.000000, 335.000000, "~b~Bom Jogo !");
  412. TextDrawBackgroundColor(Draw_Fundo[playerid][6], 255);
  413. TextDrawFont(Draw_Fundo[playerid][6], 0);
  414. TextDrawLetterSize(Draw_Fundo[playerid][6], 0.959999, 2.299998);
  415. TextDrawColor(Draw_Fundo[playerid][6], -1);
  416. TextDrawSetOutline(Draw_Fundo[playerid][6], 0);
  417. TextDrawSetProportional(Draw_Fundo[playerid][6], 1);
  418. TextDrawSetShadow(Draw_Fundo[playerid][6], 1);
  419.  
  420. Draw_Fundo[playerid][7] = TextDrawCreate(450.000000, 310.000000, " Cancelar");
  421. TextDrawBackgroundColor(Draw_Fundo[playerid][7], 255);
  422. TextDrawFont(Draw_Fundo[playerid][7], 2);
  423. TextDrawLetterSize(Draw_Fundo[playerid][7], 0.209999, 1.600000);
  424. TextDrawColor(Draw_Fundo[playerid][7], -1);
  425. TextDrawSetOutline(Draw_Fundo[playerid][7], 0);
  426. TextDrawSetProportional(Draw_Fundo[playerid][7], 1);
  427. TextDrawSetShadow(Draw_Fundo[playerid][7], 1);
  428. TextDrawUseBox(Draw_Fundo[playerid][7], 1);
  429. TextDrawBoxColor(Draw_Fundo[playerid][7], 153);
  430. TextDrawTextSize(Draw_Fundo[playerid][7], 500.000000, 10.000000);
  431.  
  432. // ===== TextDraw Registroo
  433.  
  434. Draw_Registro[playerid][0] = TextDrawCreate(211.000000, 110.000000, "Ola, sua conta ainda nao e registrada");
  435. TextDrawBackgroundColor(Draw_Registro[playerid][0], 255);
  436. TextDrawFont(Draw_Registro[playerid][0], 2);
  437. TextDrawLetterSize(Draw_Registro[playerid][0], 0.219999, 1.899999);
  438. TextDrawColor(Draw_Registro[playerid][0], 255);
  439. TextDrawSetOutline(Draw_Registro[playerid][0], 0);
  440. TextDrawSetProportional(Draw_Registro[playerid][0], 1);
  441. TextDrawSetShadow(Draw_Registro[playerid][0], 0);
  442.  
  443. Draw_Registro[playerid][1] = TextDrawCreate(385.000000, 310.000000, " Registrar");
  444. TextDrawBackgroundColor(Draw_Registro[playerid][1], 255);
  445. TextDrawFont(Draw_Registro[playerid][1], 2);
  446. TextDrawLetterSize(Draw_Registro[playerid][1], 0.209999, 1.600000);
  447. TextDrawColor(Draw_Registro[playerid][1], -1);
  448. TextDrawSetOutline(Draw_Registro[playerid][1], 0);
  449. TextDrawSetProportional(Draw_Registro[playerid][1], 1);
  450. TextDrawSetShadow(Draw_Registro[playerid][1], 1);
  451. TextDrawUseBox(Draw_Registro[playerid][1], 1);
  452. TextDrawBoxColor(Draw_Registro[playerid][1], 153);
  453. TextDrawTextSize(Draw_Registro[playerid][1], 437.000000, 10.000000);
  454.  
  455. Draw_Registro[playerid][2] = TextDrawCreate(170.000000, 144.000000, " Senha");
  456. TextDrawBackgroundColor(Draw_Registro[playerid][2], 255);
  457. TextDrawFont(Draw_Registro[playerid][2], 2);
  458. TextDrawLetterSize(Draw_Registro[playerid][2], 0.500000, 3.000000);
  459. TextDrawColor(Draw_Registro[playerid][2], -1);
  460. TextDrawSetOutline(Draw_Registro[playerid][2], 0);
  461. TextDrawSetProportional(Draw_Registro[playerid][2], 1);
  462. TextDrawSetShadow(Draw_Registro[playerid][2], 1);
  463. TextDrawUseBox(Draw_Registro[playerid][2], 1);
  464. TextDrawBoxColor(Draw_Registro[playerid][2], 153);
  465. TextDrawTextSize(Draw_Registro[playerid][2], 335.000000, 30.000000);
  466.  
  467. Draw_Registro[playerid][3] = TextDrawCreate(170.000000, 206.000000, " Sexo");
  468. TextDrawBackgroundColor(Draw_Registro[playerid][3], 255);
  469. TextDrawFont(Draw_Registro[playerid][3], 2);
  470. TextDrawLetterSize(Draw_Registro[playerid][3], 0.500000, 3.000000);
  471. TextDrawColor(Draw_Registro[playerid][3], -1);
  472. TextDrawSetOutline(Draw_Registro[playerid][3], 0);
  473. TextDrawSetProportional(Draw_Registro[playerid][3], 1);
  474. TextDrawSetShadow(Draw_Registro[playerid][3], 1);
  475. TextDrawUseBox(Draw_Registro[playerid][3], 1);
  476. TextDrawBoxColor(Draw_Registro[playerid][3], 153);
  477. TextDrawTextSize(Draw_Registro[playerid][3], 335.000000, 30.000000);
  478.  
  479. Draw_Registro[playerid][4] = TextDrawCreate(170.000000, 267.000000, " Idade");
  480. TextDrawBackgroundColor(Draw_Registro[playerid][4], 255);
  481. TextDrawFont(Draw_Registro[playerid][4], 2);
  482. TextDrawLetterSize(Draw_Registro[playerid][4], 0.500000, 3.000000);
  483. TextDrawColor(Draw_Registro[playerid][4], -1);
  484. TextDrawSetOutline(Draw_Registro[playerid][4], 0);
  485. TextDrawSetProportional(Draw_Registro[playerid][4], 1);
  486. TextDrawSetShadow(Draw_Registro[playerid][4], 1);
  487. TextDrawUseBox(Draw_Registro[playerid][4], 1);
  488. TextDrawBoxColor(Draw_Registro[playerid][4], 153);
  489. TextDrawTextSize(Draw_Registro[playerid][4], 335.000000, 30.000000);
  490.  
  491. Draw_Registro[playerid][5] = TextDrawCreate(390.000000, 146.000000, "New Textdraw");
  492. TextDrawBackgroundColor(Draw_Registro[playerid][5], 255);
  493. TextDrawFont(Draw_Registro[playerid][5], 5);
  494. TextDrawLetterSize(Draw_Registro[playerid][5], 0.600000, -5.099998);
  495. TextDrawColor(Draw_Registro[playerid][5], -1);
  496. TextDrawSetOutline(Draw_Registro[playerid][5], 0);
  497. TextDrawSetProportional(Draw_Registro[playerid][5], 1);
  498. TextDrawSetShadow(Draw_Registro[playerid][5], 1);
  499. TextDrawUseBox(Draw_Registro[playerid][5], 1);
  500. TextDrawBoxColor(Draw_Registro[playerid][5], 255);
  501. TextDrawTextSize(Draw_Registro[playerid][5], 105.000000, 145.000000);
  502. TextDrawSetPreviewModel(Draw_Registro[playerid][5], SKIN_INICIAL);
  503. TextDrawSetPreviewRot(Draw_Registro[playerid][5], -16.000000, 0.000000, -55.000000, 1.000000);
  504.  
  505. Draw_Registro[playerid][6] = TextDrawCreate(139.000000, 310.000000, "~r~Por favor preencha todos os dados !");
  506. TextDrawBackgroundColor(Draw_Registro[playerid][6], 255);
  507. TextDrawFont(Draw_Registro[playerid][6], 2);
  508. TextDrawLetterSize(Draw_Registro[playerid][6], 0.270000, 1.300000);
  509. TextDrawColor(Draw_Registro[playerid][6], -1);
  510. TextDrawSetOutline(Draw_Registro[playerid][6], 1);
  511. TextDrawSetProportional(Draw_Registro[playerid][6], 1);
  512.  
  513. // ==== TextDraw Login
  514.  
  515. Draw_Login[playerid][0] = TextDrawCreate(211.000000, 110.000000, "Ola, sua conta ja esta registrada.");
  516. TextDrawBackgroundColor(Draw_Login[playerid][0], 255);
  517. TextDrawFont(Draw_Login[playerid][0], 2);
  518. TextDrawLetterSize(Draw_Login[playerid][0], 0.219999, 1.899999);
  519. TextDrawColor(Draw_Login[playerid][0], 255);
  520. TextDrawSetOutline(Draw_Login[playerid][0], 0);
  521. TextDrawSetProportional(Draw_Login[playerid][0], 1);
  522. TextDrawSetShadow(Draw_Login[playerid][0], 0);
  523.  
  524. Draw_Login[playerid][1] = TextDrawCreate(385.000000, 310.000000, " Logar");
  525. TextDrawBackgroundColor(Draw_Login[playerid][1], 255);
  526. TextDrawFont(Draw_Login[playerid][1], 2);
  527. TextDrawLetterSize(Draw_Login[playerid][1], 0.209999, 1.600000);
  528. TextDrawColor(Draw_Login[playerid][1], -1);
  529. TextDrawSetOutline(Draw_Login[playerid][1], 0);
  530. TextDrawSetProportional(Draw_Login[playerid][1], 1);
  531. TextDrawSetShadow(Draw_Login[playerid][1], 1);
  532. TextDrawUseBox(Draw_Login[playerid][1], 1);
  533. TextDrawBoxColor(Draw_Login[playerid][1], 153);
  534. TextDrawTextSize(Draw_Login[playerid][1], 437.000000, 10.000000);
  535.  
  536. Draw_Login[playerid][2] = TextDrawCreate(170.000000, 144.000000, " Senha");
  537. TextDrawBackgroundColor(Draw_Login[playerid][2], 255);
  538. TextDrawFont(Draw_Login[playerid][2], 2);
  539. TextDrawLetterSize(Draw_Login[playerid][2], 0.500000, 3.000000);
  540. TextDrawColor(Draw_Login[playerid][2], -1);
  541. TextDrawSetOutline(Draw_Login[playerid][2], 0);
  542. TextDrawSetProportional(Draw_Login[playerid][2], 1);
  543. TextDrawSetShadow(Draw_Login[playerid][2], 1);
  544. TextDrawUseBox(Draw_Login[playerid][2], 1);
  545. TextDrawBoxColor(Draw_Login[playerid][2], 153);
  546. TextDrawTextSize(Draw_Login[playerid][2], 335.000000, 30.000000);
  547.  
  548. Draw_Login[playerid][3] = TextDrawCreate(170.000000, 206.000000, " Forum");
  549. TextDrawBackgroundColor(Draw_Login[playerid][3], 255);
  550. TextDrawFont(Draw_Login[playerid][3], 2);
  551. TextDrawLetterSize(Draw_Login[playerid][3], 0.500000, 3.000000);
  552. TextDrawColor(Draw_Login[playerid][3], -1);
  553. TextDrawSetOutline(Draw_Login[playerid][3], 0);
  554. TextDrawSetProportional(Draw_Login[playerid][3], 1);
  555. TextDrawSetShadow(Draw_Login[playerid][3], 1);
  556. TextDrawUseBox(Draw_Login[playerid][3], 1);
  557. TextDrawBoxColor(Draw_Login[playerid][3], 153);
  558. TextDrawTextSize(Draw_Login[playerid][3], 335.000000, 30.000000);
  559.  
  560. Draw_Login[playerid][4] = TextDrawCreate(170.000000, 267.000000, " WhatsApp");
  561. TextDrawBackgroundColor(Draw_Login[playerid][4], 255);
  562. TextDrawFont(Draw_Login[playerid][4], 2);
  563. TextDrawLetterSize(Draw_Login[playerid][4], 0.500000, 3.000000);
  564. TextDrawColor(Draw_Login[playerid][4], -1);
  565. TextDrawSetOutline(Draw_Login[playerid][4], 0);
  566. TextDrawSetProportional(Draw_Login[playerid][4], 1);
  567. TextDrawSetShadow(Draw_Login[playerid][4], 1);
  568. TextDrawUseBox(Draw_Login[playerid][4], 1);
  569. TextDrawBoxColor(Draw_Login[playerid][4], 153);
  570. TextDrawTextSize(Draw_Login[playerid][4], 335.000000, 30.000000);
  571.  
  572. Draw_Login[playerid][5] = TextDrawCreate(390.000000, 146.000000, "New Textdraw");
  573. TextDrawBackgroundColor(Draw_Login[playerid][5], 255);
  574. TextDrawFont(Draw_Login[playerid][5], 5);
  575. TextDrawLetterSize(Draw_Login[playerid][5], 0.600000, -5.099998);
  576. TextDrawColor(Draw_Login[playerid][5], -1);
  577. TextDrawSetOutline(Draw_Login[playerid][5], 0);
  578. TextDrawSetProportional(Draw_Login[playerid][5], 1);
  579. TextDrawSetShadow(Draw_Login[playerid][5], 1);
  580. TextDrawUseBox(Draw_Login[playerid][5], 1);
  581. TextDrawBoxColor(Draw_Login[playerid][5], 255);
  582. TextDrawTextSize(Draw_Login[playerid][5], 105.000000, 145.000000);
  583. TextDrawSetPreviewModel(Draw_Login[playerid][5], SKIN_USADA);
  584. TextDrawSetPreviewRot(Draw_Login[playerid][5], -16.000000, 0.000000, -55.000000, 1.000000);
  585.  
  586. Draw_Login[playerid][6] = TextDrawCreate(139.000000, 310.000000, "~r~Por favor coloque sua senha !");
  587. TextDrawBackgroundColor(Draw_Login[playerid][6], 255);
  588. TextDrawFont(Draw_Login[playerid][6], 2);
  589. TextDrawLetterSize(Draw_Login[playerid][6], 0.270000, 1.300000);
  590. TextDrawColor(Draw_Login[playerid][6], -1);
  591. TextDrawSetOutline(Draw_Login[playerid][6], 1);
  592. TextDrawSetProportional(Draw_Login[playerid][6], 1);
  593.  
  594. TextDrawSetSelectable(Text:Draw_Fundo[playerid][7], true);
  595. TextDrawSetSelectable(Text:Draw_Registro[playerid][1], true);
  596. TextDrawSetSelectable(Text:Draw_Registro[playerid][2], true);
  597. TextDrawSetSelectable(Text:Draw_Registro[playerid][3], true);
  598. TextDrawSetSelectable(Text:Draw_Registro[playerid][4], true);
  599. TextDrawSetSelectable(Text:Draw_Login[playerid][1], true);
  600. TextDrawSetSelectable(Text:Draw_Login[playerid][2], true);
  601. TextDrawSetSelectable(Text:Draw_Login[playerid][3], true);
  602. TextDrawSetSelectable(Text:Draw_Login[playerid][4], true);
  603. return 1;
  604. }
  605.  
  606. stock TirarTextDraw(playerid)
  607. {
  608. TextDrawHideForPlayer(playerid, Draw_Registro[playerid][0]);
  609. TextDrawHideForPlayer(playerid, Draw_Registro[playerid][1]);
  610. TextDrawHideForPlayer(playerid, Draw_Registro[playerid][2]);
  611. TextDrawHideForPlayer(playerid, Draw_Registro[playerid][3]);
  612. TextDrawHideForPlayer(playerid, Draw_Registro[playerid][4]);
  613. TextDrawHideForPlayer(playerid, Draw_Registro[playerid][5]);
  614. TextDrawHideForPlayer(playerid, Draw_Registro[playerid][6]);
  615. TextDrawHideForPlayer(playerid, Draw_Login[playerid][0]);
  616. TextDrawHideForPlayer(playerid, Draw_Login[playerid][1]);
  617. TextDrawHideForPlayer(playerid, Draw_Login[playerid][2]);
  618. TextDrawHideForPlayer(playerid, Draw_Login[playerid][3]);
  619. TextDrawHideForPlayer(playerid, Draw_Login[playerid][4]);
  620. TextDrawHideForPlayer(playerid, Draw_Login[playerid][5]);
  621. TextDrawHideForPlayer(playerid, Draw_Login[playerid][6]);
  622. TextDrawHideForPlayer(playerid, Draw_Fundo[playerid][0]);
  623. TextDrawHideForPlayer(playerid, Draw_Fundo[playerid][1]);
  624. TextDrawHideForPlayer(playerid, Draw_Fundo[playerid][2]);
  625. TextDrawHideForPlayer(playerid, Draw_Fundo[playerid][3]);
  626. TextDrawHideForPlayer(playerid, Draw_Fundo[playerid][4]);
  627. TextDrawHideForPlayer(playerid, Draw_Fundo[playerid][5]);
  628. TextDrawHideForPlayer(playerid, Draw_Fundo[playerid][6]);
  629. TextDrawHideForPlayer(playerid, Draw_Fundo[playerid][7]);
  630. return 1;
  631. }
  632.  
  633. public OnPlayerClickTextDraw(playerid, Text:clickedid)
  634. {
  635. // === Draw registro
  636. if(clickedid == Draw_Registro[playerid][2]) ShowPlayerDialog(playerid, DIALOG_REGISTRO, DIALOG_STYLE_PASSWORD, "Digite uma senha:", "Digite uma senha abaixo para registrar-se.\n\nObs: Ela deve conter no mínimo 4 e no máximo 16 caracteres.", "Registrar", "Voltar");
  637. if(clickedid == Draw_Registro[playerid][3]) ShowPlayerDialog(playerid, DIALOG_SEXO, DIALOG_STYLE_MSGBOX, "Escolha seu sexo:", "Escolhe seu sexo clicando nos botões abaixo.", "Masculino", "Feminino");
  638. if(clickedid == Draw_Registro[playerid][4]) ShowPlayerDialog(playerid, DIALOG_IDADE, DIALOG_STYLE_INPUT, "Digite sua idade", "Digite a idade do seu personagem abaixo.\n\nObs: Mínimo 10 e máximo 100 anos.", "Registrar", "Voltar");
  639. if(clickedid == Draw_Fundo[playerid][7]) Kick(playerid); //box canxelar
  640.  
  641. if(clickedid == Draw_Registro[playerid][1]) // Registrar
  642. {
  643. if(DigitouSenha[playerid] == 1 && DigitouSexo[playerid] == 1 && DigitouIdade[playerid] == 1)
  644. {
  645. TirarTextDraw(playerid);
  646. DigitouSenha[playerid] = 0;
  647. DigitouSexo[playerid] = 0;
  648. DigitouIdade[playerid] = 0;
  649. PlayerInfo[playerid][Level] = LEVEL_INICIAL;
  650. PlayerInfo[playerid][Skin] = SKIN_INICIAL;
  651. PlayerInfo[playerid][Dinheiro] = DINHEIRO_INICIAL;
  652. PlayerInfo[playerid][Pos][0] = POSX_INICIAL;
  653. PlayerInfo[playerid][Pos][1] = POSY_INICIAL;
  654. PlayerInfo[playerid][Pos][2] = POSZ_INICIAL;
  655. SendClientMessage(playerid, -1, "Sua conta foi registrada com sucesso!");
  656. CarregarDados(playerid);
  657. } else {
  658. TextDrawShowForPlayer(playerid, Draw_Registro[playerid][6]); // mensagem de erro preencha todos os dados
  659. }
  660. }
  661.  
  662. // === TextDraw Login
  663. if(clickedid == Draw_Login[playerid][2]) ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Digite sua senha:", "Você já é um player registrado, digite uma senha abaixo para logar-se", "Logar", "Voltar");
  664.  
  665. if(clickedid == Draw_Login[playerid][1]) // LOGIN
  666. {
  667. if(DigitouLogin[playerid] == 1)
  668. {
  669. new Query[70];
  670. mysql_format(Conexao, Query, sizeof(Query), "SELECT * FROM usuarios WHERE Nome='%s'", Nome(playerid));
  671. mysql_tquery(Conexao, Query, "Mysql_Carregar", "d", playerid);
  672. DigitouLogin[playerid] = 0;
  673. } else {
  674. TextDrawShowForPlayer(playerid, Draw_Login[playerid][6]); // mensagem de erro, esqueceu de digitar senha
  675. }
  676. }
  677.  
  678. if(clickedid == Draw_Login[playerid][4]) // WhatsApp
  679. {
  680. if(ClicouWhats[playerid] == 0)
  681. {
  682. TextDrawSetString(Draw_Login[playerid][4], WHATSAPP);
  683. ClicouWhats[playerid] = 1;
  684. } else if(ClicouWhats[playerid] == 1){
  685. TextDrawSetString(Draw_Login[playerid][4], "WhatsApp");
  686. ClicouWhats[playerid] = 0;
  687. }
  688. }
  689.  
  690. if(clickedid == Draw_Login[playerid][3]) // Forum
  691. {
  692. if(ClicouForum[playerid] == 0)
  693. {
  694. TextDrawSetString(Draw_Login[playerid][3], FORUM);
  695. ClicouForum[playerid] = 1;
  696. } else if(ClicouForum[playerid] == 1){
  697. TextDrawSetString(Draw_Login[playerid][3], "Forum");
  698. ClicouForum[playerid] = 0;
  699. }
  700. }
  701. return 1;
  702. }
  703.  
  704. CMD:trocarsenha(playerid)
  705. {
  706. ShowPlayerDialog(playerid, DIALOG_SENHA, DIALOG_STYLE_PASSWORD, "Digite uma senha:", "Digite sua nova senha abaixo\n\nObs: Ela deve conter no mínimo 4 e no máximo 16 caracteres.", "Trocar", "Voltar");
  707. return 1;
  708. }
  709.  
  710. CMD:trocarnick(playerid)
  711. {
  712. ShowPlayerDialog(playerid, DIALOG_NICK, DIALOG_STYLE_PASSWORD, "Digite um novo nick:", "Digite seu novo nick abaixo\n\nObs: Ele deve conter no máximo 25 caracteres.", "Trocar", "Voltar");
  713. return 1;
  714. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement