SA-MP Forums Archive
/kill command bugged - 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 command bugged (/showthread.php?tid=80262)



/kill command bugged - skalman - 03.06.2009

Okey, I have this in gf.pwn

line 26244| public OnPlayerCommandText(playerid, cmdtext[])
line 26245| {
line 26246| new cmd[256], idx;
line 26247| cmd = strtok(cmdtext, idx);
line 26248|
line 26249| if (strcmp(cmdtext, "/kill", true) == 0)
line 26250| {
line 26251| SetPlayerHealth(playerid, 0.0);
line 26252| }
line 26253| }


but when I compile it I get this:

C:\Program\Rockstar Games\SAMPserver\gamemode\gf.pwn(26245) : error 021: symbol already defined: "OnPlayerCommandText"
C:\Program\Rockstar Games\SAMPserver\gamemode\gf.pwn(26253) : warning 209: function "OnPlayerCommandText" should return a value
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.




(Just to show you wich lines the things are at I wrote them in) Help me please



Re: /kill command bugged - Correlli - 03.06.2009

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);

if (strcmp(cmdtext, "/kill", true) == 0)
{
SetPlayerHealth(playerid, 0.0);
return 1;
}

return 0;
}
This will fix the warning. About the error, you're missing a bracket somewhere in the script probably.


Re: /kill command bugged - Think - 03.06.2009

Quote:
Originally Posted by skalman
Okey, I have this in gf.pwn

ask in the damn GF topic.


Quote:
Originally Posted by kaiser



Re: /kill command bugged - skalman - 03.06.2009

Okey I will just try to get a fix for this, now I still get this error:

C:\Program\Rockstar Games\SAMPserver\gamemode\gf.pwn(26245) : error 021: symbol already defined: "OnPlayerCommandText"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

How can that be fixed? On line 26245 I have a "{" that is all :P

Thanks for replying so fast!



Re: /kill command bugged - Correlli - 03.06.2009

You're missing bracket somewhere in the script, or you have one bracket which isn't needed.


Re: /kill command bugged - skalman - 03.06.2009

Okey this is the script:


LINE 26244| public OnPlayerCommandText(playerid, cmdtext[])
LINE 26245| {
LINE 26246| new cmd[256], idx;
LINE 26247| cmd = strtok(cmdtext, idx);
LINE 26248|
LINE 26249| if (strcmp(cmdtext, "/kill", true) == 0)
LINE 26250| {
LINE 26251| SetPlayerHealth(playerid, 0.0);
LINE 26252| return 1;
LINE 26253| }
LINE 26254|
LINE 26255| return 0;
LINE 26256| }




Thats how it looks with lines Hope someone can see what is wrong


Re: /kill command bugged - Correlli - 03.06.2009

This part of code is ok, look through script for missing { or }.


Re: /kill command bugged - radhakr - 03.06.2009

Or you already have OnPlayerCommandText elsewhere in the script. Search for it and if it is there put the /kill command in there.


Re: /kill command bugged - gergo11 - 03.06.2009

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);

if (strcmp(cmdtext, "/kill", true) == 0) return SetPlayerHealth(playerid, 0.0);

return 0;
}
Like this better according to me, more beautiful, plainer, and 1 row.


Re: /kill command bugged - Mike Garber - 03.06.2009

It's kinda obviosly that you're trying to add a "Public" function that already exists.

(OnPlayerCommandText).

You aren't supposed to add a new "public" function for each command.

Just make a new row Under another command, and paste this:



pawn Код:
if (strcmp("/kill", cmdtext, true, 10) == 0)
{
SetPlayerHealth(playerid, 0);
SendClientMessage(playerid, COLOR_YELLOW, "You have killed yourself.");
return 1;
}
Simple, but works!