Command Error - 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: Command Error (
/showthread.php?tid=138767)
Command Error -
keujh - 03.04.2010
Well, I'm slowly learning and moving along, although i keep coming across this same error when ever i try to add /etc commands.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
if(strcmp(cmdtext, "/help", true) == 0)
{
SendClientMessage(playerid, COLOR_BLUE, "** HELP **");
SendClientMessage(playerid, COLOR_RED, "** COMMANDS **\n /suicide");
}
if(strcmp(cmdtext, "/error", true) == 0)
{
SendClientMessage(playerid, COLOR_RED, "** ERROR **");
return 1;
}
This is the annoying error i keep getting.
pawn Код:
C:\DOCUME~1\SKELLY~1\Desktop\GTASER~1\GAMEMO~1\Untitled.pwn(139) : error 010: invalid function or declaration
C:\DOCUME~1\SKELLY~1\Desktop\GTASER~1\GAMEMO~1\Untitled.pwn(142) : error 010: invalid function or declaration
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
2 Errors.
Any help is appreciated.
Thanks.
Re: Command Error -
dracar - 03.04.2010
missing your { after public OnPlayerCommandText(playerid, cmdtext[]), cant have if's floating around in the middle of no where lol
Re: Command Error -
Calgon - 03.04.2010
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/help", true) == 0)
{
SendClientMessage(playerid, COLOR_BLUE, "** HELP **");
SendClientMessage(playerid, COLOR_RED, "** COMMANDS **\n /suicide");
return 1;
}
if(strcmp(cmdtext, "/error", true) == 0)
{
SendClientMessage(playerid, COLOR_RED, "** ERROR **");
return 1;
}
}
Remember to return 1 (for commands) - though you should use an alternate command processor (such as
zcmd), and use brackets to keep code in callbacks/functions etc.
Re: Command Error -
keujh - 03.04.2010
Quote:
Originally Posted by dracar
missing your { after public OnPlayerCommandText(playerid, cmdtext[]), cant have if's floating around in the middle of no where lol
|
OMG LOL! i didn't even realize that. (Looks down.. hits head on desk really hard, till blood starts to drip)
Re: Command Error -
keujh - 03.04.2010
Quote:
Originally Posted by FreddoX [BINMAN
]
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp(cmdtext, "/help", true) == 0) { SendClientMessage(playerid, COLOR_BLUE, "** HELP **"); SendClientMessage(playerid, COLOR_RED, "** COMMANDS **\n /suicide"); return 1; } if(strcmp(cmdtext, "/error", true) == 0) { SendClientMessage(playerid, COLOR_RED, "** ERROR **"); return 1; } }
Remember to return 1 (for commands) - though you should use an alternate command processor (such as zcmd), and use brackets to keep code in callbacks/functions etc.
|
Thanks, but I've got a warning now.
pawn Код:
C:\Documents and Settings\Skellyhand\Desktop\gtaserver\gamemodes\Untitled.pwn(146) : warning 209: function "OnPlayerCommandText" should return a value
Re: Command Error -
ScottCFR - 03.04.2010
Put return 1; at the bottom of OnPlayercommandText
Re: Command Error -
keujh - 03.04.2010
Thank you.