Raised This Month: $ Target: $400
 0% 

How does return FMRES_SUPERCEDE; work in this plugin?


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Author Message
SubStream
Veteran Member
Join Date: Aug 2005
Location: USA
Old 03-18-2006 , 13:51   How does return FMRES_SUPERCEDE; work in this plugin?
#1

Code:
#include <amxmodx>
#include <fakemeta>

#define	PLUGIN		"Silent Assault"
#define	VERSION		"0.1"
#define	AUTHOR		"v3x"

public plugin_init()
{
  register_plugin(PLUGIN, VERSION, AUTHOR);
  register_forward(FM_EmitSound, "EmitSound");
}

#define MAX_SOUNDS	20

new g_szSnds[MAX_SOUNDS][] =
{
  "doors/doormove2.wav",
  "doors/doormove9.wav",
  "doors/doormove10.wav",
  "doors/doorstop4.wav",
  "debris/bustmetal1.wav",
  "debris/bustmetal2.wav",
  "debris/metal1.wav",
  "debris/metal2.wav",
  "debris/metal3.wav",
  "debris/metal4.wav",
  "debris/metal5.wav",
  "debris/metal6.wav",
  "player/pl_duct1.wav",
  "player/pl_duct2.wav",
  "player/pl_duct3.wav",
  "player/pl_duct4.wav",
  "player/pl_ladder1.wav",
  "player/pl_ladder2.wav",
  "player/pl_ladder3.wav",
  "player/pl_ladder4.wav"
}

new bool:g_bActive = false;

public plugin_cfg()
{
  new szMap[64];
  get_mapname(szMap, 63);

  if(containi(szMap, "_assault") != -1)
  {
    g_bActive = true;
    server_print("[AMXX] Silent Assault: ON");
  }
  else
    server_print("[AMXX] Silent Assault: OFF");
}

public EmitSound(entity, channel, const sound[])
{
  if(g_bActive)
  {
    //client_print(0, 3, "[SA] Sound emitted: %s", sound);

    for(new iSnd = 0; iSnd < MAX_SOUNDS; iSnd++)
    {
      if(containi(sound, g_szSnds[iSnd]) != -1)
        return FMRES_SUPERCEDE;
    }
  }
  return FMRES_IGNORED;
}
return FMRES_SUPERCEDE; - First of all... why did v3x put a ; after that line? Secondly... it says FMRES_SUPERCEDE returns a value of 4... so does that mean that line means return 4???? I am confused how that stops the sound if it returns a value of 4... unless the tutorial is misleading...

I assume with the name SUPERCEDE tied to it that it means to supercede any other functions/whatever that may be called normally by the forward... and I assume the FMRES_IGNORED; means to ignore anything else that may be called such as the sounds??? yet in tutorial it says FMRES_IGNORED = 1... and why is there a ; there as well???

Can someone clear this up for me and explain what returning those values actually does and if I am right in my assumption of what they do... ty
__________________
If you're really bored, check out the plugins I've publicly released.
SubStream is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 03-18-2006 , 13:57  
#2

the semi-colon denotes a line end. It is not nessasary, but it looks nice.

FMRES_*'s denote what to tell MetaMod about the forward return type. IGNOR E means continue on past, HANDLE means stop here, SUPERCEDE means this return value and operation goes above all others, OVERRIDE means to override the value.

Look it up in the documentation before asking here; it saves time and effort.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 03-19-2006 , 05:12  
#3

Quote:
Originally Posted by Twilight Suzuka
the semi-colon denotes a line end. It is not nessasary, but it looks nice.

FMRES_*'s denote what to tell MetaMod about the forward return type. IGNOR E means continue on past, HANDLE means stop here, SUPERCEDE means this return value and operation goes above all others, OVERRIDE means to override the value.

Look it up in the documentation before asking here; it saves time and effort.
In fact, HANDLED doesn't mean much; it's only provided for other plugins to be able to see that you did something. Metamod handles (F)MRES_IGNORED/(F)MRES_HANDLED equally IIRC. Only SUPERCEDE actually stops the original function from being called; and you can't stop other plugins from seeing the function call.
__________________
hello, i am pm
PM is offline
Closed Thread



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 16:33.


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