Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*------------------------------------------------------------------------------
- * Este sistema fue programado por DesingP
- * Se prohibe la publicacion del post en otras comunidades sin su autorizacion
- * Este metedo es el pastebin, te recomiendo descargarte las carpetas correspondientes
- -*----------------------------------------------------------------------------*/
- #include <a_samp>
- #include <zcmd>
- #include <djson>
- /*----------------------------------------------------------------------------*/
- #define DIALOG_INGRESO 0
- #define DIALOG_REGISTRO 1
- #define DIALOG_REGISTRO_FINALIZADO 2
- #define DIALOG_ESTADISTICAS 3
- #define MAX_PASSWORD_INVALIDA 4
- #define MAX_STRINGS 256
- #define COLOR_CELESTE 0x00C8FFFF
- #define CELESTE "{00C8FF}"
- #define COLOR_BLANCO 0xFFFFFFFF
- #define BLANCO "{FFFFFF}"
- /*----------------------------------------------------------------------------*/
- enum pInfo
- {
- pIdentificado,
- pRegistrado,
- pAsesinatos,
- pMuertes,
- pDinero,
- pScore,
- pPasswordIncorrecta
- };
- new PlayerInfo[MAX_PLAYERS][pInfo];
- /*----------------------------------------------------------------------------*/
- forward CuandoUnJugadorCierraSesion(playerid);
- /*----------------------------------------------------------------------------*/
- public OnFilterScriptInit()
- {
- djson_GameModeInit();
- // ---------------------------------
- new dma[3],
- hms[3];
- getdate(dma[2], dma[1], dma[0]);
- gettime(hms[0], hms[1], hms[2]);
- // ---------------------------------
- print("\n--------------------------------------------------------------------" );
- print( " [Programacion] Esto fue programado por DesingP. " );
- print( "--------------------------------------------------------------------" );
- printf( " Fecha: %i-%i-%i Hora: %i:%i:%i",dma[0], dma[1], dma[2], hms[0], hms[1], hms[2]);
- print( "--------------------------------------------------------------------\n" );
- // ---------------------------------
- if (!fexist("Cuentas"))
- {
- print(" > Error, falta la carpeta \"Cuentas\" en ScriptFiles\n\n");
- } else if (fexist("Cuentas"))
- {
- print(" > Los \"datos\" de los usuarios fueron cargados correctamente.\n\n");
- }
- // ---------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- public OnFilterScriptExit()
- {
- djson_GameModeExit();
- // ---------------------------------
- new dma[3],
- hms[3];
- getdate(dma[2], dma[1], dma[0]);
- gettime(hms[0], hms[1], hms[2]);
- // ---------------------------------
- print("\n--------------------------------------------------------------------" );
- printf( " Fecha: %i-%i-%i Hora: %i:%i:%i",dma[0], dma[1], dma[2], hms[0], hms[1], hms[2]);
- print( "--------------------------------------------------------------------\n" );
- // ---------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- public OnPlayerConnect(playerid)
- {
- PlayerInfo[playerid][pIdentificado] = 0;
- PlayerInfo[playerid][pRegistrado] = 0;
- PlayerInfo[playerid][pAsesinatos] = 0;
- PlayerInfo[playerid][pMuertes] = 0;
- PlayerInfo[playerid][pDinero] = 0;
- PlayerInfo[playerid][pScore] = 0;
- PlayerInfo[playerid][pPasswordIncorrecta] = 0;
- // ---------------------------------
- if (fexist(pArchivo(playerid)))
- {
- PlayerInfo[playerid][pRegistrado] = 1;
- }
- // ---------------------------------
- new string[MAX_STRINGS];
- if (PlayerInfo[playerid][pRegistrado])
- {
- format(string, sizeof(string), "{FFFFFF}- Bienvenido {FFFF00}%s.{FFFFFF}\n{FFFFFF}- Escribe una contraseña para identificarte", pNombre(playerid));
- ShowPlayerDialog(playerid, DIALOG_INGRESO, DIALOG_STYLE_INPUT, ""#CELESTE"Ingreso", string, "Ingresar", "Salir");
- }
- else
- {
- format(string, sizeof(string), "{FFFFFF}- Bienvenido {FFFF00}%s.{FFFFFF}\n{FFFFFF}- Escribe una contraseña para registrarte", pNombre(playerid));
- ShowPlayerDialog(playerid, DIALOG_REGISTRO, DIALOG_STYLE_INPUT, "{FFFF00}Registro", string, "Registrar", "Salir");
- }
- // ---------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- public OnPlayerText(playerid, text[])
- {
- if((!PlayerInfo[playerid][pRegistrado]) || (!PlayerInfo[playerid][pIdentificado]))
- {
- SendClientMessage(playerid, COLOR_CELESTE, "{FFFF00}[DesingP]: {FFFFFF}No puedes hablar hasta no \"Registrarte\" y \"Ingresar\"");
- return 0;
- }
- // ---------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- public OnPlayerRequestSpawn(playerid)
- {
- if ((!PlayerInfo[playerid][pRegistrado]) || (!PlayerInfo[playerid][pIdentificado]))
- {
- SendClientMessage(playerid, COLOR_CELESTE, "{FFFF00}[DesingP]: {FFFFFF}No puedes spawnear hasta no \"Registrarte\" y \"Ingresar\"");
- return 0;
- }
- // ---------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(killerid == INVALID_PLAYER_ID)
- {
- PlayerInfo[playerid][pMuertes]++;
- }
- else
- {
- PlayerInfo[killerid][pAsesinatos]++;
- PlayerInfo[playerid][pMuertes]++;
- }
- // ---------------------------------
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- public OnPlayerDisconnect(playerid, reason)
- {
- new string[MAX_STRINGS];
- switch (reason)
- {
- case 0: format(string,sizeof(string),"{FFFF00}[DesingP]: {FFFFFF}%s ha salido del servidor (Conexion Fallida)",pNombre(playerid));
- case 1: format(string,sizeof(string),"{FFFF00}[DesingP]: {FFFFFF}%s ha salido del servidor.",pNombre(playerid));
- case 2: format(string,sizeof(string),"{FFFF00}[DesingP]: {FFFFFF}%s ha salido del servidor (Kick/Ban)",pNombre(playerid));
- }
- SendClientMessageToAll(COLOR_BLANCO,string);
- // ---------------------------------
- if (PlayerInfo[playerid][pIdentificado])
- {
- CallLocalFunction("CuandoUnJugadorCierraSesion", "i", playerid);
- }
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new string[MAX_STRINGS];
- if(dialogid == DIALOG_REGISTRO)
- {
- if(!response) return Kick(playerid);
- {
- if(strlen(inputtext) <= 4)
- {
- 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));
- ShowPlayerDialog(playerid, DIALOG_REGISTRO, DIALOG_STYLE_INPUT, "{FFFF00}Registro", string, "Registrar", "Salir");
- PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
- return 1;
- }
- // ---------------------------------
- djCreateFile (pArchivo(playerid));
- djSetInt (pArchivo(playerid), "Contraseña", adler32(inputtext));
- djSetInt (pArchivo(playerid), "Asesinatos", PlayerInfo[playerid][pAsesinatos]);
- djSetInt (pArchivo(playerid), "Muertes", PlayerInfo[playerid][pMuertes]);
- djSetInt (pArchivo(playerid), "Dinero", PlayerInfo[playerid][pDinero]);
- djSetInt (pArchivo(playerid), "Score", PlayerInfo[playerid][pScore]);
- djSet (pArchivo(playerid), "Fecha de Registro", GetDateAndTime());
- djCommit (pArchivo(playerid));
- // ---------------------------------
- PlayerInfo[playerid][pIdentificado] = 1;
- PlayerInfo[playerid][pRegistrado] = 1;
- // ---------------------------------
- PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
- // ---------------------------------
- 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());
- ShowPlayerDialog(playerid, DIALOG_REGISTRO_FINALIZADO, DIALOG_STYLE_MSGBOX, "{FFFF00}Registro terminado", string, "Aceptar", "");
- }
- }
- // ---------------------------------
- if(dialogid == DIALOG_INGRESO)
- {
- if(!response) return Kick(playerid);
- {
- if(strlen(inputtext) == 0)
- {
- format(string, sizeof(string) ,"{FFFFFF}- Por favor {FFFF00}%s.{FFFFFF}\n{FFFFFF}- No introduciste ningun digito, escribelo nuevamente" ,pNombre(playerid));
- ShowPlayerDialog(playerid, DIALOG_INGRESO, DIALOG_STYLE_INPUT, "{FFFF00}Ingreso", string, "Ingresar", "Salir");
- PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
- return 1;
- }
- if (djInt(pArchivo(playerid), "Contraseña") == adler32(inputtext))
- {
- // ---------------------------------
- PlayerInfo[playerid][pIdentificado] = 1;
- PlayerInfo[playerid][pRegistrado] = 1;
- PlayerInfo[playerid][pAsesinatos] = djInt (pArchivo(playerid), "Asesinatos");
- PlayerInfo[playerid][pMuertes] = djInt (pArchivo(playerid), "Muertes");
- GivePlayerMoney(playerid, djInt (pArchivo(playerid), "Dinero"));
- SetPlayerScore(playerid, djInt (pArchivo(playerid), "Score"));
- djSet (pArchivo(playerid), "Ultimo inicio de sesion", GetDateAndTime());
- // ---------------------------------
- PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
- // ---------------------------------
- }
- else
- {
- PlayerInfo[playerid][pPasswordIncorrecta]++;
- format(string, sizeof(string), "{FFFFFF}- Por favor {FFFF00}%s.{FFFFFF}\n{FFFFFF}- Ingresa una contraseña correcta",pNombre(playerid));
- ShowPlayerDialog(playerid, DIALOG_INGRESO, DIALOG_STYLE_INPUT, "{FFFF00}Ingreso", string, "Ingresar", "Salir");
- PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
- // ---------------------------------
- if (PlayerInfo[playerid][pPasswordIncorrecta] == MAX_PASSWORD_INVALIDA)
- {
- format(string,sizeof(string),"{FFFF00}[DesingP]: %s fue expulsado (Max intentos de ingresar(Contraseña invalida))",pNombre(playerid));
- SendClientMessageToAll(COLOR_BLANCO, string);
- SendClientMessage(playerid, COLOR_BLANCO, "** Haz puesto varias contraseñas incorrectas has sido kickeado del servidor por seguridad.");
- Kick(playerid);
- }
- return 1;
- }
- }
- }
- return 1;
- }
- /*----------------------------------------------------------------------------*/
- public CuandoUnJugadorCierraSesion(playerid)
- {
- djSetInt (pArchivo(playerid), "Asesinatos", PlayerInfo[playerid][pAsesinatos]);
- djSetInt (pArchivo(playerid), "Muertes", PlayerInfo[playerid][pMuertes]);
- djSetInt (pArchivo(playerid), "Dinero", GetPlayerMoney(playerid));
- djSetInt (pArchivo(playerid), "Score", GetPlayerScore(playerid));
- djSet (pArchivo(playerid), "Ultimo cierre de sesion", GetDateAndTime());
- djCommit (pArchivo(playerid));
- }
- /*----------------------------------------------------------------------------*/
- CMD:cuenta(playerid, params[])
- {
- new string[MAX_STRINGS];
- 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));
- ShowPlayerDialog(playerid,DIALOG_ESTADISTICAS,DIALOG_STYLE_MSGBOX,"{FFFF00}Cuenta del servidor",string,"Aceptar","");
- return 1;
- }
- /*----------------------------------------------------------------------------*-
- | • Stock's • |
- -*----------------------------------------------------------------------------*/
- stock pNombre(playerid)
- {
- new Nombre[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Nombre, sizeof(Nombre));
- return Nombre;
- }
- /*----------------------------------------------------------------------------*/
- stock pArchivo(playerid)
- {
- new string[MAX_STRINGS];
- GetPlayerName(playerid, string, sizeof (string));
- format(string, sizeof (string), "Cuentas/%s.json", string);
- return string;
- }
- /*----------------------------------------------------------------------------*/
- stock GetDateAndTime()
- {
- new string[MAX_STRINGS],dma[3],hms[3];
- getdate(dma[2], dma[1], dma[0]);
- gettime(hms[0], hms[1], hms[2]);
- format(string,sizeof(string),"%i/%i /%i - %i:%i:%i",dma[0], dma[1], dma[2], hms[0], hms[1], hms[2]);
- return string;
- }
- /*----------------------------------------------------------------------------*/
- stock adler32(buf[])
- {
- new len = strlen(buf), key1 = 1, key2 = 0, n;
- for (n = 0; n < len; n ++)
- {
- key1 = (key1 + buf[n]) % 65521;
- key2 = (key2 + key1) % 65521;
- }
- return (key2 << 16) + key1;
- }
- /*----------------------------------------------------------------------------*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement