Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #include <sscanf>
- #include <YSI\y_ini>
- #define DIALOGO_REGISTRO (1)
- #define DIALOGO_INGRESO (2)
- #define DIALOGO_NORMAL (3)
- main( ) { }
- enum pInfo
- {
- pKey[34], //contraseña
- pAdminZC, //lvl admin
- pCash, //dinero
- pKills, //asesinatos
- pDeaths, //muertes
- pJailCant, // Cantidad Jails.
- pMats, // Materiales.
- pCrack, // Crack.
- pChar, //skin
- pMarihuana,
- Float:pVida, //vida
- Float:pChaleco, //armadura
- pInt, //interior
- Float:pPos_x,//posicion X
- Float:pPos_y,//posicion Y
- Float:pPos_z,//posicion Z
- Float:pPos_r,//rotacion
- pVW, //virtualword
- pVIP, //vip
- pWeapons[13],//armas
- pRepuestos,
- pPiezas,
- pAuto,
- pMedicamentos,
- pSF,
- pRegistrado
- };
- new Info[MAX_PLAYERS+1][pInfo];
- #define rutaUsuarios "/Usuarios/%s.ini"
- forward LoadUser_data(playerid,name[],value[]);
- public LoadUser_data(playerid,name[],value[])
- {
- INI_Int("RopaPuesta",Info[playerid][pChar]);
- INI_Int("Contraseña",Info[playerid][pKey]);
- INI_Int("Dinero",Info[playerid][pCash]);
- INI_Int("Asesinatos",Info[playerid][pKills]);
- INI_Int("Muertes",Info[playerid][pDeaths]);
- INI_Int("Admin",Info[playerid][pAdminZC]);
- INI_Int("Vip",Info[playerid][pVIP]);
- INI_Int("Registrado",Info[playerid][pRegistrado]);
- INI_Int("JailCantidad",Info[playerid][pJailCant]);
- INI_Int("Materiales",Info[playerid][pMats]);
- INI_Int("Crack",Info[playerid][pCrack]);
- INI_Int("Marihuana",Info[playerid][pMarihuana]);
- INI_Float("Vida",Info[playerid][pVida]);
- INI_Float("Chaleco",Info[playerid][pChaleco]);
- INI_Int("Interior",Info[playerid][pInt]);
- INI_Float("PosicionX",Info[playerid][pPos_x]);
- INI_Float("PosicionY",Info[playerid][pPos_y]);
- INI_Float("PosicionZ",Info[playerid][pPos_z]);
- INI_Float("Rotacion",Info[playerid][pPos_r]);
- INI_Int("VirtualWorld",Info[playerid][pVW]);
- INI_Int("Armas",Info[playerid][pWeapons]);
- INI_Int("Repuestos",Info[playerid][pRepuestos]);
- INI_Int("Piezas",Info[playerid][pPiezas]);
- INI_Int("Autos",Info[playerid][pAuto]);
- INI_Int("Medicamentos",Info[playerid][pMedicamentos]);
- INI_Int("SFCoin",Info[playerid][pSF]);
- return 1;
- }
- //Kickear al Usuario.
- forward KickearJugador(playerid);
- public KickearJugador(playerid)
- {
- Kick(playerid);
- return 1;
- }
- //Reconocer el nombre del Usuario.
- stock Nombre(playerid){
- new uNombre[32];
- GetPlayerName(playerid,uNombre,100);
- return uNombre;}
- //Checar si existe la cuenta del Usuario.
- stock ChecarCuenta(playerid){
- new cuenta[146];
- format(cuenta,sizeof(cuenta),rutaUsuarios,Nombre(playerid));
- return cuenta;}
- //Guardar cuenta del Usuario.
- stock GuardarCuenta(playerid){
- new INI:File = INI_Open(ChecarCuenta(playerid));
- INI_SetTag(File,"data");
- INI_WriteInt(File,"RopaPuesta",Info[playerid][pChar]);
- INI_WriteString(File,"Contraseña",Info[playerid][pKey]);
- INI_WriteInt(File,"Dinero",Info[playerid][pCash]);
- INI_WriteInt(File,"Asesinatos",Info[playerid][pKills]);
- INI_WriteInt(File,"Muertes",Info[playerid][pDeaths]);
- INI_WriteInt(File,"Admin",Info[playerid][pAdminZC]);
- INI_WriteInt(File,"Vip",Info[playerid][pVIP]);
- INI_WriteInt(File,"Registrado",Info[playerid][pRegistrado]);
- INI_WriteInt(File,"JailCantidad",Info[playerid][pJailCant]);
- INI_WriteInt(File,"Materiales",Info[playerid][pMats]);
- INI_WriteInt(File,"Crack",Info[playerid][pCrack]);
- INI_WriteInt(File,"Marihuana",Info[playerid][pMarihuana]);
- INI_WriteFloat(File,"Vida",Info[playerid][pVida]);
- INI_WriteFloat(File,"Chaleco",Info[playerid][pChaleco]);
- INI_WriteInt(File,"Interior",Info[playerid][pInt]);
- INI_WriteFloat(File,"PosicionX",Info[playerid][pPos_x]);
- INI_WriteFloat(File,"PosicionY",Info[playerid][pPos_y]);
- INI_WriteFloat(File,"PosicionZ",Info[playerid][pPos_z]);
- INI_WriteFloat(File,"Rotacion",Info[playerid][pPos_r]);
- INI_WriteInt(File,"VirtualWorld",Info[playerid][pVW]);
- INI_WriteInt(File,"Armas",Info[playerid][pWeapons]);
- INI_WriteInt(File,"Repuestos",Info[playerid][pRepuestos]);
- INI_WriteInt(File,"Piezas",Info[playerid][pPiezas]);
- INI_WriteInt(File,"Autos",Info[playerid][pAuto]);
- INI_WriteInt(File,"Medicamentos",Info[playerid][pMedicamentos]);
- INI_WriteInt(File,"SFCoin",Info[playerid][pSF]);
- INI_Close(File);}
- //Reiniciar datos del Usuario (prevenir bugs)
- stock ReiniciarDatos(playerid){
- Info[playerid][pCash] = 0;
- Info[playerid][pKills] = 0;
- Info[playerid][pDeaths] = 0;
- Info[playerid][pAdminZC] = 0;
- Info[playerid][pVIP] = 0;
- Info[playerid][pMedicamentos] = 0;
- Info[playerid][pSF] = 0;
- Info[playerid][pAuto] = 0;
- Info[playerid][pWeapons] = 0;
- Info[playerid][pRepuestos] = 0;
- Info[playerid][pPiezas] = 0;
- Info[playerid][pChaleco] = 0;
- Info[playerid][pVida] = 0;
- Info[playerid][pMarihuana] = 0;
- Info[playerid][pCrack] = 0;
- Info[playerid][pMats] = 0;
- Info[playerid][pJailCant] = 0;
- Info[playerid][pChar] = 0;
- Info[playerid][pRegistrado] = 0;
- Info[playerid][pRegistrado] = 0;
- Info[playerid][pRegistrado] = 0;}
- //Guardar cuentas en caso de que el servidor sufra un apagon (evitar perdida de datos)
- public OnGameModeExit(){
- for(new i=0;i<MAX_PLAYERS;i++){
- if(IsPlayerConnected(i) && fexist(ChecarCuenta(i))){
- GuardarCuenta(i);
- SendClientMessage(-1,-1,"Las cuentas fueron guardadas correctamente.");
- printf("Cuentas guardadas correctamente.");}}
- return 1;}
- //Checaremos si la cuenta del Usuario existe en la ruta de Cuentas.
- public OnPlayerConnect(playerid){
- ReiniciarDatos(playerid);
- if(fexist(ChecarCuenta(playerid))){
- INI_ParseFile(ChecarCuenta(playerid),"LoadUser_%s",.bExtra = true, .extra = playerid);
- ShowPlayerDialog(playerid,DIALOGO_INGRESO,DIALOG_STYLE_PASSWORD,"{FFFFFF}Inicio de sesion","{FFFFFF}Escribe en el siguiente campo tu contraseña para poder iniciar sesion.","Aceptar","");
- }else{
- ShowPlayerDialog(playerid,DIALOGO_REGISTRO,DIALOG_STYLE_INPUT,"{FFFFFF}Registro de cuenta","{FFFFFF}Escriba la contraseña que desea para registrar su cuenta.","Aceptar","");}
- return 1;}
- public OnPlayerSpawn(playerid)
- {
- Info[playerid][pChar] = GetPlayerSkin(playerid);
- //Cargado
- SetPlayerPos(playerid,Info[playerid][pPos_x],Info[playerid][pPos_y],Info[playerid][pPos_z]);
- SetPlayerFacingAngle(playerid, Info[playerid][pPos_r]);
- SetPlayerSkin(playerid, Info[playerid][pChar]);
- SetPlayerHealth(playerid, Info[playerid][pVida]);
- SetPlayerArmour(playerid, Info[playerid][pChaleco]);
- return 1;
- }
- public OnPlayerDisconnect(playerid){
- if(fexist(ChecarCuenta(playerid))){
- GuardarCuenta(playerid);
- SendClientMessage(playerid,-1,"Sus datos fueron guardados.");
- printf("La cuenta \"%s\" fue guardada correctamente.",Nombre(playerid));}
- return 1;}
- public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[]){
- if(dialogid == DIALOGO_REGISTRO){
- if(!response)return SetTimerEx("KickearJugador",1000,false,"i",playerid) && ShowPlayerDialog(playerid,DIALOGO_NORMAL,DIALOG_STYLE_MSGBOX,"{FFFFFF}Expulsado","{FFFFFF}Fuistes expulsado por evadir el Registro.","Aceptar","");
- if(response){
- if(!strlen(inputtext))return ShowPlayerDialog(playerid,DIALOGO_REGISTRO,DIALOG_STYLE_INPUT,"{FFFFFF}Registro de cuenta","{FFFFFF}Escriba la contraseña que desea para registrar su cuenta.","Aceptar","");
- new pw[34];
- format(pw,sizeof(pw),"%s",inputtext);
- Info[playerid][pKey] = pw;
- new INI:File = INI_Open(ChecarCuenta(playerid));
- INI_SetTag(File,"data");
- INI_WriteString(File,"Contraseña",inputtext);
- INI_Close(File);
- Info[playerid][pAdminZC] = 0;//Poner su administracion en 0.
- Info[playerid][pVIP] = 0;//Poner su VIP en 0.
- Info[playerid][pCash] = 2000;//Comensara con 2,000 dolares.
- Info[playerid][pRegistrado] = 1;//Reconocera que el Jugador esta registrado.
- Info[playerid][pPos_x] = 1521.3809;
- Info[playerid][pPos_y] = -1712.8494;
- Info[playerid][pPos_z] = 18.0014;
- Info[playerid][pVida] = 100;
- Info[playerid][pChaleco] = 100;
- SendClientMessage(playerid,-1,"ahora estas registrado en el servidor.");
- }}
- if(dialogid == DIALOGO_INGRESO){
- if(!response)return SetTimerEx("KickearJugador",1000,false,"i",playerid) && ShowPlayerDialog(playerid,DIALOGO_NORMAL,DIALOG_STYLE_MSGBOX,"{FFFFFF}Expulsado","{FFFFFF}Fuistes expulsado por intentar evadir contraseña.","Aceptar","");
- if(response){
- if(strcmp(inputtext,Info[playerid][pKey], true) == 0){
- INI_ParseFile(ChecarCuenta(playerid),"LoadUser_%s",.bExtra = true, .extra = playerid);
- SendClientMessage(playerid,-1,"Has ingresado a tu cuenta correctamente.");
- }else return SetTimerEx("KickearJugador",1000,false,"i",playerid) && ShowPlayerDialog(playerid,DIALOGO_NORMAL,DIALOG_STYLE_MSGBOX,"{FFFFFF}Expulsado","{FFFFFF}Fuistes expulsado por ingresar una contraseña incorrecta.","Aceptar","");
- }}
- return 1;}
- //Dar el Dinero & Score del Usuario.
- public OnPlayerUpdate(playerid){
- //Su dinero
- if(GetPlayerMoney(playerid) != Info[playerid][pCash]){
- ResetPlayerMoney(playerid);
- //Su score
- GivePlayerMoney(playerid,Info[playerid][pCash]);}
- if(GetPlayerScore(playerid) != Info[playerid][pKills]){
- SetPlayerScore(playerid,Info[playerid][pKills]);}
- return 1;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement