Raised This Month: $ Target: $400
 0% 

returning values


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Locks
Senior Member
Join Date: Sep 2005
Old 05-04-2006 , 22:51   returning values
Reply With Quote #1

What's the difference between

Code:
return
and
Code:
return PLUGIN_HANDLED

and
Code:
continue
Code:
return PLUGIN_CONTINUE
Locks is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 05-04-2006 , 23:04  
Reply With Quote #2

if you just use return it would be the same as using return PLUGIN_CONTINUE

plain continue is used to skip the rest of the code in a particular iteration of a loop and go to the next.

There is more in the wiki
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
VEN
Veteran Member
Join Date: Jan 2005
Old 05-05-2006 , 04:50  
Reply With Quote #3

Also search. There are a good explanation of return PLUGIN_*'s (by PM i think).
VEN is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 05-05-2006 , 08:53  
Reply With Quote #4

Quote:
Originally Posted by Suicid3
if you just use return it would be the same as using return PLUGIN_CONTINUE
Not exactly the same.

return; alone suggests that the function has no return value - it only suggests that you want to stop execution of the function. The fact that this acutally returns a zero (which, by chance, is what PLUGIN_CONTINUE is defined to) when used in a public function is an implementation detail.

Basically:
If a function has a return value (for your own (stock) function you can decide yourself, for public functions the host aplication (=AMXX) decides*), you should always use
Code:
return something
and also place such a return statement as the last one in the function (otherwise the compiler will moan).

If the function doesn't have a return value, it's not neccessary (and not encouraged) to put a single return at the end; and if you want to exit the function immediately, use
Code:
return


*) technically, all public functions have return a value to the host application. However, the host application can decide to ignore it. In that case the programmer should treat that function as a function without a return value - unless he wants to call it from his own code and return something; that's pretty unlikely though ;o
__________________
hello, i am pm
PM is offline
Urahara
Member
Join Date: Apr 2006
Old 05-05-2006 , 12:47  
Reply With Quote #5

Ohayo PM-san!

continue and break are used to cycle in loops; break jumps out of the loop while continue jumps to the next state in the loop cycle!

hope that is helpful to you lock-san!
__________________

Urahara's Shop is open! For all your needs:
http://urahara.amxmodx.org/forums/
Projects:
Ururu AntiCheat
MetaScript Library
Jinta Hax
Urahara is offline
Reply



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 05:12.


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