Raised This Month: $ Target: $400
 0% 

What is differance ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
senecas
Senior Member
Join Date: Jun 2006
Old 02-13-2009 , 19:31   What is differance ?
Reply With Quote #1

public fw_playerprethink(id)
{
if(!is_user_alive(id)) return

blabla code
}

or

public fw_playerprethink(id)
{
if(!is_user_alive(id)) return FMRES_IGNORED

blabla code
return FMRES_IGNORED
}


what is differance btw 'return' and 'return FMRES_IGNORED'
samething ?
senecas is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 02-13-2009 , 19:48   Re: What is differance ?
Reply With Quote #2

FMRES_* - in fakemeta forwards. (no only fm, can work in ham fw)
PLUGIN_* - in engine forwards or publics.

return - is equal to return PLUGIN_CONTINUE or return 0

Quote:
  • FMRES_HANDLED --> Something was done in this function, but call the one in the DLL / Engine anyways.
  • FMRES_SUPERCEDE --> Prevent function in DLL / Engine from being called.
  • FMRES_IGNORED --> Call original function.
  • FMRES_OVERRIDE --> Call original function, but change return value.
More info
PS: search before
__________________

anakin_cstrike is offline
senecas
Senior Member
Join Date: Jun 2006
Old 02-13-2009 , 19:59   Re: What is differance ?
Reply With Quote #3

but if I change first code to

public fw_playerprethink(id)
{
if(!is_user_alive(id)) return PLUGIN_CONTINUE

blabla code
}

like this , but this code is wrong.
I dont think "return" is exactly same "return PLUGIN_CONTINUE"
It shoud be

public fw_playerprethink(id)
{
if(!is_user_alive(id)) return

blabla code
return PLUGIN_CONTINUE <--
}

right ?
So I asked this things.
once I use return FMRES_IGNORED or return P LUGIN_CONTINUE at top of code,
there shoud be return FMRES_IGNORED or return PLUGIN_CONTINUE at bottom of code.

I want to know diiferance or benefit.
senecas is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 02-13-2009 , 22:24   Re: What is differance ?
Reply With Quote #4

in a fakemeta forward hook, you'd better always use the FMRES_ type as the return value.
return is not equal to return 0, return is just return nothing
code below will get a warning, although it get 0 as result
Code:
public test(id) //a command
{
    console_print(id, "%d", func())
    return PLUGIN_HANDLED
}
public func()
{
    return
}
you can do return nothing in a fm forward because the fakemeta use the default return value(FMRES_IGNORED) if the return value you provide is smaller than it.
so if you only return FMRES_IGNORED in a fm forward, you can use return;
other than that, you should always use FMRES_*
so for your case, the difference depend on the blabla code, if there is no other return type than FMRES_IGNORED, then your two case is the same thing. otherwise your first code is wrong, because in a function you can't use return; and return something; at the same time.
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 02-14-2009 , 07:42   Re: What is differance ?
Reply With Quote #5

Quote:
return is not equal to return 0, return is just return nothing
Opsss...i've made a mistake because i saw a long time ago a post wich said "return 0 or just return;"
__________________

anakin_cstrike is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 02-14-2009 , 10:06   Re: What is differance ?
Reply With Quote #6

Quote:
Originally Posted by jim_yang View Post
return is not equal to return 0, return is just return nothing
This is incorrect. Returning nothing assumes PLUGIN_CONTINUE by the engine.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Old 02-14-2009, 10:22
anakin_cstrike
This message has been deleted by anakin_cstrike. Reason: Nvm
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 17:01.


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