Bracket problem
#1

Hey, what's up guys. i need a some help here. this is my code and i know the brackets are wrong... would somebody be kind enough to fix them? Thanks in-advance.

The error:
pawn Код:
C:\DOCUME~1\SKELLY~1\Desktop\GTASER~1\GAMEMO~1\Untitled.pwn(141) : warning 209: function "JB_OnPlayerCommandText" should return a value
C:\DOCUME~1\SKELLY~1\Desktop\GTASER~1\GAMEMO~1\Untitled.pwn(141) : error 010: invalid function or declaration
C:\DOCUME~1\SKELLY~1\Desktop\GTASER~1\GAMEMO~1\Untitled.pwn(143) : error 021: symbol already defined: "JB_SetPlayerHealth"
C:\DOCUME~1\SKELLY~1\Desktop\GTASER~1\GAMEMO~1\Untitled.pwn(144) : error 010: invalid function or declaration
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
if(!strcmp(cmdtext, "/help", true))
{
  TogglePlayerControllable(playerid,0);
  ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "What do you need help, with?", "Commands\nLocations\nJobs", "OK", "Cancel");
  TogglePlayerControllable(playerid,1);
  return 1;
}
if(!strcmp(cmdtext, "/suicide", true))
{
  SetPlayerHealth(playerid, 0);
  return 1;
}
NOTE: DON'T MIND errors on lines 141 & 143
Reply
#2

Quote:
Originally Posted by [ĦŁ₣
ЉǾǖŦĦЗŁΛẄ ]
A Callback must have it's own set of brackets:

Callback()
{
Statements()
{
Functions()
}
return
}

Then add the return at the bottom, for commandtext it should be 'return 0;' so it returns an error if a player enters an invalid command, or if you want to make your own error then instead of the '0' in 'return 0;' add a SendClientMessage 'return SendClientMessage(...);'

Hope this helped you :P
Well thanks for this but, if i wanted an explanation on how they work i would of asked for that. the reason why i asked for someone else to fix it is, because IM DUMB.
Reply
#3

Quote:
Originally Posted by [ĦŁ₣
ЉǾǖŦĦЗŁΛẄ ]
public OnPlayerCommandText(playerid, cmdtext[])

is a callback therefore needs braces:

public OnPlayerCommandText(playerid, cmdtext[])
{

code...

return 0;

}

there
LOL, alright man.. thanks a bunch. I'll make sure you go in the credits for the game mode I'm making.
Reply
#4

Ok, nvm this is not working out.. and that's why i said i was dumb. i blame my A.D.D but yeaaaaahhhh.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)