12.10.2011, 06:45
pawn Код:
#include a_samp
#include DOF2
#if defined MAX_PLAYERS
#undef MAX_PLAYERS
#endif
#define MAX_PLAYERS 45
#define contas "%s.ini"
#define login "Bem vindo ao servidor %s digite sua senha para logar-se."
#define registro "Bem vindo ao servidor %s registre-se."
enum pInfo
{
pGrana,
pLevel,
};
new playerinfo[MAX_PLAYERS][pInfo];
new
arquivo[50],
nome[24],
paramount[90]
;
public OnFilterScriptExit()
{
DOF2_Exit();
return 1;
}
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid,nome,24);
format(arquivo,50,contas,nome);
if(fexist(arquivo))
{
GetPlayerName(playerid,nome,24);
format(paramount,90,login,nome);
ShowPlayerDialog(playerid,9998,DIALOG_STYLE_INPUT,"Servidor",paramount,"entrar","sair");
}
else
{
GetPlayerName(playerid,nome,24);
format(paramount,90,registro,nome);
ShowPlayerDialog(playerid,9999,DIALOG_STYLE_INPUT,"Servidor",paramount,"registrar","sair");
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 9999)
{
if(!response) return Kick(playerid);
if(response)
{
GetPlayerName(playerid,nome,24);
format(arquivo,50,contas,nome);
DOF2_CreateFile(arquivo);
DOF2_SetString(arquivo,"senha",inputtext);
playerinfo[playerid][pLevel] = DOF2_SetInt(arquivo,"level",5);
playerinfo[playerid][pGrana] = DOF2_SetInt(arquivo,"dinheiro",5000);
format(paramount,90,login,nome);
new len = strlen(inputtext);
if(len < 5 || len > 20) return ShowPlayerDialog(playerid,9999,DIALOG_STYLE_INPUT,"Servidor","Senha deve conter no minimo 5 caracteres.","Ok","kick");
return ShowPlayerDialog(playerid,9998,DIALOG_STYLE_INPUT,"Servidor",login,"ok","fechar");
}
}
if(dialogid == 9998)
{
if(!response) return Kick(playerid);
if(response)
{
new senha[20];
GetPlayerName(playerid,nome,24);
format(arquivo,50,contas,nome);
format(senha,20,"%s",strval(inputtext));
if(strcmp(inputtext,DOF2_GetString(arquivo,"senha"),true) == 0)
{
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid,9998,DIALOG_STYLE_INPUT,"Servidor","senha errada, digite a senha correta para logar-se.","ok","sair");
return SendClientMessage(playerid,-1,"senha errada.");
}
GetPlayerName(playerid,nome,24);
format(arquivo,28,contas,nome);
SetPlayerScore(playerid,DOF2_GetInt(arquivo,"level"));
GivePlayerMoney(playerid,DOF2_GetInt(arquivo,"dinheiro"));
}
else
{
ShowPlayerDialog(playerid,9998,DIALOG_STYLE_INPUT,"Servidor","senha errada, insira a senha correta.","ok","sair");
SendClientMessage(playerid,-1,"senha errada.");
}
}
}
return 1;
}