CMD:makeadmin(playerid,params[]) returns 0 and doesnt do anything
#1

Hey,

I made this command:

pawn Код:
CMD:makeadmin(playerid,params[])
{
    new string[128],name[MAX_PLAYER_NAME],pID,Level;
    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] <= 0) return 0;
    if(j_sscanf(params,"ui",pID,Level)) return SendClientMessage(playerid,COLOR_GREY,"/makeadmin <player> <level>");
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid,COLOR_GREY,"Invalid Player Specified");
    else if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] >= 1338)
    {
        PlayerInfo[pID][pAdminLevel] = Level;
        format(string,sizeof(string),"** ADMIN PROMOTE: %s Is Now An Administrator Level %d!",name,Level);
        SendClientMessageToAll(COLOR_PINK,string);
        GameTextForPlayer(pID,"Promoted",3000,4);
        return 1;
    }
    return 1;
}
Unforantly it doesnt work.

Could someone please explain why this is?

Thanks

-Michael
Reply
#2

Logged into Rcon?
Reply
#3

try:
if(!IsPlayerAdmin(playerid) && PlayerInfo[playerid][pAdminLevel] <= 1337) return 0;
Reply
#4

Quote:
Originally Posted by THE_KNOWN
Посмотреть сообщение
try:
if(!IsPlayerAdmin(playerid) && PlayerInfo[playerid][pAdminLevel] <= 0) return 0;
PlayerInfo[playerid][pAdminLevel] == 0...
Reply
#5

Edited.
Reply
#6

pawn Код:
if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] <= 0)
I have tried doing something quite similar to the code above, but what seems to happen is that none of the code on that line actually works at all.

I noticed you were running an admin-check twice, you only need to do it once.
Reply
#7

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
pawn Код:
if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] <= 0)
I have tried doing something quite similar to the code above, but what seems to happen is that none of the code on that line actually works at all.

I noticed you were running an admin-check twice, you only need to do it once.
That's what I was trying to tell him xD
Reply
#8

Try:
pawn Код:
if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] <= 0) return 1;
If not, try:
pawn Код:
if(!IsPlayerAdmin(playerid) && PlayerInfo[playerid][pAdminLevel] <= 0) return 1;
Never return 0; in a command like this, always return 1.
Reply
#9

pawn Код:
if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] < 1) return SendClientMessage(playerid, -1, "Your NOT rcon admin or admin level 1+!");
pawn Код:
if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] > 0) return SendClientMessage(playerid, -1, "Your RCON admin OR admin level 1+");
Reply
#10

pawn Код:
CMD:makeadmin(playerid,params[])
{
    new string[128],name[MAX_PLAYER_NAME],pID,Level;
    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] < 1) return 0;
    if(sscanf(params,"ui",pID,Level)) return SendClientMessage(playerid,COLOR_GREY,"/makeadmin <player> <level>");
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid,COLOR_GREY,"Invalid Player Specified");
    PlayerInfo[pID][pAdminLevel] = Level;
    format(string,sizeof(string),"** ADMIN PROMOTE: %s Is Now An Administrator Level %d!",name,Level);
    SendClientMessageToAll(COLOR_PINK,string);
    GameTextForPlayer(pID,"Promoted",3000,4);
    return 1;
}
This should work.

@Jack_Leslie Wrong. If he returns 0 in command it would send message "SERVER: UNKNOWN COMMAND".
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)