29.09.2012, 20:49
Alguem Tem Um Sistema de Registro Que Salva
Kills Deaths
Admin
Dinheiro
Kills Deaths
Admin
Dinheiro
#include <a_samp>
#include <dof2>
const DINHEIRO_INICIAL = 5000;
enum Player
{
Admin,
Kills,
Deaths
}
new VarPlayer[MAX_PLAYERS][Player];
public OnPlayerConnect(playerid)
{
static string[64];
GetPlayerName(playerid, string, 24);
format(string, sizeof(string), "Contas/%s.ini", string);
if(!fexist(string))
ShowPlayerDialog(playerid, REGISTRO, DIALOG_STYLE_PASSWORD, "Registro", "Digite uma senha para se registrar", "Registrar", "Sair");
else
ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Digite sua senha", "Login", "Sair");
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
static string[64];
GetPlayerName(playerid, string, 24);
format(string, sizeof(string), "Contas/%s.ini", string);
if(fexist(string))
{
DOF2_SetInt(string, "Admin", VarPlayer[playerid][Admin]);
DOF2_SetInt(string, "Kills", VarPlayer[playerid][Kills]);
DOF2_SetInt(string, "Deaths", VarPlayer[playerid][Deaths]);
DOF2_SaveFile();
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
VarPlayer[playerid][Deaths]++;
if(killerid != 0xFFFF)
{
VarPlayer[killerid][Kills]++;
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == REGISTRO)
{
if(response)
{
static string[64];
GetPlayerName(playerid, string, 24);
format(string, sizeof(string), "Contas/%s.ini", string);
DOF2_CreateFile(string);
DOF2_SetString(string, "Senha", inputtext);
DOF2_SetInt(string, "Admin", 0);
DOF2_SetInt(string, "Kills", 0);
DOF2_SetInt(string, "Deaths", 0);
DOF2_SetInt(string, "Dinheiro", DINHEIRO_INICIAL);
DOF2_SaveFile();
}
else
{
Kick(playerid);
}
}
else if(dialogid == LOGIN)
{
if(response)
{
static string[64];
GetPlayerName(playerid, string, 24);
format(string, sizeof(string), "Contas/%s.ini", string);
if(!strcmp(inputtext, DOF2_GetString(string, "Senha"))
{
VarPlayer[playerid][Admin] = DOF2_GetInt(string, "Admin");
VarPlayer[playerid][Kills] = DOF2_GetInt(string, "Kills");
VarPlayer[playerid][Deaths] = DOF2_GetInt(string, "Deaths");
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, DOF2_GetInt(string, "Dinheiro"));
}
else
{
Kick(playerid);
}
}
}
return 1;
}