public OnPlayerConnect(playerid)
{
// - - Register System - - //
gPlayerLogged[playerid] = 0;
new pName[MAX_PLAYER_NAME];
new file[256];
format(file, sizeof(file), SERVER_DATABASE, pName);
if(!dini_Exists(file))
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Register", "Welcome To Advena Freeroam You Are Not Registered\nPlease Do By Typing Your Password Below","Register","Leave");
}
if(fexist(file))
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Login", "Welcome Back To Advena Freeroam Please\nEnter Your Password Below To Login","Login","Leave");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new pName[MAX_PLAYER_NAME];
new file[256];
GetPlayerName(playerid, pName, sizeof(pName));
format(file, sizeof(file), SERVER_DATABASE, pName);
if(gPlayerLogged[playerid] == 1)
{
dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
dini_IntSet(file, "VIP", PlayerInfo[playerid][pVIP]);
dini_IntSet(file, "Admin", PlayerInfo[playerid][pAdmin]);
}
gPlayerLogged[playerid] = 0;
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
// - - Register System - - //
if(dialogid == 1)
{
new pName[MAX_PLAYER_NAME];
new file[256];
new string[128];
GetPlayerName(playerid, pName, sizeof(pName));
format(file, sizeof(file), SERVER_DATABASE, pName);
if(!response) return Kick(playerid);
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Register", "NOTE: You Didn't Enter Anything\n\nWelcome To Advena Freeroam Please Write A Password\nBelow To Register A New Account","Register","Leave");
dini_Create(file);
dini_IntSet(file, "Password", udb_hash(inputtext));
dini_IntSet(file, "Admin", PlayerInfo[playerid][pAdmin] = 0);
dini_IntSet(file, "Money", PlayerInfo[playerid][pCash] = 50);
dini_IntSet(file, "VIP", PlayerInfo[playerid][pVIP]);
dini_IntSet(file, "Score", PlayerInfo[playerid][pScore] = 0);
format(string, 128, "[SYSTEM] You Have Successfully Registered The Name (%s) With Password (%s)", pName, inputtext);
SendClientMessage(playerid, SERVER_RED, string);
gPlayerLogged[playerid] = 1;
}
else
{
new pName[MAX_PLAYER_NAME];
new file[256];
GetPlayerName(playerid, pName, sizeof(pName));
format(file, sizeof(file), SERVER_DATABASE, pName);
if(!response) return Kick(playerid);
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Login", "NOTE: You Didn't Enter Anything\n\nWelcome Back To Advena Freeroam Please Type Your\nPassword Below To Login","Login","Leave");
new tmp;
tmp = dini_Int(file, "Password");
if(udb_hash(inputtext) !=tmp)
{
SendClientMessage(playerid, SERVER_RED, "Wrong Password Entered Please Try Again");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Login", "NOTE: You Have Entered An Incorrect Password\n\nPlease Retype Your Password Below","Login","Leave");
}
else
{
gPlayerLogged[playerid] = 1;
PlayerInfo[playerid][pAdmin] = dini_Int(file, "Admin");
SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
SendClientMessage(playerid, SERVER_RED, "[SYSTEM] You Have Successfully Logged In");
}
}
return 1;
}
if(!dini_Exists(file))
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Register", "Welcome To Advena Freeroam You Are Not Registered\nPlease Do By Typing Your Password Below","Register","Leave");
}
if(fexist(file))
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Login", "Welcome Back To Advena Freeroam Please\nEnter Your Password Below To Login","Login","Leave");
}
if(!fexist(file))
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Register", "Welcome To Advena Freeroam You Are Not Registered\nPlease Do By Typing Your Password Below","Register","Leave");
}
else if(fexist(file))
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Login", "Welcome Back To Advena Freeroam Please\nEnter Your Password Below To Login","Login","Leave");
}
Change
pawn Код:
pawn Код:
|