//onplayerdisconnect
public OnPlayerDisconnect(playerid, reason)
{
new INI:ACCOUNT = INI_Open(UserPath(playerid));
INI_SetTag(ACCOUNT,"data");
INI_WriteInt(ACCOUNT,"Level",pInfo[playerid][aAdmin]);
INI_WriteInt(ACCOUNT,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(ACCOUNT,"Kills",pInfo[playerid][Kills]);
INI_WriteInt(ACCOUNT,"Deaths",pInfo[playerid][Deaths]);
INI_WriteInt(ACCOUNT, "Banned",pInfo[playerid][Banned]);
INI_WriteInt(ACCOUNT, "Donator",pInfo[playerid][Donator]);
INI_WriteInt(ACCOUNT, "Score", pInfo[playerid][Score]);
INI_WriteInt(ACCOUNT, "Skin", pInfo[playerid][Skin]);
INI_WriteInt(ACCOUNT, "Muted",pInfo[playerid][Muted]);
INI_Close(ACCOUNT);
return 1;
}
//onplayerdialogresponse
//my login dialog
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == pInfo[playerid][Pass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in to your Account!","Ok","");
SetPlayerScore(playerid, pInfo[playerid][Score]);
GivePlayerMoney(playerid, pInfo[playerid][Cash]);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
pInfo[playerid][LoginAttempts]++;
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Account Login error",astring, "Login", "Quit");
if(pInfo[playerid][LoginAttempts] >= MAX_LOGIN_ATTEMPTS)
{
format(astring, sizeof(astring),"%s has been automatically kicked | Reason: 'Incorrect password login attempts [3/3]'", GetName(playerid));
SendToAdmins(orange,astring);
ShowPlayerDialog(playerid,ACCKICK, DIALOG_STYLE_MSGBOX, "Kicked","You have been automatically kicked | Reason: 'Incorrect password login attempts [3/3]. \n Take a screen shot of this message and post on our forums if you think this in a mistake.\nOur forums: ******.com'", "Ok", "");
SetTimerEx("KickPlayer",100,false,"d",playerid);
return 1;
}
format(astring, sizeof(astring),"Account \"%s\"\nEnter your password to login\n{FF0000}*Incorrect password", GetName(playerid));
}
}
return 1;
}
}
return 1;
}
//my register dialog
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
new INI:ACCOUNT = INI_Open(UserPath(playerid));
INI_SetTag(ACCOUNT,"data");
INI_WriteInt(ACCOUNT,"Password",udb_hash(inputtext));
INI_WriteInt(ACCOUNT, "Level", 0);
INI_WriteInt(ACCOUNT, "Banned", 0);
INI_WriteInt(ACCOUNT, "Donator", 0);
INI_WriteInt(ACCOUNT, "Score", SCORE);
INI_WriteInt(ACCOUNT, "Cash", CASH);
INI_WriteInt(ACCOUNT, "Kills", 0);
INI_WriteInt(ACCOUNT, "Deaths", 0);
INI_WriteInt(ACCOUNT, "Skin", 0);
INI_WriteInt(ACCOUNT, "Muted", 0);
INI_Close(ACCOUNT);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Account has been Successfully Created in our Database. Enjoy your stay","Ok","");
}
}
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
You mean it work perfectly, but it only save when someone disconnect?
|
CMD:setlevel(playerid,params[])
{
if(IsPlayerAdmin(playerid) || pInfo[playerid][aAdmin] >= 7)
{
new id,lvl,year,month,day,hour,minute,second;
if(sscanf(params, "ui", id, lvl)) return
SendClientMessage(playerid, 0xFFFF00C8, "Usage: /Setlevel <PlayerID> <Level>") ;
if(lvl < 0) return SendClientMessage(playerid,red,"Invalid level(level must be greater than -1)");
if(IsPlayerConnected(id))
{
if(lvl == pInfo[id][aAdmin])
return SendClientMessage(playerid,red,"Player is already in this level!");
if(lvl > 7)
{
format(astring,sizeof(astring),"Error: Maximum admin level is 7"); return SendClientMessage(playerid,red,astring);
}
CommandToAdmins(playerid,"setlevel");
getdate(year, month, day);
gettime(hour,minute,second);
switch(lvl)
{
case 0: AdminRank ="Trial Administrator";
case 1: AdminRank = "Moderator";
case 2: AdminRank = "Junior Administrator";
case 3: AdminRank = "Senior Administrator";
case 4: AdminRank = "Head Administrator";
case 5: AdminRank = "Master Administrator";
default: AdminRank = "Head Of Staff/Server Owner";
}
format(astring,sizeof(astring),"You have given %s level: %d (%s) , Date: %d/%d/%d at %d:%d:%d",GetName(id), lvl, AdminRank, day, month, year ,hour, minute, second);
SendClientMessage(playerid,blue,astring);
if(lvl > pInfo[id][aAdmin])
{
format(astring,sizeof(astring),"Administrator %s has given you Administrator level: %d (%s) <Promoted on %d/%d/%d at %d:%d:%d>",GetName(playerid), lvl, AdminRank ,day, month, year,hour, minute, second),GameTextForPlayerEx(id,"~B~congratulations!~N~~G~Promoted", 2000, 3);
SendClientMessage(id,yellow,astring);
format(astring,sizeof(astring),"[PROMOTED] %s has changed %s's level from %d to %d (%s)",GetName(playerid),GetName(id),pInfo[id][aAdmin], lvl, AdminRank);
}
else
{
format(astring,sizeof(astring),"Administrator %s has set you level: %d <Demoted on %d/%d/%d at %d:%d:%d>",GetName(playerid), lvl,day, month, year,hour, minute, second),GameTextForPlayerEx(id,"~R~Demoted", 2000, 3);
SendClientMessage(id,red,astring);
format(astring,sizeof(astring),"[DEMOTED] %s has changed %s's level from %d to %d (%s)",GetName(playerid),GetName(id),pInfo[id][aAdmin], lvl, AdminRank);
}
pInfo[id][aAdmin] = lvl;
return 1;
}
else return ShowMessage(playerid, red, 2);
}
else return ShowMessage(playerid, red, 1);
}
I'm always so happy to see when people try and make things by themselves or try to through a tutorial or something, way to go!
![]() Can you show the function in which the user data is loaded into the variables? There might be missing something there. Also, can you verify that inside the .ini file, the value is actually set to something other than 0? So, set your admin level and log out, then open the ini file and check if the value is 0 or something else. That could rule out the possibility of an error in the saving function of the script. |
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",pInfo[playerid][Pass]);
INI_Int("Cash",pInfo[playerid][Cash]);
INI_Int("Admin",pInfo[playerid][aAdmin]);
INI_Int("Kills",pInfo[playerid][Kills]);
INI_Int("Deaths",pInfo[playerid][Deaths]);
INI_Int("Muted", pInfo[playerid][Muted]);
INI_Int("Score", pInfo[playerid][Score]);
INI_Int("Banned", pInfo[playerid][Banned]);
INI_Int("Donator", pInfo[playerid][Donator]);
INI_Int("Skin", pInfo[playerid][Skin]);
INI_String("LastLoggedIP", pInfo[playerid][IP], 16);
INI_Int("TotalSeconds", pInfo[playerid][TotalSecs]);
return 1;
}
INI_Int("Admin",pInfo[playerid][aAdmin]);
INI_WriteInt(ACCOUNT,"Level",pInfo[playerid][aAdmin]);
INI_Int("Level",pInfo[playerid][aAdmin]);
forward LoadUser_data(playerid,name[],value[]); public LoadUser_data(playerid,name[],value[]) { INI_Int("Password",pInfo[playerid][Pass]); INI_Int("Cash",pInfo[playerid][Cash]); INI_Int("Level",pInfo[playerid][aAdmin]); // <- changed that to "Level" just like the saving code INI_Int("Kills",pInfo[playerid][Kills]); INI_Int("Deaths",pInfo[playerid][Deaths]); INI_Int("Muted", pInfo[playerid][Muted]); INI_Int("Score", pInfo[playerid][Score]); INI_Int("Banned", pInfo[playerid][Banned]); INI_Int("Donator", pInfo[playerid][Donator]); INI_Int("Skin", pInfo[playerid][Skin]); INI_String("LastLoggedIP", pInfo[playerid][IP], 16); INI_Int("TotalSeconds", pInfo[playerid][TotalSecs]); return 1; }
Код:
INI_Int("Admin",pInfo[playerid][aAdmin]); You did this: Код:
INI_WriteInt(ACCOUNT,"Level",pInfo[playerid][aAdmin]); Код:
INI_Int("Level",pInfo[playerid][aAdmin]); Код:
forward LoadUser_data(playerid,name[],value[]); public LoadUser_data(playerid,name[],value[]) { INI_Int("Password",pInfo[playerid][Pass]); INI_Int("Cash",pInfo[playerid][Cash]); INI_Int("Level",pInfo[playerid][aAdmin]); // <- changed that to "Level" just like the saving code INI_Int("Kills",pInfo[playerid][Kills]); INI_Int("Deaths",pInfo[playerid][Deaths]); INI_Int("Muted", pInfo[playerid][Muted]); INI_Int("Score", pInfo[playerid][Score]); INI_Int("Banned", pInfo[playerid][Banned]); INI_Int("Donator", pInfo[playerid][Donator]); INI_Int("Skin", pInfo[playerid][Skin]); INI_String("LastLoggedIP", pInfo[playerid][IP], 16); INI_Int("TotalSeconds", pInfo[playerid][TotalSecs]); return 1; } |