Raised This Month: $32 Target: $400
 8% 

NEEDED: Decent, Thorough explaination of returns?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kirewv
Senior Member
Join Date: Oct 2007
Old 03-24-2008 , 15:04   NEEDED: Decent, Thorough explaination of returns?
Reply With Quote #1

Plugin_continue, Plugin_stop, Plugin_handled...I have read all I could find in the wiki and examples and I am still confused about when and why to use these. If someone who really understands these could explain them in laymans terms, without quoting anything from what is already written, I think many scriptors would benefit.
kirewv is offline
BAILOPAN
Join Date: Jan 2004
Old 03-24-2008 , 15:10   Re: NEEDED: Decent, Thorough explaination of returns?
Reply With Quote #2

Their use is entirely dependent on the specific callback you're working with, and most callbacks will document the functionality of each meaningful return value.

There are generalized guidelines for what they do, but in the end they're meaningless without a specific function case. And those guidelines are probably what you've read in the wiki.
__________________
egg
BAILOPAN is offline
kirewv
Senior Member
Join Date: Oct 2007
Old 03-24-2008 , 16:56   Re: NEEDED: Decent, Thorough explaination of returns?
Reply With Quote #3

How about a couple of simple examples for each with detailed //notes in the code as to what happens

please
kirewv is offline
KMFrog
Senior Member
Join Date: Oct 2007
Old 03-24-2008 , 17:40   Re: NEEDED: Decent, Thorough explaination of returns?
Reply With Quote #4

Take the example hooked events normally sent to clients.
In this e.g. I will use kill events.

Quote:
player1<123><STEAM_0:1:2321> killed player2<456><STEAM_1:0:43433> with a toaster (headshot)
Which when hooked in code, would look like this:

Code:
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{

}
When you have finished what ever you want to do with this hooked event, for example, play a sound of someone getting hit by a toaster, then you can tell sourcemod what to do to finish it all off.

In the case of Plugin_continue, SM would run your code and send the "killed" event to all the players as normal.

In the case of Plugin_handled, SM would understand that your code has handled the event, so it should not send the event to clients. If you did this in the "killed" hook, the player would still die, but none of the clients would see it on their screens.

Plugin_stop is a rare one, I think it should be used with timers and/or threads to stop them (please correct me if I'm wrong) - not typically used with events so my example is bad for this one ;]

But the same applies to all the times you can return one of these three. If its for hooking a command instead of an event and you return plugin_handled then SM understands that your code in the hooked command has handled everything and stops the original command...

I hope that clears it up a bit
__________________
Was I helpful or not? Rate Me!
KMFrog is offline
kirewv
Senior Member
Join Date: Oct 2007
Old 03-24-2008 , 19:32   Re: NEEDED: Decent, Thorough explaination of returns?
Reply With Quote #5

That is useful TY. in the last part of your post "SM understands that your code in the hooked command has handled everything and stops the original command"

stops the original command?

Do you mean just breaks out of the function when return Plugin_Handled; is in the code?
kirewv is offline
BAILOPAN
Join Date: Jan 2004
Old 03-24-2008 , 20:31   Re: NEEDED: Decent, Thorough explaination of returns?
Reply With Quote #6

returns always immediately exit the function and pass the return value to the caller

KMFrog I think you're right about Plugin_Stop, it tends to be a rare find
__________________
egg
BAILOPAN is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:17.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode