Kill /kill - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Kill /kill (
/showthread.php?tid=66137)
Kill /kill -
walrus - 19.02.2009
Hello, how can i kill myself with cmd /kill? I have made it, but compiler shows errors

Can anyone help me, this is my script:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if (strcmp(cmd, "/kill", true) == 0)
{
SetPlayerHealth(playerid, 0.0);
}
}
And this is what i get when i try to compile
Код:
C:\Documents and Settings\Martynas\Desktop\samp\gamemodes\timertest.pwn(71) : error 017: undefined symbol "strtok"
C:\Documents and Settings\Martynas\Desktop\samp\gamemodes\timertest.pwn(71) : error 033: array must be indexed (variable "cmd")
C:\Documents and Settings\Martynas\Desktop\samp\gamemodes\timertest.pwn(70) : warning 203: symbol is never used: "idx"
Re: Kill /kill -
Grim_ - 19.02.2009
you need the strtok stock to fix the erros.
Though, you don't need it just to do the /kill command:
pawn Код:
if(strcmp(cmdtext, "/kill", true) == 0)
{
SetPlayerHealth(playerid, 0.0);
return 1;
}
Re: Kill /kill -
walrus - 19.02.2009
strtok stock? What you mean, sorry my english bad, lol
Re: Kill /kill -
amrour - 19.02.2009
either u define strtok, either just copy what he wrote up there to ur script.
Re: Kill /kill -
Grim_ - 19.02.2009
instead of
pawn Код:
if(strcmp(cmd, "/kill", true) == 0)
{
SetPlayerHealth(playerid, 0.0);
return 1;
}
just replace the 'cmd' with 'cmdtext' so,
pawn Код:
if(strcmp(cmdtext, "/kill", true) == 0)
{
SetPlayerHealth(playerid, 0.0);
return 1;
}
Re: Kill /kill -
walrus - 19.02.2009
It works!

Thank you so much!
Re: Kill /kill -
TheArbiter97 - 24.04.2009
hey dude i wanna addthis to my server where i put it?\
PS:Credits goto you
EDIT:btw i already have a onplayer command text