Load AdminLevel, OnPlayerSpawn, How?
#1

I want to load the player's admin level, here's some of the codes
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
forward ResetVariables(playerid);

new AdminLevel[MAX_PLAYERS];
//==================================
#define PATH "/Administration/Users/%s.ini"
//==============================================================================
enum pInfo
{
    pPass,
    pCash,
    pScore,
    pAdminLevel,
    pKills,
    pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];
//==============================================================================
public ResetVariables(playerid)
{
    gTeam[playerid] =0;
    AdminLevel[playerid] =0;
}
//==============================================================================
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Score",PlayerInfo[playerid][pScore]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin Level",PlayerInfo[playerid][pAdminLevel]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}

stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}

stock udb_hash(buf[]) {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
//==============================================================================
public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"Player's Data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_WriteInt(File,"AdminLevel",PlayerInfo[playerid][pAdminLevel]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);
   
    new pname[MAX_PLAYER_NAME], string[63 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(string, sizeof(string), "%s has Joined the server.", pname, aDisconnectNames[reason]);
    SendClientMessageToAll(COLOR_CYAN, string);
    return 1;
}
//==============================================================================
public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid,Clock);
    TextDrawShowForPlayer(playerid,Date);

    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
    SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
    //Should I add something here?
    return 1;
}
//============================================================================//
public OnPlayerCommandText(playerid, cmdtext[])
{
    //All Player's Commands.
    dcmd(rules,5,cmdtext);
    //Admins Commands.
    if(AdminLevel[playerid] >= 1)
    {
       dcmd(ann,3,cmdtext);
       return 1;
    }
    //Civilian Commands.
    //Law Inforcement Commands.
    //Medic Commands.
    //FireFighter Commands.
    return 1;
}
//====================================================================
The /ann is not working when I add it to AdminLevel[playerid].....
When I add it to all players, it works fine, so it's a loading AdminLevel error.

No compiling error.

EDIT: Just removed a Typo..
Reply
#2

Anyone please?
Reply
#3

If you have some sort of a log in system, use this when the player logs in:

Код:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
Reply
#4

Already there
pawn Код:
public OnPlayerConnect(playerid)
{
        new pname[MAX_PLAYER_NAME], string[63 + MAX_PLAYER_NAME];
        SendClientMessage(playerid,COLOR_GREEN,"Welcome to San Andreas");
        SendClientMessage(playerid,COLOR_GREEN,"Make sure you read and Abide by our /rules, and obey our admins.");
        TogglePlayerClock(playerid, 0);

        if(fexist(UserPath(playerid)))
        {
           INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); //here it is
           ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"{F81414}San Andreas  ","{FFFFFF}Welcome back, Please type your password below to login.","Login","Quit");
        }
        else
        {
           ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"{F81414}San Andreas ","{FFFFFF}Welcome, Please type your password below to register a new account.","Register","Quit");
        }
       
        GetPlayerName(playerid, pname, sizeof(pname));
        format(string, sizeof(string), "%s has Joined the server.", pname);
        SendClientMessageToAll(COLOR_CYAN, string);
        return 1;
}
Reply
#5

Код:
if(PlayerInfo[playerid][pAdminLevel] >= 1)
{
     dcmd(ann,3,cmdtext);
     return 1;
}
You had the wrong variable...
Reply
#6

Still not working tho. x_X
Reply
#7

Код:
INI_Int("Admin Level",PlayerInfo[playerid][pAdminLevel]);

INI_WriteInt(File,"AdminLevel",PlayerInfo[playerid][pAdminLevel]);
Make them both equal.
And I suggest that you don't use spaces when saving your integers.
Reply
#8

They're already like that.. What do you mean?
Reply
#9

"Admin Level" and "AdminLevel" are not the same thing.
They both have to be the same.

Ahh...
Just replace this line in your scipt.
Код:
INI_Int("Admin Level",PlayerInfo[playerid][pAdminLevel]);
to
Код:
INI_Int("AdminLevel",PlayerInfo[playerid][pAdminLevel]);
Reply
#10

Thanks dude!!
Stupid me, I appreciate it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)