02.02.2019, 21:41
Talvez seja o REGISTRO. Da uma olhada nesse sistema que eu fiz aqui, ele salva tudo e carrega tudo ja testei e n achei bugs
>=
>=
PHP код:
// INCLUDES
#include <a_samp>
#include <DOF2>
// DIALOGS
#define DIALOG_REGISTRO 1
#define DIALOG_LOGIN 2
#define DIALOG_SEXO 3
// NEWS
enum PlayerInfo
{
Dinheiro,
Level,
Skin,
Procurado,
Admin,
Float:pX,
Float:pY,
Float:pZ,
Float:pA,
bool:Logado
};
new Player[MAX_PLAYERS][PlayerInfo];
main() {}
public OnPlayerRequestClass(playerid, classid)
{
new File[50];
format(File, sizeof(File), "Contas/%s.ini", Nome(playerid));
if(!DOF2::FileExists(File))
{
ShowPlayerDialog(playerid, DIALOG_REGISTRO, DIALOG_STYLE_INPUT, "REGISTRO", "- Insira sua senha para Registrar-se:", "Registrar", "Sair");
}
else if(DOF2::FileExists(File))
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "LOGIN", "- Insira sua senha para Logar-se:", "Logar", "Sair");
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new File[50];
format(File, sizeof(File), "Contas/%s.ini", Nome(playerid));
if(dialogid == DIALOG_REGISTRO)
{
if(response)
{
if(strlen(inputtext) < 5 || strlen(inputtext) > 20)
{
SendClientMessage(playerid, Vermelho, "| ERRO | Insira uma senha entre 5 e 20 caracters!");
ShowPlayerDialog(playerid, DIALOG_REGISTRO, DIALOG_STYLE_INPUT, "REGISTRO", "- Insira sua senha para Registrar-se:", "Registrar", "Sair");
return 1;
}
DOF2::CreateFile(File);
DOF2::SetString(File, "Senha", inputtext);
DOF2::SetInt(File, "Dinheiro", Player[playerid][Dinheiro] = 5000);
DOF2::SetInt(File, "Procurado", Player[playerid][Procurado] = 0);
DOF2::SetInt(File, "Level", Player[playerid][Level] = 0);
DOF2::SetInt(File, "Skin", Player[playerid][Skin] = 60);
DOF2::SetInt(File, "Admin", Player[playerid][Admin] = 0);
DOF2::SetFloat(File, "X", Player[playerid][pX] = 1958.3783);
DOF2::SetFloat(File, "Y", Player[playerid][pY] = 1343.1572);
DOF2::SetFloat(File, "Z", Player[playerid][pZ] = 15.3746);
DOF2::SetFloat(File, "A", Player[playerid][pA] = 270.0000);
DOF2::SaveFile();
GivePlayerMoney(playerid, Player[playerid][Dinheiro]);
SetPlayerScore(playerid, Player[playerid][Level]);
SetPlayerWantedLevel(playerid, Player[playerid][Procurado]);
SetSpawnInfo(playerid, 0, Player[playerid][Skin], Player[playerid][pX], Player[playerid][pY], Player[playerid][pZ], Player[playerid][pA], 0, 0, 0, 0, 0, 0);
Player[playerid][Logado] = true;
SpawnPlayer(playerid);
}
else
{
Kick(playerid);
return 1;
}
return 1;
}
if(dialogid == DIALOG_LOGIN)
{
if(response)
{
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "LOGIN", "- Insira sua senha para Logar-se:", "Logar", "Sair");
return 1;
}
if(strcmp(inputtext, DOF2::GetString(File, "Senha"), true) == 0)
{
Player[playerid][Dinheiro] = DOF2::GetInt(File, "Dinheiro");
Player[playerid][Procurado] = DOF2::GetInt(File, "Procurado");
Player[playerid][Level] = DOF2::GetInt(File, "Level");
Player[playerid][Skin] = DOF2::GetInt(File, "Skin");
Player[playerid][Admin] = DOF2::GetInt(File, "Admin");
Player[playerid][pX] = DOF2::GetFloat(File, "X");
Player[playerid][pY] = DOF2::GetFloat(File, "Y");
Player[playerid][pZ] = DOF2::GetFloat(File, "Z");
Player[playerid][pA] = DOF2::GetFloat(File, "A");
GivePlayerMoney(playerid, Player[playerid][Dinheiro]);
SetPlayerScore(playerid, Player[playerid][Level]);
SetPlayerWantedLevel(playerid, Player[playerid][Procurado]);
SetSpawnInfo(playerid, 0, Player[playerid][Skin], Player[playerid][pX], Player[playerid][pY], Player[playerid][pZ], Player[playerid][pA], 0, 0, 0, 0, 0, 0);
Player[playerid][Logado] = true;
SpawnPlayer(playerid);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "LOGIN", "- Insira sua senha para Logar-se:", "Logar", "Sair");
return 1;
}
}
else
{
Kick(playerid);
return 1;
}
return 1;
}
return 0;
}