mirror of
https://github.com/hermansimensen/eventqueue-fix.git
synced 2025-12-07 10:28:25 +00:00
Add Natives for getting and setting player events.
This commit is contained in:
parent
d1c4a5a2be
commit
871ded0400
@ -13,6 +13,7 @@
|
||||
#include <sdkhooks>
|
||||
#include <dhooks>
|
||||
#include <shavit>
|
||||
#include <eventqueuefix>
|
||||
|
||||
#pragma semicolon 1
|
||||
|
||||
@ -33,17 +34,6 @@ bool g_bLateLoad;
|
||||
Handle g_hFindEntityByName;
|
||||
int g_iRefOffset;
|
||||
|
||||
enum struct event_t
|
||||
{
|
||||
char target[64];
|
||||
char targetInput[64];
|
||||
char variantValue[64];
|
||||
float delay;
|
||||
int activator;
|
||||
int caller;
|
||||
int outputID;
|
||||
}
|
||||
|
||||
enum struct entity_t
|
||||
{
|
||||
int caller;
|
||||
@ -67,6 +57,11 @@ public void OnPluginStart()
|
||||
|
||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||
{
|
||||
CreateNative("GetClientEvents", Native_GetClientEvents);
|
||||
CreateNative("SetClientEvents", Native_SetClientEvents);
|
||||
|
||||
MarkNativeAsOptional("GetClientEvents");
|
||||
MarkNativeAsOptional("SetClientEvents");
|
||||
g_bLateLoad = late;
|
||||
|
||||
return APLRes_Success;
|
||||
@ -389,4 +384,37 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
g_aPlayerEvents[client].SetArray(i, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public any Native_GetClientEvents(Handle plugin, int numParams)
|
||||
{
|
||||
int client = GetNativeCell(1);
|
||||
if(!IsValidClient(client))
|
||||
return false;
|
||||
|
||||
eventpack_t ep;
|
||||
ep.playerEvents = view_as<ArrayList>(CloneHandle(g_aPlayerEvents[client].Clone()));
|
||||
ep.outputWaits = view_as<ArrayList>(CloneHandle(g_aOutputWait[client].Clone()));
|
||||
|
||||
SetNativeArray(2, ep, sizeof(eventpack_t));
|
||||
return true;
|
||||
}
|
||||
|
||||
public any Native_SetClientEvents(Handle plugin, int numParams)
|
||||
{
|
||||
int client = GetNativeCell(1);
|
||||
if(!IsValidClient(client))
|
||||
return false;
|
||||
|
||||
eventpack_t ep;
|
||||
GetNativeArray(2, ep, sizeof(eventpack_t));
|
||||
|
||||
delete g_aPlayerEvents[client];
|
||||
|
||||
ArrayList playerEvents = view_as<ArrayList>(CloneHandle(ep.playerEvents));
|
||||
|
||||
g_aPlayerEvents[client] = playerEvents.Clone();
|
||||
delete playerEvents;
|
||||
|
||||
return true;
|
||||
}
|
||||
42
scripting/include/eventqueuefix.inc
Normal file
42
scripting/include/eventqueuefix.inc
Normal file
@ -0,0 +1,42 @@
|
||||
#if defined _eventqueuefix_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _eventqueuefix_included
|
||||
|
||||
enum struct event_t
|
||||
{
|
||||
char target[64];
|
||||
char targetInput[64];
|
||||
char variantValue[64];
|
||||
float delay;
|
||||
int activator;
|
||||
int caller;
|
||||
int outputID;
|
||||
}
|
||||
|
||||
enum struct eventpack_t
|
||||
{
|
||||
ArrayList playerEvents;
|
||||
ArrayList outputWaits;
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets the current pending events for a client.
|
||||
*
|
||||
* @param client Client index.
|
||||
* @param eventpack Struct containg arrays for pending events and trigger cooldowns.
|
||||
*
|
||||
* @return True if successful, false otherwise.
|
||||
*/
|
||||
native any GetClientEvents(int client, any[] eventpack);
|
||||
|
||||
/*
|
||||
* Sets the current pending events for a client.
|
||||
*
|
||||
* @param client Client index.
|
||||
* @param eventpack Struct containg arrays for pending events and trigger cooldowns.
|
||||
*
|
||||
* @return True if successful, false otherwise.
|
||||
*/
|
||||
native any SetClientEvents(int client, any[] eventpack);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user