Skip to content

Commit 8574172

Browse files
authored
Added forwards about caster registeration (#880)
1 parent af76377 commit 8574172

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

353 Bytes
Binary file not shown.

addons/sourcemod/scripting/caster_system.sp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@ bool forbidSelfRegister;
2929

3030
ConVar g_hDisableAddons;
3131

32+
GlobalForward g_hFWD_CasterRegistered;
33+
GlobalForward g_hFWD_CasterUnregistered;
34+
3235
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
3336
{
3437
CreateNative("IsClientCaster", Native_IsClientCaster);
3538
CreateNative("IsIDCaster", Native_IsIDCaster);
3639

40+
g_hFWD_CasterRegistered = new GlobalForward("OnCasterRegistered", ET_Ignore, Param_Cell);
41+
g_hFWD_CasterUnregistered = new GlobalForward("OnCasterUnregistered", ET_Ignore, Param_Cell);
42+
3743
RegPluginLibrary("caster_system");
3844
return APLRes_Success;
3945
}
@@ -232,6 +238,10 @@ Action Cast_Cmd(int client, int args)
232238
casterTrie.SetValue(buffer, true);
233239
CPrintToChat(client, "%t", "SelfCast1");
234240
CPrintToChat(client, "%t", "SelfCast2");
241+
242+
Call_StartForward(g_hFWD_CasterRegistered);
243+
Call_PushCell(client);
244+
Call_Finish();
235245
}
236246

237247
return Plugin_Handled;
@@ -257,6 +267,10 @@ Action Caster_Cmd(int client, int args)
257267
ReplyToCommand(client, "\x01%t", "RegCasterReply", target);
258268
CPrintToChat(target, "%t", "RegCasterTarget", client);
259269
CPrintToChat(target, "%t", "SelfCast2");
270+
271+
Call_StartForward(g_hFWD_CasterRegistered);
272+
Call_PushCell(target);
273+
Call_Finish();
260274
}
261275
else
262276
{
@@ -279,6 +293,10 @@ Action NotCasting_Cmd(int client, int args)
279293
CPrintToChat(client, "%t", "Reconnect1");
280294
CPrintToChat(client, "%t", "Reconnect2");
281295

296+
Call_StartForward(g_hFWD_CasterUnregistered);
297+
Call_PushCell(client);
298+
Call_Finish();
299+
282300
// Reconnection to disable their addons
283301
CreateTimer(3.0, Reconnect, client);
284302
}
@@ -303,6 +321,10 @@ Action NotCasting_Cmd(int client, int args)
303321
{
304322
CPrintToChat(target, "%t", "UnregCasterTarget", client);
305323
NotCasting_Cmd(target, 0);
324+
325+
Call_StartForward(g_hFWD_CasterUnregistered);
326+
Call_PushCell(target);
327+
Call_Finish();
306328
}
307329
ReplyToCommand(client, "\x01%t", "UnregCasterSuccess", target);
308330
}

addons/sourcemod/scripting/include/caster_system.inc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ native bool IsClientCaster(int client);
1818
*/
1919
native bool IsIDCaster(const char[] AuthID);
2020

21+
/**
22+
* Called when a client is registered as a caster
23+
*
24+
* @param Client index
25+
*
26+
* @noreturn
27+
*/
28+
forward void OnCasterRegistered(int client);
29+
30+
/**
31+
* Called when a client is unregistered as a caster
32+
*
33+
* @param Client index
34+
*
35+
* @noreturn
36+
*/
37+
forward void OnCasterUnregistered(int client);
38+
2139
public SharedPlugin __pl_caster_system =
2240
{
2341
name = "caster_system",

0 commit comments

Comments
 (0)