What is the purpose of 'return' in callbacks?
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
Same question was asked a while back. For default callbacks, it tells the server whether it should process the same callback in other (filter)scripts.
So there isn't any need for it in custom callbacks?

And whenever a default callback is called it ALWAYS calls the one within the gamemode script? I've noticed that returning the value 0 in the 'OnPlayerText' callback will stop the chat all together to allow a custom chat format. I guess this is the process?:

Код:
> Player talks
> 'OnPlayerText' is called in the gamemode script
> Code gets executed
> return 1:
	> Processes the message in an internal script
	> Continues to other filterscripts
> return 0:
	> Callback stops completely, not called anywhere else
EDIT: Time limit not allowing me to double post:

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
In custom callbacks is not necessary to return values and it's not actually necessary to return a value to some of the callbacks (by samp) either.

You may see in SA-MP Wiki in some callbacks to say "This callback does not handle returns." and some other say what happens if we return a specific value. Let's take an example of OnPlayerCommandText callback. SA-MP Wiki says:
Returning 0 in some callbacks stops those callbacks from being called in other modes such as filterscripts etc.

Another example is OnPlayerText callback and returning 0 will disable the default chat.
Ahh okay that makes sense, check the above post for my assumption on how 'OnPlayerText' works too.
Reply


Messages In This Thread
What is the purpose of 'return' in callbacks? - by Bicentric - 02.02.2014, 18:02
Re: What is the purpose of 'return' in callbacks? - by Vince - 02.02.2014, 18:09
Re: What is the purpose of 'return' in callbacks? - by Konstantinos - 02.02.2014, 18:12
Re: What is the purpose of 'return' in callbacks? - by Bicentric - 02.02.2014, 18:17
Re: What is the purpose of 'return' in callbacks? - by PowerPC603 - 02.02.2014, 18:28

Forum Jump:


Users browsing this thread: 1 Guest(s)