Author Topic: Procedures  (Read 2258 times)

0 Members and 1 Guest are viewing this topic.

Offline JFK

  • Camper
  • ***
  • Posts: 255
    • My TraxInSpace Account
Re: Procedures
« Reply #20 on: April 07, 2008, 10:27:29 am »
Ok, let me try to explain. We work here with two different things: Procedures and Functions. The only difference between this two is that a Function will return a variable (a boolean, string, integer etc.). What the function returns is called the 'result'.
OnPlayerCommand is a function. This function will return a boolean (true or false). If it returns True then soldat will disable all commands accept the ones you discribe in OnPlayerCommand. Therefor you usually want to have result := false somewhere in the OnPlayerCommand function.
OnPlayerSpeak is a Procedure, it doesn't return anything. So if you put 'result' in OnPlayerSpeak the compiler will tell you that the identifier was not found.
Come join: EliteCTF
Listen to: My Music

Offline RunMan

  • Major(1)
  • Posts: 27
Re: Procedures
« Reply #21 on: April 07, 2008, 10:47:28 am »
But I use OnPlayerCommands not OnPlayerSpeak

Offline JFK

  • Camper
  • ***
  • Posts: 255
    • My TraxInSpace Account
Re: Procedures
« Reply #22 on: April 07, 2008, 12:07:23 pm »
then really recheck your code. It should be a Function like this:

Code: [Select]
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
  --blabla, whatever here--
  Result := false;
end;

Result cannot be an unknown identifier then...
Come join: EliteCTF
Listen to: My Music

Offline RunMan

  • Major(1)
  • Posts: 27
Re: Procedures
« Reply #23 on: April 07, 2008, 01:02:16 pm »
Thanks, you are so cool :D

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Procedures
« Reply #24 on: April 07, 2008, 02:30:46 pm »
Thats because variables are default false, 0, or whatever.
not always =F I think its highly recommended to reset your vars because of the nature of the language... Dont know the details, but it does act funny sometimes
I found that 100% of the time in pascal that statement true, but not in other languages though.. Although it is good practice to set default values to variables.