PDA

View Full Version : Problem with Saving system!


Sanady
21/05/2012, 08:07 AM
Hello.When I set my self Admin level 5.And relog.Admin level wont save.I don`t know why.

CODE

public OnPlayerConnect(playerid)
{
gPlayerLogged[playerid] = 0;
new file[256],string[126],name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);


if (!dini_Exists(file))
{
format(string, sizeof(string), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF} to the server, you're "COL_RED"not{FFFFFF} registered\n\nPlease log in by inputting your password.", name, playerid);
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{FFFFFF}Registration", string, "Register", "Leave");
pInfo[playerid][pFailLogins] = 0;
pInfo[playerid][pLevel] = -1;
}
if(fexist(file))
{
format(string, sizeof(string), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF} to the server, you're registered\n\nPlease log in by inputting your password.", name, playerid);
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{FFFFFF}Login", string, "Login", "Leave");
}
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
new file[256],name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);

pInfo[playerid][pFailLogins] = 0;
pInfo[playerid][pLevel] = -1;

if(gPlayerLogged[playerid] == 1)
{
dini_IntSet(file, "Score", pInfo[playerid][pScore]);
dini_IntSet(file, "Money", pInfo[playerid][pMoney]);
dini_IntSet(file, "AdminLevel",pInfo[playerid][pLevel]);
dini_IntSet(file, "Kills",pInfo[playerid][pKills]);
dini_IntSet(file, "Deaths",pInfo[playerid][pDeaths]);
}
gPlayerLogged[playerid] = 0;
{
pInfo[playerid][pFailLogins] = 0;
pInfo[playerid][pLevel] = -1;
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == 1)
{
new file[256], string[228],offstring[70],name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{FFFFFF}Registration", ""COL_RED"[ERROR]{FFFFFF}Please input password!", "Register", "Leave");
dini_Create(file);
dini_IntSet(file, "Password", udb_hash(inputtext));
dini_IntSet(file, "AdminLevel",pInfo[playerid][pLevel] = -1);
dini_IntSet(file, "Money",pInfo[playerid][pMoney] = 500);
dini_IntSet(file, "Score",pInfo[playerid][pScore] = 0);
dini_IntSet(file, "Kills",pInfo[playerid][pKills] = 0);
dini_IntSet(file, "Deaths",pInfo[playerid][pDeaths] = 0);

format(string,sizeof(string),"{FFFFFF}You have been "COL_GREEN"successfully {FFFFFF}registred\n\n\
{FFFFFF}Account:"COL_BLUE"%s\n\
{FFFFFF}Password:"COL_BLUE"%s\n\n\
{FFFFFF}You have been automaticly login!",
name,
inputtext);

format(offstring,sizeof(offstring),"{FFFFFF}Welcome,"COL_BLUE"%s",name);
ShowPlayerDialog(playerid,3,DIALOG_STYLE_MSGBOX,of fstring,string,"Spawn","");

gPlayerLogged[playerid] = 1;
}
if (dialogid == 2)
{
new name[MAX_PLAYER_NAME], file[256],string[227],offstring[70];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{FFFFFF}", ""COL_RED"[ERROR]{FFFFFF}Please input right password!", "Login", "Leave");
new tmp;
tmp = dini_Int(file, "Password");
if(udb_hash(inputtext) != tmp)
{
format(string, sizeof (string), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF} to the server, you're registered\n\nPlease log in by inputting your password.\n"embed_red"Wrong password!", pName[playerid],playerid);
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT,"{FFFFFF}Login", string,"Login","Kick");
pInfo[playerid][pFailLogins]++;
if(pInfo[playerid][pFailLogins] >= MAX_FAIL_LOGINS)
{
SendClientMessage(playerid, red, "[ERROR]"embed_grey"Failed to login!");
Kick(playerid);
return 1;
}
}
else
{
gPlayerLogged[playerid] = 1;
pInfo[playerid][pLevel] = dini_Int(file, "AdminLevel");
SetPlayerScore(playerid, pInfo[playerid][pScore]);
GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
pInfo[playerid][pKills] = dini_Int(file, "Kills");
pInfo[playerid][pDeaths] = dini_Int(file, "Deaths");
format(string,sizeof(string),"{FFFFFF}Your stats are:\n\n\
{FFFFFF}Account:"COL_BLUE"%s\n\
{FFFFFF}Admin Level:"COL_BLUE"%s\n\
{FFFFFF}Kills:"COL_RED"%d\n\
{FFFFFF}Deaths:"COL_RED"%d",
name,
LevelName(playerid),
pInfo[playerid][pKills],
pInfo[playerid][pDeaths]);
format(offstring,sizeof(offstring),"{FFFFFF}Welcome back,"COL_BLUE"%s",name);
ShowPlayerDialog(playerid,3, DIALOG_STYLE_MSGBOX,offstring,string,"Spawn","");
}
}
return 1;
}

Please help.

[FMJ]PowerSurge
21/05/2012, 02:45 PM
Does everything else load?

Sanady
21/05/2012, 04:08 PM
PowerSurge;1876640']Does everything else load?

FIXED