CMD:makeadmin help!
#1

Everything works great besides one thing..
When you register a new account you automatically become an admin..
I think it's something with the "type". When I register a new character I became LVL 5 admin but when a friend of mine register he became a LVL 4 admin, weird.
pawn Код:
COMMAND:makeadmin(playerid, params[])
{
    new targetid, type, string[128], sendername[MAX_PLAYER_NAME], staffname[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME];
    if(sscanf(params, "ui", targetid, type)) SendClientMessage(playerid, COLOR_GREY, "USAGE: /makeadmin [PlayerID] [level 0-5]");
    else
    {
        if(type < 0 || type > 5) return SendClientMessage(playerid, COLOR_GREY, "SERVER: Cannot go under 0 or above 5.");
        if(PlayerInfo[playerid][pStaff] >= 5)
        {
            format(sendername, sizeof(sendername), "%s", PlayerName(playerid));
            format(staffname, sizeof(staffname), "%s", GetStaffLvlName(playerid));
            format(targetname, sizeof(targetname), "%s", PlayerName(targetid));
            GiveNameSpace(sendername);
            GiveNameSpace(targetname);
            PlayerInfo[targetid][pStaff] = type;
            new INI:File = INI_Open(UserPath(targetid));
            INI_SetTag(File,"data");
            INI_WriteInt(File,"Staff", type);
            INI_Close(File);
            SetPlayerHealth(targetid, 0);
            format(string, sizeof(string), "[Staff-Command]: %s %s has promoted %s to Staff-Level %d.", staffname, sendername, targetname, type);
            SendStaffMessage(COLOR_YELLOW, string);
            format(string, sizeof(string), "%s %s has promoted you to Staff-Level %d.", staffname, sendername, type);
            SendClientMessage(targetid, COLOR_GREEN, string);
        }
        else
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "WARNING: You do not have access to this command.");
        }
    }
    return 1;
}
Reply
#2

Under OnPlayerConnect, add this code before you check ask them to register/login:
pawn Код:
PlayerInfo[playerid][pStaff] = 0;
This will make it so everyone's staff level is 0.

Then when you load up their stats from the database, it will set the saved value to their new value.

Or
Under OnPlayerDisconnect, add this code AFTER you save their stats:
pawn Код:
PlayerInfo[playerid][pStaff] = 0;
EDIT: If you want this explained better, just send me a PM.
Reply
#3

Lol thanks!

Didn't know that if you put a line before another one it loads it first.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)