Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-14-2007, 08:07 PM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
Plugin class

PHP Code:
/****
This allows codes to be added to a weapon without
any further editing of the code itself.

(+) addPlugin( pluginType, pluginName, object, function )
  - Adds plugin to system
  - returns data from object.function( default )

(+) remPlugin( pluginType, pluginName )
  - removes plugin

(-) getPlugin( pluginType, default, pluginName )
  - Get the value from a plugin
  - If pluginName is set, from a specific Name

(-) getPlugins( pType )
  - returns Plugin with data
  - if pType is empty, return all plugins

example:
NPC1:
function onCreated()
  {
  NPC2.addPlugin( "listen", "hello", this, "sayHello" );
  }

public function sayHello( pDefault )
  {
  return "Hello";
  }

NPC2:
function listen()
  {
  temp.messages = plugin::getPlugin( "listen" );
  echo( m ); // Returns "Hello"
  }
****/

public function addPluginpTypepNameobjfunc )
  {
  if ( 
remPluginpTypepName ) )
    { 
// Removed old!
    
this.plugins.add( {pTypepNameobjfunc } );
    }

  return 
true;
  }

public function 
remPluginpTypepName )
  {
  for ( 
0this.plugins.size(); ++ )
    {
    if ( 
this.plugins[i][0] != pType )
      continue;
    if ( 
this.plugins[i][1] != pName )
      continue;
    
    
this.plugins.delete-- ); // deletes this index, next is same.
    
return true// Shouldn't have two copies...
    
}
  return 
true;
  }

function 
getPluginpTypepDefaultpName)
  {
  for ( 
pthis.plugins )
    {
    if ( 
pType != p[0] )
      continue;
    if ( 
pName != null && pName != p[1] )
      continue;

    
pDefault p[2].(@ p[3] )( pDefault );
    }

  return 
pDefault;
  }

function 
getPluginspType )
  {
  if ( 
pType == null )
    return 
this.plugins;

  for ( 
pthis.plugins )
    {
    if ( 
pType != p[0] )
      continue;
    
temp.plugins.add);
    }

  return 
temp.plugins;
  } 
Reply With Quote
 


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 +2. The time now is 04:17 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.