Ta ae todo o cуdigo:
pawn Код:
CMD:register(playerid,params[])
{
if(DOF2_FileExists(ReturnFileUser(playerid))) return SendClientMessage(playerid,yellow,"Essa conta jб estб registrada.");
new string[115];
format(string,sizeof(string),"Nick: %s\nEnter com uma senha para registrar a conta.", PlayerName(playerid));
ShowPlayerDialog(playerid,DIALOG_REGISTRO,DIALOG_STYLE_INPUT,"Assasin'City - Registro",string,"Registrar","Cancelae");
return 1;
}
CMD:login(playerid,params[])
{
if(!DOF2_FileExists(ReturnFileUser(playerid))) return SendClientMessage(playerid,-1,"Sua conta ainda nгo estб registrada, registre-a primeiro, /registrar.");
if(Conectado[playerid] == true) return SendClientMessage(playerid,-1,"Vocк jб estб logado.");
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Assasin'City - Login", "Entre com a senha da conta para logar-se.", "Logar","Cancelar");
return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_REGISTRO)
{
if(!response)
if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTRO,DIALOG_STYLE_INPUT,"Assasins'City - Registro","Entre com uma senha para registrar.","Registrar","Cancelar");
new string[70];
format(string,sizeof(string),"Conta registrada com sucesso! | Sua senha: %s", inputtext);
SendClientMessage(playerid,-1,string);
DOF2_CreateFile(ReturnFileUser(playerid));
DOF2_SetString(ReturnFileUser(playerid),"Password",inputtext);
DOF2_SetString(ReturnFileUser(playerid),"Admin",PlayerInfo[playerid][Admin]);
DOF2_SetString(ReturnFileUser(playerid),"Kills",PlayerInfo[playerid][Kills]);
DOF2_SetString(ReturnFileUser(playerid),"Deaths",PlayerInfo[playerid][Deaths]);
DOF2_SetString(ReturnFileUser(playerid),"Score",PlayerInfo[playerid][Score]);
DOF2_SetString(ReturnFileUser(playerid),"Cash",PlayerInfo[playerid][Cash]);
DOF2_SaveFile();
GivePlayerMoney(playerid,10000);
Conectado[playerid] = true;
SalvarConta(playerid);
return 1;
}
if(dialogid == DIALOG_LOGIN)
{
if(!response)
if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Assasins'City - Login","Entre com uma senha para logar-se","Logar","Cancelar");
if(strcmp(inputtext,DOF2_GetString(ReturnFileUser(playerid),"Password"),true) == 0)
{
CarregarConta(playerid);
Conectado[playerid] = true;
}
else
{
if(SenhaErrada[playerid] == 3)
{
SendClientMessage(playerid,-1,"Vocк serб kickado se errar a senha 3x");
Kick(playerid);
}
else if(SenhaErrada[playerid] < 3)
{
SenhaErrada[playerid] ++;
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Assasins'City - Login","Senha Incorreta, por favor digite a senha certa para essa conta, ou mude seu nick.","Logar","Cancelar");
}
}
return 1;
}
return 1;
}
pawn Код:
stock ReturnFileUser(playerid)
{
new File[156],Name[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,sizeof(Name));
format(File,sizeof(File),FileUsers,Name);
return File;
}
stock PlayerName(playerid)
{
new Name[MAX_PLAYERS];
GetPlayerName(playerid, Name, sizeof(Name));
return Name;
}
stock SalvarConta(playerid)
{
DOF2_SetInt(GetarConta(playerid),"Admin",PlayerInfo[playerid][Admin]);
DOF2_SetInt(GetarConta(playerid),"Kills",PlayerInfo[playerid][Kills]);
DOF2_SetInt(GetarConta(playerid),"Deaths",PlayerInfo[playerid][Deaths]);
DOF2_SetInt(GetarConta(playerid),"Score",PlayerInfo[playerid][Score]);
DOF2_SetInt(GetarConta(playerid),"Cash",PlayerInfo[playerid][Cash]);
DOF2_SaveFile();
return 1;
}
stock CarregarConta(playerid)
{
PlayerInfo[playerid][Admin] = DOF2_GetInt(GetarConta(playerid),"Admin");
PlayerInfo[playerid][Kills] = DOF2_GetInt(GetarConta(playerid),"Kills");
PlayerInfo[playerid][Deaths] = DOF2_GetInt(GetarConta(playerid),"Deaths");
SetPlayerScore(playerid,DOF2_GetInt(GetarConta(playerid),"Score"));
GivePlayerMoney(playerid,DOF2_GetInt(GetarConta(playerid),"Cash"));
return 1;
}
stock GetarConta(id)
{
new snd[MAX_PLAYER_NAME];
GetPlayerName(id,snd,sizeof(snd));
return snd;
}