Badyx

Registro e Ingreso por dialog

Nov 22nd, 2011
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.40 KB | None | 0 0
  1. Bueno debido a que la gente no sabe como hacer el registro e ingreso con el dialog y que con la otra guia parece ser que no se aclaran paso a explicaros como hacerlo.
  2.  
  3.  
  4. Primero tenemos que borrar el sistema de registro anterior (en el caso de que haiga)
  5.  
  6. Vamos a OnPlayerRegister y veremos algo asi:
  7.  
  8. [spoiler]new sendername[MAX_PLAYER_NAME];
  9. new string[256];
  10. GetPlayerName(playerid, sendername,sizeof(sendername));
  11. format(string, sizeof(string), "SAGC/Accounts/%s.ini", sendername);[/spoiler]
  12.  
  13. Puede variar un poco pero mas o menos sera igual. Hay mas texto pero no voy a poner todo ^^.Bien pues eso lo borraremos mas el comando de registrar y logueo.
  14.  
  15. Y listo. Ahora procederemos a poner el sistema de Registro e ingreso por Dialog.
  16.  
  17.  
  18.  
  19. Lo primero agregamos #include <Dini>
  20.  
  21. Quedando de tal manera
  22.  
  23. #include <a_samp>
  24. #include <Dini>
  25. //demas includes
  26.  
  27. luego agregamos estos dos new:
  28.  
  29. new gPlayerLogTries[MAX_PLAYERS];
  30. new ObjetoConectado[MAX_PLAYERS];
  31.  
  32. Luego nos vamos a OnPlayerConnect y ponemos esto:
  33.  
  34. [spoiler]new sendername[MAX_PLAYER_NAME];
  35. new string[256];
  36. GetPlayerName(playerid, sendername,sizeof(sendername));
  37. format(string, sizeof(string), "SAGC/Accounts/%s.ini", sendername);
  38. ObjetoConectado[playerid] = CreatePlayerObject(playerid,18750,1413.6752,-1040.2668,148.6437,90.0,60.0,180.0);
  39. if(fexist(string))
  40. {
  41. new loginstring[256];
  42. SetPlayerCameraPos(playerid,1334.000,-995.000,149.000);
  43. SetPlayerCameraLookAt(playerid,1339.000,-998.000,149.000);
  44. SetPlayerPos(playerid,1334.000,-995.000,109.000);
  45. format(loginstring,sizeof(loginstring),"{4FC7C9}Bienvenido a nuestro servidor.\n\n\n{4FC7C9}Este Nombre ya se encuentra registrado.\n\n{4FC7C9}Coloca tu contraseña para acceder a tu cuenta.\n\n\n{4FC7C9}Recuerda no usar Cheats.");
  46. ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"{E50000}Callejeros RP{BB9000}RP - {D8711B}Login",loginstring,"Login","Salir");
  47. return 1;
  48. }
  49. else
  50. {
  51. new regstring[256];
  52. SetPlayerCameraPos(playerid,1334.000,-995.000,149.000);
  53. SetPlayerCameraLookAt(playerid,1339.000,-998.000,149.000);
  54. SetPlayerPos(playerid,1334.000,-995.000,109.000);
  55. format(regstring,sizeof(regstring),"{4FC7C9}Bienvenido a nuestro servidor.\n\n{4FC7C9}Esta cuenta no se encuentra registrada.\n{4FC7C9}Coloca tu contraseña abajo para crear un cuenta y poder entrar.");
  56. ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"{E50000}Callejeros RP {BB9000}RP - {D8711B}Registro",regstring,"Registrar","Salir");
  57. }
  58. LimpiarPantalla(playerid);
  59. return 1;
  60. }
  61.  
  62. stock LimpiarPantalla(playerid)
  63. {
  64. SendClientMessage(playerid, COLOR_YELLOW, "");
  65. SendClientMessage(playerid, COLOR_YELLOW, "");
  66. SendClientMessage(playerid, COLOR_YELLOW, "");
  67. SendClientMessage(playerid, COLOR_YELLOW, "");
  68. SendClientMessage(playerid, COLOR_YELLOW, "");
  69. SendClientMessage(playerid, COLOR_YELLOW, "");
  70. SendClientMessage(playerid, COLOR_YELLOW, "");
  71. SendClientMessage(playerid, COLOR_YELLOW, "");
  72. SendClientMessage(playerid, COLOR_YELLOW, "");
  73. SendClientMessage(playerid, COLOR_YELLOW, "");
  74. SendClientMessage(playerid, COLOR_YELLOW, "");
  75. SendClientMessage(playerid, COLOR_YELLOW, "");
  76. SendClientMessage(playerid, COLOR_YELLOW, "");
  77. SendClientMessage(playerid, COLOR_YELLOW, "");
  78. SendClientMessage(playerid, COLOR_YELLOW, "");
  79. SendClientMessage(playerid, COLOR_YELLOW, "");
  80. SendClientMessage(playerid, COLOR_YELLOW, "");
  81. SendClientMessage(playerid, COLOR_YELLOW, "");
  82. SendClientMessage(playerid, COLOR_YELLOW, "");
  83. SendClientMessage(playerid, COLOR_YELLOW, "");
  84. SendClientMessage(playerid, COLOR_YELLOW, "");
  85. SendClientMessage(playerid, COLOR_YELLOW, "");
  86. SendClientMessage(playerid, COLOR_YELLOW, "");
  87. SendClientMessage(playerid, COLOR_YELLOW, "");
  88. SendClientMessage(playerid, COLOR_YELLOW, "");
  89. SendClientMessage(playerid, COLOR_YELLOW, "");
  90. SendClientMessage(playerid, COLOR_YELLOW, "");
  91. SendClientMessage(playerid, COLOR_YELLOW, "");
  92. SendClientMessage(playerid, COLOR_YELLOW, "");
  93. SendClientMessage(playerid, COLOR_YELLOW, "");
  94. SendClientMessage(playerid, COLOR_YELLOW, "");
  95. SendClientMessage(playerid, COLOR_YELLOW, "");
  96. SendClientMessage(playerid, COLOR_YELLOW, "");
  97. SendClientMessage(playerid, COLOR_YELLOW, "");
  98. SendClientMessage(playerid, COLOR_YELLOW, "");
  99. SendClientMessage(playerid, COLOR_YELLOW, "");
  100. SendClientMessage(playerid, COLOR_YELLOW, "");
  101. SendClientMessage(playerid, COLOR_YELLOW, "");
  102. SendClientMessage(playerid, COLOR_YELLOW, "");
  103. SendClientMessage(playerid, COLOR_YELLOW, "");
  104. SendClientMessage(playerid, COLOR_YELLOW, "");
  105. SendClientMessage(playerid, COLOR_YELLOW, "");
  106. SendClientMessage(playerid, COLOR_YELLOW, "");
  107. SendClientMessage(playerid, COLOR_YELLOW, "");
  108. SendClientMessage(playerid, COLOR_YELLOW, "");
  109. SendClientMessage(playerid, COLOR_YELLOW, "");
  110. SendClientMessage(playerid, COLOR_YELLOW, "");
  111. SendClientMessage(playerid, COLOR_YELLOW, "");
  112. SendClientMessage(playerid, COLOR_YELLOW, "");
  113. SendClientMessage(playerid, COLOR_YELLOW, "");
  114. SendClientMessage(playerid, COLOR_YELLOW, "");
  115. SendClientMessage(playerid, COLOR_YELLOW, "");
  116. SendClientMessage(playerid, COLOR_YELLOW, "");
  117. SendClientMessage(playerid, COLOR_YELLOW, "");
  118. SendClientMessage(playerid, COLOR_YELLOW, "");
  119. SendClientMessage(playerid, COLOR_YELLOW, "");
  120. SendClientMessage(playerid, COLOR_YELLOW, "");
  121. SendClientMessage(playerid, COLOR_YELLOW, "");
  122. SendClientMessage(playerid, COLOR_YELLOW, "");
  123. SendClientMessage(playerid, COLOR_YELLOW, "");
  124. SendClientMessage(playerid, COLOR_YELLOW, "");
  125. SendClientMessage(playerid, COLOR_YELLOW, "");
  126. SendClientMessage(playerid, COLOR_YELLOW, "");
  127. SendClientMessage(playerid, COLOR_YELLOW, "");
  128. SendClientMessage(playerid, COLOR_YELLOW, "");
  129. SendClientMessage(playerid, COLOR_YELLOW, "");
  130. SendClientMessage(playerid, COLOR_YELLOW, "");
  131. SendClientMessage(playerid, COLOR_YELLOW, "");
  132. SendClientMessage(playerid, COLOR_YELLOW, "");
  133. SendClientMessage(playerid, COLOR_YELLOW, "");
  134. SendClientMessage(playerid, COLOR_YELLOW, "");
  135. SendClientMessage(playerid, COLOR_YELLOW, "");
  136. SendClientMessage(playerid, COLOR_YELLOW, "");
  137. SendClientMessage(playerid, COLOR_YELLOW, "");
  138. SendClientMessage(playerid, COLOR_YELLOW, "");
  139. SendClientMessage(playerid, COLOR_YELLOW, "");
  140. SendClientMessage(playerid, COLOR_YELLOW, "");
  141. SendClientMessage(playerid, COLOR_YELLOW, "");
  142. SendClientMessage(playerid, COLOR_YELLOW, "");
  143. SendClientMessage(playerid, COLOR_YELLOW, "");
  144. SendClientMessage(playerid, COLOR_YELLOW, "");
  145. SendClientMessage(playerid, COLOR_YELLOW, "");
  146. SendClientMessage(playerid, COLOR_YELLOW, "");
  147. SendClientMessage(playerid, COLOR_YELLOW, "");
  148. SendClientMessage(playerid, COLOR_YELLOW, "");
  149. SendClientMessage(playerid, COLOR_YELLOW, "");
  150. SendClientMessage(playerid, COLOR_YELLOW, "");
  151. SendClientMessage(playerid, COLOR_YELLOW, "");
  152. SendClientMessage(playerid, COLOR_YELLOW, "");
  153. SendClientMessage(playerid, COLOR_YELLOW, "");
  154. SendClientMessage(playerid, COLOR_YELLOW, "");
  155. SendClientMessage(playerid, COLOR_YELLOW, "");
  156. SendClientMessage(playerid, COLOR_YELLOW, "");
  157. SendClientMessage(playerid, COLOR_YELLOW, "");
  158. SendClientMessage(playerid, COLOR_YELLOW, "");
  159. SendClientMessage(playerid, COLOR_YELLOW, "");
  160. SendClientMessage(playerid, COLOR_YELLOW, "");
  161. SendClientMessage(playerid, COLOR_YELLOW, "");
  162. SendClientMessage(playerid, COLOR_YELLOW, "");
  163. SendClientMessage(playerid, COLOR_YELLOW, "");
  164. SendClientMessage(playerid, COLOR_YELLOW, "");
  165. SendClientMessage(playerid, COLOR_YELLOW, "");
  166. SendClientMessage(playerid, COLOR_YELLOW, "");
  167. SendClientMessage(playerid, COLOR_YELLOW, "");
  168. SendClientMessage(playerid, COLOR_YELLOW, "");
  169. SendClientMessage(playerid, COLOR_YELLOW, "");
  170. SendClientMessage(playerid, COLOR_YELLOW, "");
  171. SendClientMessage(playerid, COLOR_YELLOW, "");
  172. SendClientMessage(playerid, COLOR_YELLOW, "");
  173. SendClientMessage(playerid, COLOR_YELLOW, "");
  174. SendClientMessage(playerid, COLOR_YELLOW, "");
  175. SendClientMessage(playerid, COLOR_YELLOW, "");
  176. SendClientMessage(playerid, COLOR_YELLOW, "");
  177. SendClientMessage(playerid, COLOR_YELLOW, "");
  178. SendClientMessage(playerid, COLOR_YELLOW, "");
  179. SendClientMessage(playerid, COLOR_YELLOW, "");
  180. SendClientMessage(playerid, COLOR_YELLOW, "");
  181. SendClientMessage(playerid, COLOR_YELLOW, "");
  182. SendClientMessage(playerid, COLOR_YELLOW, "");
  183. SendClientMessage(playerid, COLOR_YELLOW, "");
  184. SendClientMessage(playerid, COLOR_YELLOW, "");
  185. SendClientMessage(playerid, COLOR_YELLOW, "");
  186. SendClientMessage(playerid, COLOR_YELLOW, "");
  187. SendClientMessage(playerid, COLOR_YELLOW, "");
  188. SendClientMessage(playerid, COLOR_YELLOW, "");
  189. SendClientMessage(playerid, COLOR_YELLOW, "");
  190. SendClientMessage(playerid, COLOR_YELLOW, "");
  191. SendClientMessage(playerid, COLOR_YELLOW, "");
  192. SendClientMessage(playerid, COLOR_YELLOW, "");
  193. SendClientMessage(playerid, COLOR_YELLOW, "");
  194. SendClientMessage(playerid, COLOR_YELLOW, "");
  195. SendClientMessage(playerid, COLOR_YELLOW, "");
  196. SendClientMessage(playerid, COLOR_YELLOW, "");
  197. SendClientMessage(playerid, COLOR_YELLOW, "");
  198. SendClientMessage(playerid, COLOR_YELLOW, "");
  199. SendClientMessage(playerid, COLOR_YELLOW, "");
  200. SendClientMessage(playerid, COLOR_YELLOW, "");
  201. SendClientMessage(playerid, COLOR_YELLOW, "");
  202. SendClientMessage(playerid, COLOR_YELLOW, "");
  203. SendClientMessage(playerid, COLOR_YELLOW, "");
  204. SendClientMessage(playerid, COLOR_YELLOW, "");
  205. SendClientMessage(playerid, COLOR_YELLOW, "");
  206. SendClientMessage(playerid, COLOR_YELLOW, "");
  207. SendClientMessage(playerid, COLOR_YELLOW, "");
  208. SendClientMessage(playerid, COLOR_YELLOW, "");
  209. SendClientMessage(playerid, COLOR_YELLOW, "");
  210. SendClientMessage(playerid, COLOR_YELLOW, "");
  211. SendClientMessage(playerid, COLOR_YELLOW, "");
  212. SendClientMessage(playerid, COLOR_YELLOW, "");
  213. SendClientMessage(playerid, COLOR_YELLOW, "");
  214. SendClientMessage(playerid, COLOR_YELLOW, "");
  215. SendClientMessage(playerid, COLOR_YELLOW, "");
  216. SendClientMessage(playerid, COLOR_YELLOW, "");
  217. SendClientMessage(playerid, COLOR_YELLOW, "");
  218. SendClientMessage(playerid, COLOR_YELLOW, "");
  219. SendClientMessage(playerid, COLOR_YELLOW, "");
  220. SendClientMessage(playerid, COLOR_YELLOW, "");
  221. SendClientMessage(playerid, COLOR_YELLOW, "");
  222. SendClientMessage(playerid, COLOR_YELLOW, "");
  223. SendClientMessage(playerid, COLOR_YELLOW, "");
  224. }[/spoiler]
  225.  
  226. Ahora vamos a OnDialogResponse y añadimos esto:
  227.  
  228. [spoiler]if(dialogid == 1)
  229. {
  230. if(response)
  231. {
  232. if(strlen(inputtext))
  233. {
  234. new tmppass[64];
  235. strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
  236. //Encrypt(tmppass);
  237. OnPlayerLogin(playerid,tmppass);
  238. }
  239. else
  240. {
  241. new loginstring[256];
  242. format(loginstring,sizeof(loginstring)," {E60720}Contraseña incorrecta\n\n{4FC7C9}Coloca tu contraseña para acceder a tu cuenta.");
  243. ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"{E50000}Callejeros RP {BB9000}RP - {D8711B}Error",loginstring,"Login","Salir");
  244. gPlayerLogTries[playerid] += 1;
  245. if(gPlayerLogTries[playerid] == 3) { Kick(playerid); }
  246. }
  247. }
  248. else
  249. {
  250. Kick(playerid);
  251. }
  252. return 1;
  253. }
  254. if(dialogid == 2)
  255. {
  256. if(response)
  257. {
  258. if(strlen(inputtext))
  259. {
  260. new string[128];
  261. new sendername[MAX_PLAYER_NAME];
  262. GetPlayerName(playerid, sendername, sizeof(sendername));
  263. format(string, sizeof(string), "SAGC/Accounts/%s.ini", sendername);
  264. new File: hFile = fopen(string, io_read);
  265. if (hFile)
  266. {
  267. SendClientMessage(playerid, 0xFFFF00AA, "Por favor, Elija otro nombre.");
  268. fclose(hFile);
  269. Kick(playerid);
  270. return 1;
  271. }
  272. new tmppass[64];
  273. strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
  274. //Encrypt(tmppass);
  275. OnPlayerRegister(playerid,tmppass);
  276. }
  277. else
  278. {
  279. new regstring[128];
  280. format(regstring,sizeof(regstring),"{4FC7C9}Bienvenido a nuestro servidor.\n\n{4FC7C9}Esta cuenta no se encuentra registrada.\n{4FC7C9}Coloca tu contraseña abajo para crear un cuenta y poder entrar.");
  281. ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"{E50000}Callejeros RP {BB9000}RP - {D8711B}Registro",regstring,"Registrar","Salir");
  282. }
  283. }
  284. else
  285. {
  286. Kick(playerid);
  287. }
  288. }[/spoiler]
  289.  
  290. Hasta aqui tendriamos todo echo pero si probamos asi no nos logueara y estaremos igual... ¿Que podemos hacer? Vamos a OnPlayerRegister y agregamos:
  291.  
  292. [spoiler]fclose(hFile);
  293. new loginstring[256];
  294. format(loginstring,sizeof(loginstring),"{4FC7C9}Bienvenido a nuestro servidor.\n\n\n{4FC7C9}Este Nombre ya se encuentra registrado.\n\n{4FC7C9}Coloca tu contraseña para acceder a tu cuenta.\n\n\n{4FC7C9}Recuerda no usar Cheats.");
  295. ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"{E50000}Virtual Rol {BB9000}RP - {D8711B}Login",loginstring,"Login","Salir");
  296. }
  297. }
  298. return 1;
  299. }[/spoiler]
  300.  
  301. Ahora si compilamos y FUNCIONA!!
  302.  
  303. Tenemos que crear una carpeta que se llame Usuarios.
  304.  
  305. Creo que no me olvide nada. :lol2:
  306.  
  307. Suerte
  308. Creditos:
  309. [spoiler]80% grove4l Ya que me base en su Gm de Virtual rol
  310. 20% Bady Por sacar el sistema y postear este tutorial[/spoiler]
  311.  
Advertisement
Add Comment
Please, Sign In to add comment