#include <a_samp>
#include <YSI\y_ini>
#define DREGISTER 1
#define DLOGIN 2
#define PATH "/Cuentas/%s.ini"
enum jInfo
{
Contra[64],
Dinero,
Administrador,
Float:PosX,
Float:PosY,
Float:PosZ,
}
new PlayersData[MAX_PLAYERS[jInfo];
forward LoadAccount_data(playerid, name[], value[]);
public LoadAccount_data(playerid, name[], value])
{
INI_Int("Contraseсa", PlayersData[playerid][Contra]);
INI_Int("Dinero", PlayersData[playerid][Dinero]);
INI_Int("Administrador", PlayersData[playerid][Administrador]);
INI_Float("Pos_X", PlayersData[playerid][PosX]);
INI_Float("Pos_Y", PlayersData[playerid][PosY]);
INI_Float("Pos_Z", PlayersData[playerid][PosZ]);
}
stock UserPath(playerid)
{
new string[128],PlayerNameFix[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerNameFix,sizeof(PlayerNameFix))
format(string,sizeof(string),PATH,PlayerNameFix);
return string;
}
if(fexist(playerid))
{
INI_ParseFile(UserPath(playerid)), "LoadAccount_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DLOGIN, DIALOG_STYLE_INPUT, "Panel de logueo", "Estб cuenta se encuentra registrada en nuestra base de datos, por favor ingrese una contraseсa para ingresar", "Entrar", "Salir");
}
else //Йsto verб si el jugador no estб registrado, si el jugador no estб registrada le enviarб el dialogo de registro
{
ShowPlayerDialog(playerid, DREGISTER, DIALOG_STYLE_INPUT,"Panel de registro", "Estб cuenta no se encuentra registrada en nuestra base de datos, por favor ingrese una nueva contraseсa para registrarse", "Entrar", "Salir");
}
if(dialogid = DREGISTER)
{
if (!response) return Kick(playerid); //El 'Kick' es si le da en salir, lo expulse del servidor automaticamente
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DREGISTER, DIALOG_STYLE_INPUT, "Error en el registro", "Hubo un error en el registro, por favor ingrese su contraseсa de nuevo", "Registrar", "Salir");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteString(File,"Contrasena",inputtext);
INI_WriteInt(File,"Dinero",8000);
INI_WriteInt(File,"Admin",0);
INI_WriteFloat(File,"Pos_X",1958.33);
INI_WriteFloat(File,"Pos_Y",1343.12);
INI_WriteFloat(File,"Pos_Z",15.36);
INI_Close(File);
PlayersData[playerid][Dinero]=8000;
PlayersData[playerid][Administrador]=0;
PlayersData[playerid][PosX]=1958.33;
PlayersData[playerid][PosY]=1343.12;
PlayersData[playerid][PosZ]=15.36;
SetPlayerSkin(playerid, 26);
SpawnPlayer(playerid);
}
}
if(dialogid== DLOGIN)
{
if (!response) return Kick(playerid);
if(response)
{
if(strcmp(inputtext, PlayersData[playerid][Contra], true) == 0)
{
INI_ParserFile(UserPath(playerid), "LoadAccount_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayersData[playerid][Dinero]);
SpawnPlayer(playerid);
}
else
{
ShowPlayerDialog(playerid, DLOGIN, DIALOG_STYLE_INPUT, "Erro en el ingreso", "Hubo un error en el ingreso por favor ingrese su contraseсa para entrar", "Entrar", "Salir");
}
return 1;
}
}
stock SaveAccount(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteString(File, "Contraseсa", PlayersData[playerid][Contra]);
INI_WriteInt(File,"Dinero", PlayersData[playerid][Dinero]);
INI_WriteInt(File,"Administrador", PlayersData[playerid][Administrador]);
GetPlayerPos(playerid, PlayersData[playerid][PosX], PlayersData[playerid][PosY], PlayersData[playerid][PosZ]);
INI_WriteFloat(File,"Pos_X",PlayersData[playerid][PosX]);
INI_WriteFloat(File,"Pos_Y",PlayersData[playerid][PosY]);
INI_WriteFloat(File,"Pos_Z",PlayersData[playerid][PosZ]);
INI_Close(File);
return 1;
}
SaveAccount(playerid);
Es repetido eso sн, pero no te preocupes que lo irй actualizando, igual muchas gracias!
|
#define PATH "/Cuentas/%.ini"
#define PATH "/Cuentas/%s.ini"