Problem with Commands and how they are ordered
#1

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
Reply
#2

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
Reply
#3

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.
Reply
#4

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

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

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
Reply
#7

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

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;
}
Reply
#9

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)