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

Return.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Moody92
Veteran Member
Join Date: May 2011
Location: Oman
Old 07-07-2013 , 06:08   Return.
Reply With Quote #1

Hello guys,

I don't know why but I still don't get
PHP Code:
return 
even though I read so many articles

so I actually understand

PHP Code:
return PLUGIN_HANDLED 
and

PHP Code:
return PLUGIN_CONTINUE 
but I saw in some scripts there is

PHP Code:
return 
&
PHP Code:
return -
&
PHP Code:
return Random-Number 
so could someone explain to me how does random number return works ?
Moody92 is offline
Serkan Kischa
Member
Join Date: Dec 2012
Old 07-07-2013 , 06:09   Re: Return.
Reply With Quote #2

nope
Serkan Kischa is offline
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 07-07-2013 , 06:39   Re: Return.
Reply With Quote #3

I'm horrible in explaining
PHP Code:
// In stocks we just return any number that fits our needs
stock IsUserAliveExampleStock(id)
{
    if(
is_user_alive(id))
    {
        return 
1;
    }
    
    return 
0;
}

public Function(
id)
{
    
// iReturn will hold the value that was returned in the stock
    
new iReturn IsUserAliveExampleStock(id)
    if(
iReturn == 0)
    {
        
console_print(id"You must be alive to use this fuction")
        
        
// This type of return just stops further code,and returns the default return number
        
return;
    }
}

/* If you look in amxconst.inc, you would find these
#define PLUGIN_CONTINUE        0
#define PLUGIN_HANDLED        1
#define PLUGIN_HANDLED_MAIN    2

So you can see that PLUGIN_HANDLED, PLUGIN_CONTINUE and PLUGIN_HANDLED_MAIN are just defines to numbers
and are replaced when the script is compiled to the numbers.
*/ 
__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
No longer active in AMXX. Sorry.

Last edited by pokemonmaster; 07-07-2013 at 06:40.
pokemonmaster is offline
Moody92
Veteran Member
Join Date: May 2011
Location: Oman
Old 07-07-2013 , 06:55   Re: Return.
Reply With Quote #4

Quote:
Originally Posted by Serkan Kischa View Post
nope
Don't bother posting then

Quote:
Originally Posted by pokemonmaster View Post
I'm horrible in explaining
Spoiler
Thank you khalid... That was useful.
Moody92 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-07-2013 , 09:55   Re: Return.
Reply With Quote #5

use PLUGIN_*** when it improves readability and when it makes sense, so in amxx forwards and callbacks, because it means you want to block or not something.

Use true/false when functions are IsUserSomeThing or similar stuff that only return 0 or 1

And use values when functions are similar to get_user_team, get_user_maxspeed

For fakemeta and hamsandwich hooks, use defined returns [HAM/FMRES]_[IGNORED/HANDLED/OVERRIDE/SUPERCEDE]
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 18:43.


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