Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(API): Plugin status via forwards #19

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion addons/sourcemod/scripting/ProxyKiller.sp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Plugin myinfo =
name = PROXYKILLER_NAME,
author = "Sikari, .Rushaway, maxime1907",
description = "Kill them proxies!",
version = "2.3.2",
version = ProxyKiller_VERSION,
url = "https://github.com/srcdslab/sm-plugin-ProxyKiller"
};

Expand Down Expand Up @@ -88,9 +88,23 @@ public void OnPluginStart()

public void OnAllPluginsLoaded()
{
SendForward_Available();
CreateLists();
}

public void OnPluginPauseChange(bool pause)
{
if (pause)
SendForward_NotAvailable();
else
SendForward_Available();
}

public void OnPluginEnd()
{
SendForward_NotAvailable();
}

public void OnConfigsExecuted()
{
if (!ProxyKiller_Config_IsInit())
Expand Down
18 changes: 18 additions & 0 deletions addons/sourcemod/scripting/ProxyKiller/api/forwards.sp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// =========================================================== //

GlobalForward g_hForward_StatusOK;
GlobalForward g_hForward_StatusNotOK;

static Handle H_OnCache = null;
static Handle H_OnRules = null;
static Handle H_OnConfig = null;
Expand All @@ -21,6 +24,9 @@ static Handle H_OnClientPunishment = null;

void CreateForwards()
{
g_hForward_StatusOK = CreateGlobalForward("ProxyKiller_OnPluginOK", ET_Ignore);
g_hForward_StatusNotOK = CreateGlobalForward("ProxyKiller_OnPluginNotOK", ET_Ignore);

H_OnCache = CreateGlobalForward("ProxyKiller_OnCache", ET_Ignore);
H_OnRules = CreateGlobalForward("ProxyKiller_OnRules", ET_Ignore);
H_OnConfig = CreateGlobalForward("ProxyKiller_OnConfig", ET_Ignore);
Expand All @@ -41,6 +47,18 @@ void CreateForwards()

// =========================================================== //

stock void SendForward_Available()
{
Call_StartForward(g_hForward_StatusOK);
Call_Finish();
}

stock void SendForward_NotAvailable()
{
Call_StartForward(g_hForward_StatusNotOK);
Call_Finish();
}

void Call_OnCache()
{
Call_StartForward(H_OnCache);
Expand Down
21 changes: 21 additions & 0 deletions addons/sourcemod/scripting/include/ProxyKiller.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
#endif
#define _ProxyKiller_included_

#define ProxyKiller_V_MAJOR 2
#define ProxyKiller_V_MINOR 4
#define ProxyKiller_V_PATCH 0

#define ProxyKiller_VERSION "2.4.0"

// =========================================================== //

#include <StringMapEx>
Expand Down Expand Up @@ -303,6 +309,21 @@ native ResponseCompare ProxyKiller_Config_GetServiceResponseCompare();

// =========================================================== //

/**
* Called when the plugin becomes available.
*
* @noreturn
*/
forward void ProxyKiller_OnPluginOK();

/**
* Called when the plugin becomes unavailable.
* This can happen when the plugin is reloaded or unloaded.
*
* @noreturn
*/
forward void ProxyKiller_OnPluginNotOK();

/**
* Called when the cache is initialized for ProxyKiller
*
Expand Down
Loading