Raised This Month: $ Target: $400
 0% 

CreateMultiForward questions.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
PreDominance
Member
Join Date: Jul 2014
Old 08-14-2014 , 01:49   CreateMultiForward questions.
Reply With Quote #1

Greetings,

I'm looking into making my Warcraft plugin more of an API style (after being told, quite literally, that using callfunc was shit), where each race is an entirely new plugin.

Each race needs to have several event-based actions. Many races will contain code that needs to be executed on a spawn event, for instance.

In order to execute a public function in every plugin at once (a function called, for instance, "event_spawn"), can I do something like...
neowarcraft.sma
PHP Code:
new spawnEvent;

public 
plugin_init()
{
    
register_plugin("MF Test""1.0""PreDominance");
    
RegisterHam("Ham_Spawn""player""event_spawn""1");
    
spawnEvent CreateMultiForward("event_spawn"ET_IGNOREFP_CELL);
}

public 
event_spawn(id
{
    new 
ret;
    if (!
ExecuteForward(spawnEventretid))
        return 
log_amx("Spawn forward execute error.");
    return 
ret;
}

public 
plugin_end()
{
    
DestroyForward(spawnEvent);

Undead Scourge.sma
PHP Code:
public plugin_init()
{
    
register_plugin("Race: Undead Scourge""1.0""PreDominance");
}

public 
event_spawn(id)
{
    
//Stuff
    
return PLUGIN_CONTINUE;

My next question is, what happens to those plugins that do not have a public event_spawn (i.e. races that do not need a spawn event)? That's fine to not have, right?

Last edited by PreDominance; 08-14-2014 at 02:15.
PreDominance is offline
 



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


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