/kill command bugged
#1

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

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

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

ask in the damn GF topic.


Quote:
Originally Posted by kaiser
Reply
#4

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

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

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

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

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

Код:
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.
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)