Anything wrong with this command ?
#1

Hello guys i have made this command but the problem is when i type /setadmin 1 3 in game it just sets the player with the lowest id 0 as an admin not only this but some other commands have same problem can someone explain why and how can i fix it
pawn Код:
CMD:setadmin(playerid, params[])
{
    if(IsPlayerAdmin(playerid) | PlayerInfo[playerid][pAdmin] >= 3)
    {
        new pID;
        new Level;
        new string[128];
        new pName[MAX_PLAYER_NAME];
        new aName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, aName, sizeof(aName));
        GetPlayerName(pID, pName, sizeof(pName));
        if(sscanf(params, "ui", pID, Level)) return SendClientMessage(playerid, -1, "[USAGE] /setadmin [playerid] [level]");
        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, -1, "[ERROR] The Player You Want To Make Admin Is Not Connected");
        format(string, sizeof(string), "Admin %s Has Made %s An Admin Level %d", aName, pName, Level);
        SendClientMessageToAll(-1, string);
        PlayerInfo[pID][pAdmin] = Level;
    }
    else return SendClientMessage(playerid, -1, "You Are Not Authorized To Use That Command");
    return 1;
}
Reply
#2

It's a ID Bug sir.You need to update all of your Includes and Plugins then compile it.
Reply
#3

Is it the ID or just the level you're trying to set the player as?
Reply
#4

Quote:
Originally Posted by [BK]TrollKing
Посмотреть сообщение
It's a ID Bug sir.You need to update all of your Includes and Plugins then compile it.
It is already updated to the latest include and plugin version

Quote:
Originally Posted by Akira297
Посмотреть сообщение
Is it the ID or just the level you're trying to set the player as?
The ID is the problem when i write /setadmin 1 3 or 2 or 1 the ID returns 0
Reply
#5

So,

example
Код:
/setadmin Lexi 3
It gives you admin 0 ?

Or does it not work?

or

Код:
/setadmin 0 3 < You've made Akira admin level "3"
Instead of your ID ?
Reply
#6

Quote:
Originally Posted by Lexi'
Посмотреть сообщение
It is already updated to the latest include and plugin version



The ID is the problem when i write /setadmin 1 3 or 2 or 1 the ID returns 0
There is nothing wrong with the command it's a ID Bug.
Reply
#7

Quote:
Originally Posted by Akira297
Посмотреть сообщение
So,

example
Код:
/setadmin Lexi 3
It gives you admin 0 ?

Or does it not work?

or

Код:
/setadmin 0 3 < You've made Akira admin level "3"
Instead of your ID ?
Let me tell you this way first of all the pattern is like this "/setadmin [playerid] [level]" let's say there are 2 players in the server one of them is ID 0 and the other is ID 1 and i want to make ID 1 an admin but when i write /setadmin 1 3 it says you have set ID 0 as admin, not 1.
Reply
#8

Yes, that is what [BK]TrollKing has been sayin, you have a ID bug. You gotta make sure to update your Plugins and Includes.
Reply
#9

The command is working just fine, the problem is that 'SendClietMessage' and that 'pName'.
As you might know, when you declare a variable, it's set to '0'. So when you declared 'pID' you made it 'pID=0'.
You used sscanf AFTER you got the ID of the player, meaning that first it gets the name and afterwards checks what ID the person was typing in the command. So it does not work that way. Let me fix it for you.
pawn Код:
CMD:setadmin(playerid, params[])
{
    if(IsPlayerAdmin(playerid) | PlayerInfo[playerid][pAdmin] >= 3)
    {
        new pID;
        new Level;
        new string[128];
        new pName[MAX_PLAYER_NAME];
        new aName[MAX_PLAYER_NAME];
        if(sscanf(params, "ui", pID, Level)) return SendClientMessage(playerid, -1, "[USAGE] /setadmin [playerid] [level]"); // Just moved this line a bit.
        GetPlayerName(playerid, aName, sizeof(aName));
        GetPlayerName(pID, pName, sizeof(pName));
        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, -1, "[ERROR] The Player You Want To Make Admin Is Not Connected");
        format(string, sizeof(string), "Admin %s Has Made %s An Admin Level %d", aName, pName, Level);
        SendClientMessageToAll(-1, string);
        PlayerInfo[pID][pAdmin] = Level;
    }
    else return SendClientMessage(playerid, -1, "You Are Not Authorized To Use That Command");
    return 1;
}
edit: There is no ID bug as the guys above suggested. The command is working, you just don't know that.
Reply
#10

Quote:
Originally Posted by Berlovan
Посмотреть сообщение
The command is working just fine, the problem is that 'SendClietMessage' and that 'pName'.
As you might know, when you declare a variable, it's set to '0'. So when you declared 'pID' you made it 'pID=0'.
You used sscanf AFTER you got the ID of the player, meaning that first it gets the name and afterwards checks what ID the person was typing in the command. So it does not work that way. Let me fix it for you.
pawn Код:
CMD:setadmin(playerid, params[])
{
    if(IsPlayerAdmin(playerid) | PlayerInfo[playerid][pAdmin] >= 3)
    {
        new pID;
        new Level;
        new string[128];
        new pName[MAX_PLAYER_NAME];
        new aName[MAX_PLAYER_NAME];
        if(sscanf(params, "ui", pID, Level)) return SendClientMessage(playerid, -1, "[USAGE] /setadmin [playerid] [level]"); // Just moved this line a bit.
        GetPlayerName(playerid, aName, sizeof(aName));
        GetPlayerName(pID, pName, sizeof(pName));
        if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, -1, "[ERROR] The Player You Want To Make Admin Is Not Connected");
        format(string, sizeof(string), "Admin %s Has Made %s An Admin Level %d", aName, pName, Level);
        SendClientMessageToAll(-1, string);
        PlayerInfo[pID][pAdmin] = Level;
    }
    else return SendClientMessage(playerid, -1, "You Are Not Authorized To Use That Command");
    return 1;
}
edit: There is no ID bug as the guys above suggested. The command is working, you just don't know that.
Thanks mate it worked, and thank you all for trying to help.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)