SA-MP Forums Archive
Command not working (strcmp) - 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 not working (strcmp) (/showthread.php?tid=507451)



Command not working (strcmp) - Lajko1 - 17.04.2014

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    new idx;
    cmd = strtok(cmdtext, idx);
    //dcmd(takedrugs,9, cmdtext);
    if(strcmp(cmd, "/usedrugs", true) == 0)
    {
        new x_nr[256];
        x_nr = strtok(cmdtext, idx);
       
        if(!strlen(x_nr))
        {
            SendClientMessage(playerid, -1, "{FF6A22}USAGE: {FFFFFF}/takedrugs [name]");
            SendClientMessage(playerid, -1, "{FF6A22}Available names: {FFFFFF}Weed, Cocaine, Crack, Meth, Ectasy, Heroin");
            return 1;
        }
        if(strcmp(x_nr,"weed",true) == 0)
        {
            new Float:Health;
            GetPlayerHealth(playerid, Health);
           
            if(Pdrug[playerid][Weed] > 1)
            {
                Pdrug[playerid][Weed] -= 1;
                SetPlayerHealth(playerid, Health + 2);
                SetPlayerWeather(playerid, -68);
                SendClientMessage(playerid, -1, "{FFFFFF}test msg");
            }
            else
            {
                SendClientMessage(playerid, -1, "{FF6A22}INFO: {FFFFFF}You don't have any weed to smoke.");
            }
        }
        return 1;
    }
    //rest of cmds
    return 0;
}
No errors and nothing.. but Command isn't working - no effect when I type /takedrugs - it doesn't send me "errors msgs" and if I write "/takedrugs weed" it say Server unknown command, so can someone help me please?