Advertisement
Guest User

Filescript - DesingP

a guest
Jul 26th, 2014
859
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.15 KB | None | 0 0
  1. /*------------------------------------------------------------------------------
  2. * Este sistema fue programado por DesingP
  3. * Se prohibe la publicacion del post en otras comunidades sin su autorizacion
  4. * Este metedo es el pastebin, te recomiendo descargarte las carpetas correspondientes
  5. -*----------------------------------------------------------------------------*/
  6.  
  7. #include <a_samp>
  8. #include <zcmd>
  9. #include <djson>
  10.  
  11. /*----------------------------------------------------------------------------*/
  12.  
  13. #define DIALOG_INGRESO 0
  14. #define DIALOG_REGISTRO 1
  15. #define DIALOG_REGISTRO_FINALIZADO 2
  16. #define DIALOG_ESTADISTICAS 3
  17.  
  18. #define MAX_PASSWORD_INVALIDA 4
  19. #define MAX_STRINGS 256
  20.  
  21. #define COLOR_CELESTE 0x00C8FFFF
  22. #define CELESTE "{00C8FF}"
  23. #define COLOR_BLANCO 0xFFFFFFFF
  24. #define BLANCO "{FFFFFF}"
  25.  
  26. /*----------------------------------------------------------------------------*/
  27.  
  28. enum pInfo
  29. {
  30. pIdentificado,
  31. pRegistrado,
  32. pAsesinatos,
  33. pMuertes,
  34. pDinero,
  35. pScore,
  36. pPasswordIncorrecta
  37. };
  38. new PlayerInfo[MAX_PLAYERS][pInfo];
  39.  
  40. /*----------------------------------------------------------------------------*/
  41.  
  42. forward CuandoUnJugadorCierraSesion(playerid);
  43.  
  44. /*----------------------------------------------------------------------------*/
  45.  
  46. public OnFilterScriptInit()
  47. {
  48. djson_GameModeInit();
  49.  
  50. // ---------------------------------
  51.  
  52. new dma[3],
  53. hms[3];
  54.  
  55. getdate(dma[2], dma[1], dma[0]);
  56. gettime(hms[0], hms[1], hms[2]);
  57.  
  58. // ---------------------------------
  59.  
  60. print("\n--------------------------------------------------------------------" );
  61. print( " [Programacion] Esto fue programado por DesingP. " );
  62. print( "--------------------------------------------------------------------" );
  63. printf( " Fecha: %i-%i-%i Hora: %i:%i:%i",dma[0], dma[1], dma[2], hms[0], hms[1], hms[2]);
  64. print( "--------------------------------------------------------------------\n" );
  65.  
  66. // ---------------------------------
  67.  
  68. if (!fexist("Cuentas"))
  69. {
  70. print(" > Error, falta la carpeta \"Cuentas\" en ScriptFiles\n\n");
  71. } else if (fexist("Cuentas"))
  72. {
  73. print(" > Los \"datos\" de los usuarios fueron cargados correctamente.\n\n");
  74. }
  75.  
  76. // ---------------------------------
  77.  
  78. return 1;
  79. }
  80.  
  81. /*----------------------------------------------------------------------------*/
  82.  
  83. public OnFilterScriptExit()
  84. {
  85. djson_GameModeExit();
  86.  
  87. // ---------------------------------
  88.  
  89. new dma[3],
  90. hms[3];
  91.  
  92. getdate(dma[2], dma[1], dma[0]);
  93. gettime(hms[0], hms[1], hms[2]);
  94.  
  95. // ---------------------------------
  96.  
  97. print("\n--------------------------------------------------------------------" );
  98. printf( " Fecha: %i-%i-%i Hora: %i:%i:%i",dma[0], dma[1], dma[2], hms[0], hms[1], hms[2]);
  99. print( "--------------------------------------------------------------------\n" );
  100.  
  101. // ---------------------------------
  102.  
  103. return 1;
  104. }
  105.  
  106. /*----------------------------------------------------------------------------*/
  107.  
  108. public OnPlayerConnect(playerid)
  109. {
  110. PlayerInfo[playerid][pIdentificado] = 0;
  111. PlayerInfo[playerid][pRegistrado] = 0;
  112. PlayerInfo[playerid][pAsesinatos] = 0;
  113. PlayerInfo[playerid][pMuertes] = 0;
  114. PlayerInfo[playerid][pDinero] = 0;
  115. PlayerInfo[playerid][pScore] = 0;
  116. PlayerInfo[playerid][pPasswordIncorrecta] = 0;
  117.  
  118. // ---------------------------------
  119.  
  120. if (fexist(pArchivo(playerid)))
  121. {
  122. PlayerInfo[playerid][pRegistrado] = 1;
  123. }
  124.  
  125. // ---------------------------------
  126.  
  127. new string[MAX_STRINGS];
  128. if (PlayerInfo[playerid][pRegistrado])
  129. {
  130. format(string, sizeof(string), "{FFFFFF}- Bienvenido {FFFF00}%s.{FFFFFF}\n{FFFFFF}- Escribe una contraseña para identificarte", pNombre(playerid));
  131. ShowPlayerDialog(playerid, DIALOG_INGRESO, DIALOG_STYLE_INPUT, ""#CELESTE"Ingreso", string, "Ingresar", "Salir");
  132. }
  133. else
  134. {
  135. format(string, sizeof(string), "{FFFFFF}- Bienvenido {FFFF00}%s.{FFFFFF}\n{FFFFFF}- Escribe una contraseña para registrarte", pNombre(playerid));
  136. ShowPlayerDialog(playerid, DIALOG_REGISTRO, DIALOG_STYLE_INPUT, "{FFFF00}Registro", string, "Registrar", "Salir");
  137. }
  138.  
  139. // ---------------------------------
  140.  
  141. return 1;
  142. }
  143.  
  144. /*----------------------------------------------------------------------------*/
  145.  
  146. public OnPlayerText(playerid, text[])
  147. {
  148. if((!PlayerInfo[playerid][pRegistrado]) || (!PlayerInfo[playerid][pIdentificado]))
  149. {
  150. SendClientMessage(playerid, COLOR_CELESTE, "{FFFF00}[DesingP]: {FFFFFF}No puedes hablar hasta no \"Registrarte\" y \"Ingresar\"");
  151. return 0;
  152. }
  153.  
  154. // ---------------------------------
  155.  
  156. return 1;
  157. }
  158.  
  159. /*----------------------------------------------------------------------------*/
  160.  
  161. public OnPlayerRequestSpawn(playerid)
  162. {
  163. if ((!PlayerInfo[playerid][pRegistrado]) || (!PlayerInfo[playerid][pIdentificado]))
  164. {
  165. SendClientMessage(playerid, COLOR_CELESTE, "{FFFF00}[DesingP]: {FFFFFF}No puedes spawnear hasta no \"Registrarte\" y \"Ingresar\"");
  166. return 0;
  167. }
  168.  
  169. // ---------------------------------
  170.  
  171. return 1;
  172. }
  173.  
  174. /*----------------------------------------------------------------------------*/
  175.  
  176. public OnPlayerDeath(playerid, killerid, reason)
  177. {
  178. if(killerid == INVALID_PLAYER_ID)
  179. {
  180. PlayerInfo[playerid][pMuertes]++;
  181. }
  182. else
  183. {
  184. PlayerInfo[killerid][pAsesinatos]++;
  185. PlayerInfo[playerid][pMuertes]++;
  186. }
  187.  
  188. // ---------------------------------
  189.  
  190. return 1;
  191. }
  192.  
  193. /*----------------------------------------------------------------------------*/
  194.  
  195. public OnPlayerDisconnect(playerid, reason)
  196. {
  197. new string[MAX_STRINGS];
  198. switch (reason)
  199. {
  200. case 0: format(string,sizeof(string),"{FFFF00}[DesingP]: {FFFFFF}%s ha salido del servidor (Conexion Fallida)",pNombre(playerid));
  201. case 1: format(string,sizeof(string),"{FFFF00}[DesingP]: {FFFFFF}%s ha salido del servidor.",pNombre(playerid));
  202. case 2: format(string,sizeof(string),"{FFFF00}[DesingP]: {FFFFFF}%s ha salido del servidor (Kick/Ban)",pNombre(playerid));
  203. }
  204. SendClientMessageToAll(COLOR_BLANCO,string);
  205.  
  206. // ---------------------------------
  207.  
  208. if (PlayerInfo[playerid][pIdentificado])
  209. {
  210. CallLocalFunction("CuandoUnJugadorCierraSesion", "i", playerid);
  211. }
  212.  
  213. return 1;
  214. }
  215.  
  216. /*----------------------------------------------------------------------------*/
  217.  
  218. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  219. {
  220. new string[MAX_STRINGS];
  221. if(dialogid == DIALOG_REGISTRO)
  222. {
  223. if(!response) return Kick(playerid);
  224. {
  225. if(strlen(inputtext) <= 4)
  226. {
  227. format(string, sizeof(string) ,"{FFFFFF}- Por favor {FFFF00}%s.{FFFFFF}\n{FFFFFF}- Tu contraseña debe tener mas de 4 a 16 digitos." ,pNombre(playerid));
  228. ShowPlayerDialog(playerid, DIALOG_REGISTRO, DIALOG_STYLE_INPUT, "{FFFF00}Registro", string, "Registrar", "Salir");
  229. PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  230. return 1;
  231. }
  232.  
  233. // ---------------------------------
  234.  
  235. djCreateFile (pArchivo(playerid));
  236. djSetInt (pArchivo(playerid), "Contraseña", adler32(inputtext));
  237. djSetInt (pArchivo(playerid), "Asesinatos", PlayerInfo[playerid][pAsesinatos]);
  238. djSetInt (pArchivo(playerid), "Muertes", PlayerInfo[playerid][pMuertes]);
  239. djSetInt (pArchivo(playerid), "Dinero", PlayerInfo[playerid][pDinero]);
  240. djSetInt (pArchivo(playerid), "Score", PlayerInfo[playerid][pScore]);
  241. djSet (pArchivo(playerid), "Fecha de Registro", GetDateAndTime());
  242. djCommit (pArchivo(playerid));
  243.  
  244. // ---------------------------------
  245.  
  246. PlayerInfo[playerid][pIdentificado] = 1;
  247. PlayerInfo[playerid][pRegistrado] = 1;
  248.  
  249. // ---------------------------------
  250.  
  251. PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
  252.  
  253. // ---------------------------------
  254.  
  255. format(string, sizeof (string), "{FFFFFF}- Fuiste registrado en nuestra base de datos {FFFF00}%s.\n{FFFF00}- Tu contraseña:{FFFFFF} %s\n{FFFF00}Fecha actual de registro:{FFFFFF} %s", pNombre(playerid), inputtext, GetDateAndTime());
  256. ShowPlayerDialog(playerid, DIALOG_REGISTRO_FINALIZADO, DIALOG_STYLE_MSGBOX, "{FFFF00}Registro terminado", string, "Aceptar", "");
  257. }
  258. }
  259.  
  260. // ---------------------------------
  261.  
  262. if(dialogid == DIALOG_INGRESO)
  263. {
  264. if(!response) return Kick(playerid);
  265. {
  266. if(strlen(inputtext) == 0)
  267. {
  268. format(string, sizeof(string) ,"{FFFFFF}- Por favor {FFFF00}%s.{FFFFFF}\n{FFFFFF}- No introduciste ningun digito, escribelo nuevamente" ,pNombre(playerid));
  269. ShowPlayerDialog(playerid, DIALOG_INGRESO, DIALOG_STYLE_INPUT, "{FFFF00}Ingreso", string, "Ingresar", "Salir");
  270. PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  271. return 1;
  272. }
  273. if (djInt(pArchivo(playerid), "Contraseña") == adler32(inputtext))
  274. {
  275.  
  276. // ---------------------------------
  277.  
  278. PlayerInfo[playerid][pIdentificado] = 1;
  279. PlayerInfo[playerid][pRegistrado] = 1;
  280. PlayerInfo[playerid][pAsesinatos] = djInt (pArchivo(playerid), "Asesinatos");
  281. PlayerInfo[playerid][pMuertes] = djInt (pArchivo(playerid), "Muertes");
  282. GivePlayerMoney(playerid, djInt (pArchivo(playerid), "Dinero"));
  283. SetPlayerScore(playerid, djInt (pArchivo(playerid), "Score"));
  284. djSet (pArchivo(playerid), "Ultimo inicio de sesion", GetDateAndTime());
  285.  
  286. // ---------------------------------
  287.  
  288. PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
  289.  
  290. // ---------------------------------
  291.  
  292. }
  293. else
  294. {
  295. PlayerInfo[playerid][pPasswordIncorrecta]++;
  296. format(string, sizeof(string), "{FFFFFF}- Por favor {FFFF00}%s.{FFFFFF}\n{FFFFFF}- Ingresa una contraseña correcta",pNombre(playerid));
  297. ShowPlayerDialog(playerid, DIALOG_INGRESO, DIALOG_STYLE_INPUT, "{FFFF00}Ingreso", string, "Ingresar", "Salir");
  298. PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
  299.  
  300. // ---------------------------------
  301.  
  302. if (PlayerInfo[playerid][pPasswordIncorrecta] == MAX_PASSWORD_INVALIDA)
  303. {
  304. format(string,sizeof(string),"{FFFF00}[DesingP]: %s fue expulsado (Max intentos de ingresar(Contraseña invalida))",pNombre(playerid));
  305. SendClientMessageToAll(COLOR_BLANCO, string);
  306. SendClientMessage(playerid, COLOR_BLANCO, "** Haz puesto varias contraseñas incorrectas has sido kickeado del servidor por seguridad.");
  307. Kick(playerid);
  308. }
  309. return 1;
  310. }
  311. }
  312. }
  313. return 1;
  314. }
  315.  
  316. /*----------------------------------------------------------------------------*/
  317.  
  318. public CuandoUnJugadorCierraSesion(playerid)
  319. {
  320. djSetInt (pArchivo(playerid), "Asesinatos", PlayerInfo[playerid][pAsesinatos]);
  321. djSetInt (pArchivo(playerid), "Muertes", PlayerInfo[playerid][pMuertes]);
  322. djSetInt (pArchivo(playerid), "Dinero", GetPlayerMoney(playerid));
  323. djSetInt (pArchivo(playerid), "Score", GetPlayerScore(playerid));
  324. djSet (pArchivo(playerid), "Ultimo cierre de sesion", GetDateAndTime());
  325. djCommit (pArchivo(playerid));
  326. }
  327.  
  328. /*----------------------------------------------------------------------------*/
  329.  
  330. CMD:cuenta(playerid, params[])
  331. {
  332. new string[MAX_STRINGS];
  333. format(string,sizeof(string),"{FFFF00}- Nombre:{FFFFFF} %s\n{FFFF00}- Asesinatos:{FFFFFF} %i\n{FFFF00}- Muertes:{FFFFFF} %i\n{FFFF00}- Score:{FFFFFF} %i\n{FFFF00}- Ping: {FFFFFF}%i\n{FFFF00}- Interior:{FFFFFF} %i\n{FFFF00}- Mundo:{FFFFFF} %i\n{FFFF00}- Dinero:{FFFFFF} %i",pNombre(playerid),PlayerInfo[playerid][pAsesinatos],PlayerInfo[playerid][pMuertes],GetPlayerScore(playerid),GetPlayerPing(playerid),GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid),GetPlayerMoney(playerid));
  334. ShowPlayerDialog(playerid,DIALOG_ESTADISTICAS,DIALOG_STYLE_MSGBOX,"{FFFF00}Cuenta del servidor",string,"Aceptar","");
  335. return 1;
  336. }
  337.  
  338. /*----------------------------------------------------------------------------*-
  339. | • Stock's • |
  340. -*----------------------------------------------------------------------------*/
  341.  
  342. stock pNombre(playerid)
  343. {
  344. new Nombre[MAX_PLAYER_NAME];
  345. GetPlayerName(playerid, Nombre, sizeof(Nombre));
  346. return Nombre;
  347. }
  348.  
  349. /*----------------------------------------------------------------------------*/
  350.  
  351. stock pArchivo(playerid)
  352. {
  353. new string[MAX_STRINGS];
  354. GetPlayerName(playerid, string, sizeof (string));
  355. format(string, sizeof (string), "Cuentas/%s.json", string);
  356. return string;
  357. }
  358.  
  359. /*----------------------------------------------------------------------------*/
  360.  
  361. stock GetDateAndTime()
  362. {
  363. new string[MAX_STRINGS],dma[3],hms[3];
  364. getdate(dma[2], dma[1], dma[0]);
  365. gettime(hms[0], hms[1], hms[2]);
  366. format(string,sizeof(string),"%i/%i /%i - %i:%i:%i",dma[0], dma[1], dma[2], hms[0], hms[1], hms[2]);
  367. return string;
  368. }
  369.  
  370. /*----------------------------------------------------------------------------*/
  371.  
  372. stock adler32(buf[])
  373. {
  374. new len = strlen(buf), key1 = 1, key2 = 0, n;
  375. for (n = 0; n < len; n ++)
  376. {
  377. key1 = (key1 + buf[n]) % 65521;
  378. key2 = (key2 + key1) % 65521;
  379. }
  380. return (key2 << 16) + key1;
  381. }
  382.  
  383. /*----------------------------------------------------------------------------*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement