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


Messages In This Thread
Load AdminLevel, OnPlayerSpawn, How? - by _Khaled_ - 23.08.2012, 22:02
Re: Load AdminLevel, OnPlayerSpawn, How? - by _Khaled_ - 23.08.2012, 22:20
Re: Load AdminLevel, OnPlayerSpawn, How? - by Shetch - 23.08.2012, 22:38
Re: Load AdminLevel, OnPlayerSpawn, How? - by _Khaled_ - 23.08.2012, 22:40
Re: Load AdminLevel, OnPlayerSpawn, How? - by Shetch - 23.08.2012, 22:42
Re: Load AdminLevel, OnPlayerSpawn, How? - by _Khaled_ - 23.08.2012, 22:47
Re: Load AdminLevel, OnPlayerSpawn, How? - by Shetch - 23.08.2012, 22:50
Re: Load AdminLevel, OnPlayerSpawn, How? - by _Khaled_ - 23.08.2012, 22:52
Re: Load AdminLevel, OnPlayerSpawn, How? - by Shetch - 23.08.2012, 22:54
Re: Load AdminLevel, OnPlayerSpawn, How? - by _Khaled_ - 23.08.2012, 23:08

Forum Jump:


Users browsing this thread: 2 Guest(s)