Easy coding help!
#1

What's up? I have not been scripting for some months and I forgot alot, anyways when I try to execute this command I get "Invalid player ID" even tought it's the right one.

Code:
CMD:makeadmin(playerid, params[])
{
    new pID, value;
    if(PlayerInfo[playerid][pAdmin] < 1338 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You are not authorized to use this command.");
    else if (sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /makeadmin [playerid/partofname] [level 1-1338].");
    else if (value < 0 || value > 1338) return SendClientMessage(playerid, COLOR_RED, "Unknown level! Only 0 to 1338.");
    else if(pID == INVALID_PLAYER_ID) return SCM(playerid, COLOR_RED,"Invalid player id.");
    else {
        new pName[MAX_PLAYER_NAME], tName[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        GetPlayerName(pID, tName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "You have promoted %s to Admin level %i", tName, value);
        SCM(playerid, COLOR_GREEN, string);
        format(string, sizeof(string), "You have been promoted to Admin level %i by %s", value, pName);
        SCM(pID, COLOR_GREEN, string);
        PlayerInfo[pID][pAdmin] = value;
    }
    return 1;
}
Reply
#2

pawn Code:
CMD:makeadmin(playerid, params[])
{
    new pID, value;
    if(PlayerInfo[playerid][pAdmin] => 1338 && IsPlayerAdmin(playerid))
    {
    if(!sscanf(params, "ui", pID, value))
    {
    if (value > 0 && value <= 1338)
    {
    if(IsPlayerConnected(pID))
    {
        new pName[MAX_PLAYER_NAME], tName[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        GetPlayerName(pID, tName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "You have promoted %s to Admin level %i", tName, value);
        SCM(playerid, COLOR_GREEN, string);
        format(string, sizeof(string), "You have been promoted to Admin level %i by %s", value, pName);
        SCM(pID, COLOR_GREEN, string);
        PlayerInfo[pID][pAdmin] = value;
        return 1;
    }
    else return SCM(playerid, COLOR_RED,"Invalid player id.");
    }
    return SendClientMessage(playerid, COLOR_RED, "Unknown level! Only 0 to 1338.");
    }
    else return SendClientMessage(playerid, COLOR_GREY, "Usage: /makeadmin [playerid/partofname] [level 1-1338].");
    }
    return SendClientMessage(playerid, COLOR_RED, "You are not authorized to use this command.");
}
Reply
#3

pawn Code:
CMD:makeadmin(playerid, params[])
{
    new
        p_ID,
        p_Admin
    ;

    if(PlayerInfo[playerid][pAdmin] == 1338 || !IsPlayerAdmin(playerid))
    {
        if(sscanf(params, "ui", p_ID, p_Admin))
            return SendClientMessage(playerid, COLOR_GREY, "Usage: /makeadmin [playerid/partofname] [level 1-1338].");

        if (value < 0 || value > 1338) return SendClientMessage(playerid, COLOR_RED, "Unknown level! Only 0 to 1338.");

        if(pID == INVALID_PLAYER_ID) return SCM(playerid, COLOR_RED,"Invalid player id.");

        new pName[MAX_PLAYER_NAME], tName[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        GetPlayerName(pID, tName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "You have promoted %s to Admin level %i", tName, value);
        SCM(playerid, COLOR_GREEN, string);
        format(string, sizeof(string), "You have been promoted to Admin level %i by %s", value, pName);
        SCM(pID, COLOR_GREEN, string);
        return PlayerInfo[pID][pAdmin] = value;
    }
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)