Kill /kill
#1

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

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

strtok stock? What you mean, sorry my english bad, lol
Reply
#4

either u define strtok, either just copy what he wrote up there to ur script.
Reply
#5

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

It works! Thank you so much!
Reply
#7

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)