SA-MP Forums Archive
command wont work properly and strcmp [ need help ] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: command wont work properly and strcmp [ need help ] (/showthread.php?tid=367330)



command wont work properly and strcmp [ need help ] - RicaNiel - 09.08.2012

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;
}



Re: command wont work properly and strcmp [ need help ] - Dawnz - 09.08.2012

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


Re: command wont work properly and strcmp [ need help ] - RicaNiel - 09.08.2012

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


Re: command wont work properly and strcmp [ need help ] - Dawnz - 09.08.2012

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.


Re: command wont work properly and strcmp [ need help ] - Vince - 09.08.2012

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;