13.05.2013, 01:22
PHP код:
#include <a_samp>
#include <dini>
#define DIALOG_REGISTRO 1
#define DIALOG_LOGIN 2
#define CONTAS "Contas/%s.ini"
#define TXT_RLOGIN "{FFFFFF}Nick: %s Registrado\n\n Digite Sua Senha Para Logar"
#define TXT_LOGIN "{FFFFFF}Olб Vocк Esta Registrado\nStatus Da Conta\nNick: %s Registrado\n\n Digite Sua Senha Para Logar"
#define TXT_NREGISTER "{FFFFFF}Olб, Vocк Nгo Esta Registrado\nStatus Da Conta\nNick: %s \nDigite Uma Senha Para Continuar"
#define TXT_RL "Pronto vocк esta registrado \nAgora digite Sua Senha Para Logar-Se"
new TotalMatou[MAX_PLAYERS];
new TotalMorreu[MAX_PLAYERS];
new TotalLogou[MAX_PLAYERS];
forward SalvarLevel(playerid);
forward CarregarLevel(playerid);
public OnFilterScriptInit()
{
print("\n\n__________________________________________________________________");
print(" Sistema de registro MTO loaded!");
print(" By : mau_tito");
print(" ---------------------------");
return 1;
}
public OnFilterScriptExit()
{
print("\n\n__________________________________________________________________");
print(" Sistema de registro MTO loaded!");
print(" By : mau_tito");
print(" ---------------------------");
return 1;
}
SalvarPlayer(playerid)
{
new Nome[MAX_PLAYER_NAME];
GetPlayerName(playerid, Nome, sizeof(Nome));
new String[50];
format(String, sizeof(String), CONTAS, Nome);
dini_IntSet(String,"Dinheiro", GetPlayerMoney(playerid));
dini_IntSet(String,"Total Matou", TotalMatou[playerid]);
dini_IntSet(String,"Total Morreu", TotalMorreu[playerid]);
dini_IntSet(String,"Total Logou", TotalLogou[playerid]);
return 1;
}
CarregarPlayer(playerid)
{
new Nome[MAX_PLAYER_NAME];
GetPlayerName(playerid, Nome, sizeof(Nome));
new String[50];
format(String, sizeof(String), CONTAS, Nome);
GivePlayerMoney(playerid, dini_Int(String,"Dinheiro"));
TotalMatou[playerid] = dini_Int(String, "Total Matou");
TotalMorreu[playerid] = dini_Int(String, "Total Morreu");
TotalLogou[playerid] = dini_Int(String, "Total Logou");
return 1;
}
public OnGameModeExit()
{
for(new i=0; i<MAX_PLAYERS; i++)
SalvarPlayer(i);
return 1;
}
public OnPlayerConnect(playerid)
{
new Nome[MAX_PLAYER_NAME];
GetPlayerName(playerid, Nome, sizeof(Nome));
new String[100];
format(String, sizeof(String), CONTAS, Nome);
if(!dini_Exists(String))
{
format(String, sizeof(String), TXT_NREGISTER, Nome);
ShowPlayerDialog(playerid, DIALOG_REGISTRO, 3, "Registro", String, "Registrar", "Cancelar");
}
else
{
format(String, sizeof(String),TXT_LOGIN, Nome);
ShowPlayerDialog(playerid, DIALOG_LOGIN, 3, "Registro Com Sucesso", String, "Logar", "Cancelar");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
SalvarPlayer(playerid);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(IsPlayerConnected(killerid))
{
TotalMatou[killerid]++;
}
TotalMorreu[playerid]++;
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_REGISTRO)
{
if(response)
{
if(!strlen(inputtext))
{
new Nome[MAX_PLAYER_NAME];
GetPlayerName(playerid, Nome, sizeof(Nome));
new String[1000];
format(String, sizeof(String), TXT_NREGISTER, Nome);
ShowPlayerDialog(playerid, DIALOG_REGISTRO, 3, "Registro", String, "Registrar", "Cancelar");
SendClientMessage(playerid,0x1E90FFAA,"Senha incorreta !!");
return 1;
}
new Nome[MAX_PLAYER_NAME];
GetPlayerName(playerid, Nome, sizeof(Nome));
new String[100];
format(String, sizeof(String), CONTAS, Nome);
dini_Create(String);
dini_Set(String,"Senha",inputtext);
dini_IntSet(String,"Dinheiro",0);
dini_IntSet(String,"Vida",50);
dini_IntSet(String,"TotalMatou",0);
dini_IntSet(String,"Total Morreu",0);
dini_IntSet(String,"Total Logou",0);
ShowPlayerDialog(playerid, DIALOG_LOGIN, 3, "Login", TXT_RL, "Logar", "Cancelar");
return 1;
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "Vocк foi kickado||Motivo: Nгo quer se registrar");
Kick(playerid);
return 1;
}
}
if(dialogid == DIALOG_LOGIN)
{
if(response)
{
if(!strlen(inputtext))
{
new Nome[MAX_PLAYER_NAME];
GetPlayerName(playerid, Nome, sizeof(Nome));
new String[1000];
format(String, sizeof(String),TXT_LOGIN, Nome);
ShowPlayerDialog(playerid, DIALOG_LOGIN, 3, "Registro", String, "Logar", "Cancelar");
SendClientMessage(playerid,0x1E90FFAA,"Senha Incorreta !");
return 1;
}
new Nome[MAX_PLAYER_NAME];
GetPlayerName(playerid, Nome, sizeof(Nome));
new String[100];
format(String, sizeof(String), CONTAS, Nome);
if(!strcmp(inputtext,dini_Get(String,"Senha"),false))
{
CarregarPlayer(playerid);
TotalLogou[playerid]++;
SpawnPlayer(playerid);
return 1;
}
else
{
SendClientMessage(playerid,0x00FF00AA,"Senha incorreta digite-a novamente");
format(String, sizeof(String), TXT_RLOGIN, Nome);
ShowPlayerDialog(playerid, DIALOG_LOGIN, 3, "Registro", String, "Logar", "Cancelar");
}
return 1;
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "Vocк foi kickado||Motivo: Nгo quer logar");
Kick(playerid);
return 1;
}
}
return 0;
}