Nuclide
Software Development Kit for id Technology (BETA)
ncAddonDelegate Class Reference

About this class

This is a delegate class for individual active AddonC plugins.

Overview

These are dynamic server-side plugins, added on top of the current game. They can also be removed at any time. This is similar to MetaMod. Just integrated right into the SDK.

Loading/Unloading Plugins

You can load a plugin using a series of commands.

addon load [name]

Attempts to load the addon plugin at <gamedir>/plugins/[name].dat.

addon close [name]

Unloads the named addon plugin.

addon list

Lists the active addon plugins.

Implementing Plugins

Example AddonC

Here's an example "Hello world!" style plugin.

It is located under src/plugins/helloworld.qc:

#pragma target fte_5768
#pragma PROGS_DAT "../../base/plugins/helloworld.dat"
#include "../server/api.h"
var bool g_firstLoaded = false;
void
Plug_Load(void)
{
if (g_firstLoaded == false) {
printf("Hello world!\n");
g_firstLoaded = true;
} else {
printf("Hello again!\n");
}
}
void
Plug_Shutdown(void)
{
printf("See you again!\n");
}

Because the engine does not allow us to unload progs, you have to handle any shutdown logic yourself, plus remove any entities from the game if the game no longer needs them.

Class To Progs Callback Mappings

Left = class method, right = name of the callback function for you to implement in progs.

ncAddonDelegate::Load = Plug_Load
ncAddonDelegate::Shutdown = Plug_Shutdown
ncAddonDelegate::ConsoleCommand = Plug_ConsoleCommand
ncAddonDelegate::ClientCommand = Plug_ClientCommand
ncAddonDelegate::PlayerConnect = Plug_PlayerConnect
ncAddonDelegate::PlayerDisconnect = Plug_PlayerDisconnect
ncAddonDelegate::PlayerSpawn = Plug_PlayerSpawn
ncAddonDelegate::PlayerDeath = Plug_PlayerDeath
ncAddonDelegate::NPCDeath = Plug_NPCDeath

The underlying return values and parameters are inherited from its class counter-part.

Public Member Functions

void ncAddonDelegate (void)
 
virtual void Load (void)
 Overridable: Called when the plugin gets loaded. More...
 
virtual void Shutdown (void)
 Overridable: Called when the plugin gets unloaded. More...
 
virtual bool ConsoleCommand (ncPlayer, string)
 Overridable: Called when the server issues a console command. More...
 
virtual bool ClientCommand (ncClient, string)
 Overridable: Called when a client issues a client command. More...
 
virtual void PlayerConnect (ncPlayer)
 Overridable: Called when a ncPlayer joins the server. More...
 
virtual void PlayerDisconnect (ncPlayer)
 Overridable: Called when a ncPlayer leaves the server. More...
 
virtual void PlayerSpawn (ncPlayer)
 Overridable: Called when a ncPlayer spawns, called sometime after joining. More...
 
virtual void PlayerDeath (ncPlayer, ncEntity, ncEntity, string)
 Overridable: Called when a ncPlayer dies in the game. More...
 
virtual void NPCDeath (ncActor, ncEntity, ncEntity)
 Overridable:: Called when an NPC gets killed. More...
 
virtual void LinkProgs (void)
 Called to link functions defined within multiprogs with the delegate's methods. More...
 
nonvirtual ncAddonDelegate CreateFromProgs (string addonName, float progsHandle)
 Creates an addon delegate from a progs handle. More...
 
nonvirtual void Close (void)
 Closes the addon. More...
 
nonvirtual string Name (void)
 Returns the name of the addon. More...
 

Constructor & Destructor Documentation

◆ ncAddonDelegate()

void ncAddonDelegate::ncAddonDelegate ( void  )

Member Function Documentation

◆ ClientCommand()

bool ncAddonDelegate::ClientCommand ( ncClient  pl,
string  cmd 
)
virtual

Overridable: Called when a client issues a client command.

◆ Close()

void ncAddonDelegate::Close ( void  )

Closes the addon.

◆ ConsoleCommand()

bool ncAddonDelegate::ConsoleCommand ( ncPlayer  pl,
string  cmd 
)
virtual

Overridable: Called when the server issues a console command.

◆ CreateFromProgs()

ncAddonDelegate ncAddonDelegate::CreateFromProgs ( string  addonName,
float  progsHandle 
)

Creates an addon delegate from a progs handle.

Parameters
addonNameis the name of the addon. Required for look-up purposes.
progsHandleis the valid handle of a progs loaded via addprogs().

◆ LinkProgs()

void ncAddonDelegate::LinkProgs ( void  )
virtual

Called to link functions defined within multiprogs with the delegate's methods.

◆ Load()

void ncAddonDelegate::Load ( void  )
virtual

Overridable: Called when the plugin gets loaded.

◆ Name()

string ncAddonDelegate::Name ( void  )

Returns the name of the addon.

Generally the name (without extension) of the progs.

◆ NPCDeath()

void ncAddonDelegate::NPCDeath ( ncActor  npc,
ncEntity  attacker,
ncEntity  inflictor 
)
virtual

Overridable:: Called when an NPC gets killed.

◆ PlayerConnect()

void ncAddonDelegate::PlayerConnect ( ncPlayer  pl)
virtual

Overridable: Called when a ncPlayer joins the server.

◆ PlayerDeath()

void ncAddonDelegate::PlayerDeath ( ncPlayer  deadPlayer,
ncEntity  inflictor,
ncEntity  attacker,
string  weaponDef 
)
virtual

Overridable: Called when a ncPlayer dies in the game.

◆ PlayerDisconnect()

void ncAddonDelegate::PlayerDisconnect ( ncPlayer  pl)
virtual

Overridable: Called when a ncPlayer leaves the server.

◆ PlayerSpawn()

void ncAddonDelegate::PlayerSpawn ( ncPlayer  pl)
virtual

Overridable: Called when a ncPlayer spawns, called sometime after joining.

◆ Shutdown()

void ncAddonDelegate::Shutdown ( void  )
virtual

Overridable: Called when the plugin gets unloaded.


The documentation for this class was generated from the following files: