Command Error
#1

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

missing your { after public OnPlayerCommandText(playerid, cmdtext[]), cant have if's floating around in the middle of no where lol
Reply
#3

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

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

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

Put return 1; at the bottom of OnPlayercommandText
Reply
#7

Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)