Command not functioning properly
#1

Why is this command:
pawn Код:
CMD:makeleader(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 99998)
    {
        new player;
        if(player != INVALID_PLAYER_ID)
        {
            new faction;
            if(sscanf(params,"ud", player, faction)) return SendClientMessage(playerid, -1, "Usage: /makeleader [playerid / name] [factionid]");
            if(faction >= 1 && faction <= 4)
            {
                PlayerInfo[player][pFaction] = faction;
                PlayerInfo[player][pRank] = 6;
                PlayerInfo[player][pDivision] = 0;
                new string[128];
                new aName[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME];
                GetPlayerName(playerid, aName, MAX_PLAYER_NAME);
                GetPlayerName(player, pName, MAX_PLAYER_NAME);
                format(string, sizeof(string), ""COL_RED"[ADMIN] Administrator %s has promoted %s to the leader of the: "COL_LIGHTBLUE"%s", aName, pName, FactionStatus(playerid));
                SendClientMessageToAll(0xFFFFFF, string);
            }
            else
            {
                SendClientMessage(playerid, COLOR_TOMATO, "ERROR: Don't go below 1 or above 4!");
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_TOMATO, "ERROR: That player is not connected!");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_TOMATO, "ERROR: You are not authorized to use that command!");
    }
    return 1;
}
acting really weird.


If I ask someone to join my server and do for example: /makeleader dennis 4
It sets me to faction 4 and him too. And sometimes its behaviour is even worse. I don't know what the hell this command is thinking but please help me
Reply
#2

I would try running
Код:
if(sscanf(params,"ud", player, faction)) return SendClientMessage(playerid, -1, "Usage: /makeleader [playerid / name] [factionid]");
before
Код:
if(player != INVALID_PLAYER_ID)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)