SA-MP Forums Archive
Problem with Commands and how they are ordered - 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: Problem with Commands and how they are ordered (/showthread.php?tid=282694)



Problem with Commands and how they are ordered - Grant Johnston - 12.09.2011

Im not sure really how to ask how to Fix this.
But when I Type in /killspawnpoint. Which is a command of mine.
It triggers /kill

Код:
   			if (strcmp("/kill", cmdtext, true, 5) == 0)
	{
     SendClientMessage(playerid, COLOR_WHITE, "Killed");
	 SetPlayerHealth(playerid, 0.00);
    return 1;
	}
Thats the /kill code. what do I Need to change For it to only work if it is ONLY written /kill not anything like it :P

Thanks Lads


Re: Problem with Commands and how they are ordered - AceFlyer - 12.09.2011

Well i font know much about strcmp Commands Because i never used it much try posting the /killspawnpoint command too maybe it would help solve it This command looks pretty good to me


Re: Problem with Commands and how they are ordered - rangerxxll - 12.09.2011

I dont really know what you mean.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/kill", cmdtext, true, 10) == 0)
    {
        SetPlayerHealth(playerid, 0);
        SendClientMessage(playerid, COLOR_WHITE, "Killed");
        return 1;
    }
    return 0;
}
That's a basic kill command.

EDIT: Oh, I see. Well, I'm not very familiar with strcmp either lol, Sorry.


Re: Problem with Commands and how they are ordered - Grant Johnston - 12.09.2011

Yeah I Know, its hard to explain the problem. -_-


Re: Problem with Commands and how they are ordered - linuxthefish - 12.09.2011

Make sure you set the correct length of the string to check.


Re: Problem with Commands and how they are ordered - Wesley221 - 12.09.2011

Or just use 'ZCMD', 'YCMD' (maybe 'DCMD', not sure about this one).
ZCMD is the fastest command processor if you have < 100 commands, when you have above 100 commands i would prefer YCMD, since its a little bit faster then ZCMD


Re: Problem with Commands and how they are ordered - Grant Johnston - 12.09.2011

Gah, cbf to Learn how to use ZCMD or YCMD. Im going to wallow in my own pain of this command fucking up. XD


Re: Problem with Commands and how they are ordered - rangerxxll - 12.09.2011

Quote:
Originally Posted by Grant Johnston
Посмотреть сообщение
Gah, cbf to Learn how to use ZCMD or YCMD. Im going to wallow in my own pain of this command fucking up. XD
Zcmd is very easy, all you got to do is
pawn Код:
COMMAND:kill(playerid, cmdtext)
{
    SetPlayerHealth(playerid, 0);
    SendClientMessage(playerid, COLOR_RED, "You just killed your self");
    return 1;
}



Re: Problem with Commands and how they are ordered - Grant Johnston - 12.09.2011

Really? That seems Simple. I might have a look at it. :P Thanks


Re: Problem with Commands and how they are ordered - rangerxxll - 12.09.2011

Quote:
Originally Posted by Grant Johnston
Посмотреть сообщение
Really? That seems Simple. I might have a look at it. :P Thanks
Yep, instead of
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/kill", cmdtext, true, 10) == 0)
    {
All you got to do is
pawn Код:
COMMAND:(command here)(playerid, cmdtext)
{
    //Your shit here - example SendClientMessage(playerid, red, "This is easy");
    return 1;
}