command wont work properly and strcmp [ need help ]
#1

guys i have a problem with my command
i cop the strcmp from my login system that work
but why when it is in my command
it will go haywire
i need explination

btw here is my code mind if you can fix it

pawn Код:
CMD:giveadmin(playerid,params[])
{
    new id, rank[28];
    if(sscanf(params,"us[28]",id,rank)) return SendClientMessage(playerid,C_RED,"[ Sytax ]:"CWHITE" /giveadmin [ id ] ["CMOD" Moderator "CWHITE"/"CADMIN" Administrator"CWHITE" /"COWNER" Owner"CWHITE" ] ");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,C_RED,"[ Error ]:"CWHITE" Player Unknown / Not Connected ");
    if(pData[playerid][pAdmin] < 3|| !IsPlayerAdmin(playerid)) return CMD_ERROR
    if(!strcmp(rank,"moderator"))
    {
        pData[id][pAdmin] = 1;
    }
    else if(!strcmp(rank,"mod"))
    {
        pData[id][pAdmin] = 1;
    }
    else if(!strcmp(rank,"administrator"))
    {
        pData[id][pAdmin] = 2;
    }
    else if(!strcmp(rank,"admin"))
    {
        pData[id][pAdmin] = 2;
    }
    else if(!strcmp(rank,"owner"))
    {
        pData[id][pAdmin] = 3;
    }
    else return SendClientMessage(playerid,C_RED,"[ Sytax ]:"CWHITE" /giveadmin [ id ] ["CMOD" Moderator "CWHITE"/"CADMIN" Administrator"CWHITE" /"COWNER" Owner"CWHITE" ] ");
    new string[500];
    format(string,sizeof(string),"%s %s has given you a %s status",a_rank_names(playerid),PlayerRPName(playerid),a_rank_names(id));
    SendClientMessage(playerid,C_WHITE,string);
    return 1;
}
Reply
#2

What does the cmd actually do In-Game, when you test it?
Does it give out the admin, send any messages or...?
Reply
#3

Quote:
Originally Posted by Dawnz
Посмотреть сообщение
What does the cmd actually do In-Game, when you test it?
Does it give out the admin, send any messages or...?
send the error message

or sometimes randomly choose its own
Reply
#4

Remove !IsPlayerAdmin from this line
if(pData[playerid][pAdmin] < 3|| !IsPlayerAdmin(playerid)) return CMD_ERROR
Both the pData and IsPlayerAdmin are exactly the same, except the first one gives out a certain admin level for the cmd.
Reply
#5

Logic error right here. Also missing semicolon.
pawn Код:
if(pData[playerid][pAdmin] < 3|| !IsPlayerAdmin(playerid)) return CMD_ERROR
Should be:
pawn Код:
if(pData[playerid][pAdmin] < 3 && !IsPlayerAdmin(playerid)) return CMD_ERROR;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)