16.06.2012, 02:26
(
Last edited by Dubya; 16/06/2012 at 08:58 PM.
)
On my registration system, whenever the Player logs out, the stats won't save. Like, If I were to make someone an Admin, and they logged out, it wouldn't save.
Registration:
OnPlayerDisconnect:
It won't save the stats.
Registration:
pawn Code:
if(dialogid == 9999)
{
if(response)
{
if(strlen(inputtext))
{
new file[100], name[MAX_PLAYER_NAME], ip[16], string[128];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerIp(playerid, ip, sizeof(ip));
format(file, sizeof(file), PlayerFile, name);
dini_Create(file);
dini_Set(file, "Name", name);
dini_Set(file, "Ip", ip);
dini_IntSet(file, "Registered", 1);
dini_IntSet(file, "Password", num_hash(inputtext));
dini_IntSet(file, "AdminLevel", 0);
dini_IntSet(file, "Money", 50);
dini_IntSet(file, "Deaths", 0);
dini_IntSet(file, "Kills", 0);
format(string, sizeof(string), "System: You succesfully registered the player %s.", name);
SendClientMessage(playerid, COLOR_WHITE, string);
strcat(PlayerInfo[playerid][pName], dini_Get(file, "Name"));
strcat(PlayerInfo[playerid][pIP], dini_Get(file, "Ip"));
PlayerInfo[playerid][pPass] = dini_Int(file, "Password");
PlayerInfo[playerid][pAdmin] = dini_Int(file, "AdminLevel");
GivePlayerMoney(playerid, dini_Int(file, "Money"));
PlayerInfo[playerid][pDeaths] = dini_Int(file, "Deaths");
PlayerInfo[playerid][pKills] = dini_Int(file, "Kills");
PlayerInfo[playerid][pBanned] = dini_Int(file, "Banned");
PlayerLogged[playerid] = 1;
SendClientMessage(playerid, COLOR_ORANGE,"System: Welcome to West Coast DM.");
SendClientMessage(playerid, COLOR_ORANGE,"System: If you need help, use /Help.");
SendClientMessage(playerid, COLOR_ORANGE,"System: Current Version: "SERVER_GM_TEXT"");
}
else if(!strlen(inputtext))
{
SendClientMessage(playerid, COLOR_RED, "System: You must fill in a password!");
ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_INPUT, "Register", "Please fill in your username as a password.", "Register", "Exit");
}
}
else if(!response)
{
SendClientMessage(playerid, COLOR_RED, "System: You need to register in order to play!");
Kick(playerid);
}
}
pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
new file[100];
new string[64];
format(file, sizeof(file), PlayerFile, PlayerInfo[playerid][pName]);
dini_Set(file, "Name", PlayerInfo[playerid][pName]);
dini_Set(file, "Ip", PlayerInfo[playerid][pIP]);
dini_IntSet(file, "Registered", PlayerInfo[playerid][pReg]);
dini_IntSet(file, "Password", PlayerInfo[playerid][pPass]);
dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][pAdmin]);
dini_IntSet(file, "Money", GetPlayerMoney(playerid));
dini_IntSet(file, "Deaths", PlayerInfo[playerid][pDeaths]);
dini_IntSet(file, "Kills", PlayerInfo[playerid][pKills]);
dini_IntSet(file, "Banned", PlayerInfo[playerid][pBanned]);
PlayerLogged[playerid] = 0;
switch(reason)
{
case 0: format(string,sizeof string,"%s left the server! (Lost Connection!)",PlayerName(playerid));
case 1: format(string,sizeof string,"%s left the server! (Disconnected!)",PlayerName(playerid));
case 2: format(string,sizeof string,"%s left the server! (Kicked/Banned!)",PlayerName(playerid));
}
SendClientMessageToAll(COLOR_ORANGE,string);
return 1;
}