Table of Contents

API Hooks

THIS SYSTEM HAS BEEN DEPRECATED IN 1.0.73, SUPPORT WILL BE REMOVED SOON

GSP-Panel has a hook system that allows developers to hook into core functions. In order to use hooks you will need to place your custom hook file into includes\hooks and then call add_hook, please view the example below.

Hooks are called in the order they are added. If you need to rearrange the hooks during another script you would need to call remove_hook(hookpoint, hookfunction); and then add_hook(hookpoint, hookfunction);

Hook Points

Hook Variables Return Description
servermon_start None None This is called when the server monitor is started
servermon_end None None This is called at the end of the server monitor
maintenance_optimize None None This is called during $Maintenance→Optimize();
game_query_replace Array of game information Array of game information This is called when a game is queried for the status
addon_installed Users game ID, Addon ID None This is called after an add install has completed
game_suspended Users game ID None This is called after a game server is suspended
game_unsuspended Users game ID None This is called after a game server is unsuspended
gameinstall_finished Users game ID None This is called after the user's game has been installed
backup_completed Users game ID None This is called after a user's game has been backed up

Example

Here is our hook file that will be placed in includes\hooks\example.php

<?php
   function example_hook()
   {
        echo "This is our example hook that will be called during servermon_start";
   }
 
   function addon_email($ugid, $addonid)
   {
        // Lets load the emails class
        LoadClass("emails");
        global $emails;
 
        $addons = array("4");
        // If the addon is in the above array, send an email
        if (in_array($addonid, $addons))
        {
            $emails->SendMail(array("subject" => "test", "content" => "your content", "email" => "[email protected]"));
        }
   }
   add_hook("servermon_start", "example_hook");
   add_hook("addon_installed", "addon_email");
?>