27.04.2011, 16:54
Hey Guys, I recently made a Admin script, but there is a probleam with the registerion.
When a player registers it saves his file into scriptfiles > Players, but when he rejoins, it tells him to register again, and resets all his stats, Here is my registarion command:
And I have this definded:
When a player registers it saves his file into scriptfiles > Players, but when he rejoins, it tells him to register again, and resets all his stats, Here is my registarion command:
pawn Код:
public OnPlayerConnect(playerid)
{
gPlayerLogged[playerid] = 0;
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), MafiaAdmin, name);
dini_IntSet(file, "Warns",PlayerInfo[playerid][pWarns] = 1);
if (!dini_Exists(file))
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "You Are Not Registerd", "Welcome, you are not registered, please, input your registration password below", "Register", "Leave");
}
if(fexist(file))
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You Are Registerd", "Your account is registered! Now type your password below.", "Login", "Leave");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), MafiaAdmin, name);
if(gPlayerLogged[playerid] == 1)
{
PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel]);
dini_IntSet(file, "Warns",1);
dini_IntSet(file, "Banned",PlayerInfo[playerid][pBanned]);
dini_IntSet(file, "Muted",PlayerInfo[playerid][pMuted]);
dini_IntSet(file, "Jailed",PlayerInfo[playerid][pJailed]);
}
gPlayerLogged[playerid] = 0;
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == 1)
{
new name[MAX_PLAYER_NAME], file[256], string[128];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), MafiaAdmin, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "You are not registered.", "Welcome, your not registered, please, input your registration password below", "Register", "Leave");
dini_Create(file);
dini_IntSet(file, "Password", udb_hash(inputtext));
dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 5000);
dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
dini_IntSet(file, "Warns",PlayerInfo[playerid][pWarns] = 1);
dini_IntSet(file, "Banned",PlayerInfo[playerid][pBanned] = 0);
dini_IntSet(file, "Muted",PlayerInfo[playerid][pMuted] = 0);
dini_IntSet(file, "Jailed",PlayerInfo[playerid][pJailed] = 0);
format(string, 128, "You have succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext);
SendClientMessage(playerid, COLOR_YELLOW, string);
gPlayerLogged[playerid] = 1;
}
if (dialogid == 2)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), MafiaAdmin, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Please input your password below.", "Login", "Leave");
new tmp;
tmp = dini_Int(file, "Password");
if(udb_hash(inputtext) != tmp) {
SendClientMessage(playerid, COLOR_RED, "Incorrect password. Please try again.");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered.", "Please input your password below.", "Login", "Leave");
}
else
{
gPlayerLogged[playerid] = 1;
PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
SendClientMessage(playerid,COLOR_RED, "You have successfully logged in!");
}
}
return 1;
}
pawn Код:
#define MafiaAdmin "Players/%s.ini"