mirror of
https://github.com/hermansimensen/eventqueue-fix.git
synced 2025-12-06 18:08:27 +00:00
Respect triggers wait-time
This commit is contained in:
parent
ba422d6c00
commit
52ede98c9f
@ -16,6 +16,8 @@
|
||||
#pragma semicolon 1
|
||||
|
||||
ArrayList g_aPlayerEvents[MAXPLAYERS+1];
|
||||
ArrayList g_aOutputWait[MAXPLAYERS+1];
|
||||
|
||||
bool g_bLateLoad;
|
||||
|
||||
enum struct event_t
|
||||
@ -29,6 +31,12 @@ enum struct event_t
|
||||
int outputID;
|
||||
}
|
||||
|
||||
enum struct entity_t
|
||||
{
|
||||
int outputID;
|
||||
float waitTime;
|
||||
}
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = PLUGIN_NAME,
|
||||
@ -73,6 +81,15 @@ public void OnClientPutInServer(int client)
|
||||
{
|
||||
g_aPlayerEvents[client].Clear();
|
||||
}
|
||||
|
||||
if(g_aOutputWait[client] == null)
|
||||
{
|
||||
g_aOutputWait[client] = new ArrayList(sizeof(entity_t));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_aOutputWait[client].Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClientDisconnect(int client)
|
||||
@ -82,6 +99,12 @@ public void OnClientDisconnect(int client)
|
||||
g_aPlayerEvents[client].Clear();
|
||||
delete g_aPlayerEvents[client];
|
||||
}
|
||||
|
||||
if(g_aOutputWait[client] != null)
|
||||
{
|
||||
g_aOutputWait[client].Clear();
|
||||
delete g_aOutputWait[client];
|
||||
}
|
||||
}
|
||||
|
||||
void LoadDHooks()
|
||||
@ -125,7 +148,8 @@ void LoadDHooks()
|
||||
DHookAddParam(addEventTwo, HookParamType_CBaseEntity);
|
||||
DHookAddParam(addEventTwo, HookParamType_Int);
|
||||
if(!DHookEnableDetour(addEventTwo, false, DHook_AddEventTwo))
|
||||
SetFailState("Couldn't enable AddEventTwo detour.");*/
|
||||
SetFailState("Couldn't enable AddEventTwo detour.");
|
||||
*/
|
||||
|
||||
Handle addEventThree = DHookCreateDetour(Address_Null, CallConv_THISCALL, ReturnType_Void, ThisPointer_Ignore);
|
||||
DHookSetFromConf(addEventThree, gamedataConf, SDKConf_Signature, "AddEventThree");
|
||||
@ -139,7 +163,6 @@ void LoadDHooks()
|
||||
if(!DHookEnableDetour(addEventThree, false, DHook_AddEventThree))
|
||||
SetFailState("Couldn't enable AddEventThree detour.");
|
||||
|
||||
|
||||
delete gamedataConf;
|
||||
}
|
||||
|
||||
@ -176,7 +199,6 @@ public MRESReturn DHook_AddEvent(Handle hParams)
|
||||
return MRES_Ignored;
|
||||
}
|
||||
|
||||
|
||||
public MRESReturn DHook_AddEventTwo(Handle hParams)
|
||||
{
|
||||
event_t event;
|
||||
@ -211,8 +233,34 @@ public MRESReturn DHook_AddEventThree(Handle hParams)
|
||||
#endif
|
||||
|
||||
if((event.activator < 65 && event.activator > 0))
|
||||
{
|
||||
float m_flWait = 0.0;
|
||||
if(!IsValidClient(event.caller))
|
||||
{
|
||||
m_flWait = GetEntPropFloat(event.caller, Prop_Data, "m_flWait");
|
||||
}
|
||||
|
||||
bool bFound;
|
||||
entity_t ent;
|
||||
for(int i = 0; i < g_aOutputWait[event.activator].Length; i++)
|
||||
{
|
||||
g_aOutputWait[event.activator].GetArray(i, ent);
|
||||
|
||||
if(ent.outputID == event.outputID)
|
||||
{
|
||||
bFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!bFound || ent.waitTime <= 0.0)
|
||||
{
|
||||
g_aPlayerEvents[event.activator].PushArray(event);
|
||||
|
||||
ent.outputID = event.outputID;
|
||||
ent.waitTime = m_flWait;
|
||||
g_aOutputWait[event.activator].PushArray(ent);
|
||||
}
|
||||
return MRES_Supercede;
|
||||
}
|
||||
|
||||
@ -221,6 +269,24 @@ public MRESReturn DHook_AddEventThree(Handle hParams)
|
||||
|
||||
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2])
|
||||
{
|
||||
float timescale = Shavit_GetClientTimescale(client) != -1.0 ? Shavit_GetClientTimescale(client) : Shavit_GetStyleSettingFloat(Shavit_GetBhopStyle(client), "speed");
|
||||
|
||||
for(int i = 0; i < g_aOutputWait[client].Length; i++)
|
||||
{
|
||||
entity_t ent;
|
||||
g_aOutputWait[client].GetArray(i, ent);
|
||||
|
||||
if(ent.waitTime <= 0.0)
|
||||
{
|
||||
g_aOutputWait[client].Erase(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
ent.waitTime -= GetTickInterval() * timescale;
|
||||
g_aOutputWait[client].SetArray(i, ent);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < g_aPlayerEvents[client].Length; i++)
|
||||
{
|
||||
event_t event;
|
||||
@ -240,7 +306,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
if(!strcmp("!activator", event.target, false))
|
||||
{
|
||||
targetEntity = event.activator;
|
||||
AcceptEntityInput(targetEntity, event.targetInput, event.activator, event.caller, event.outputID); //right now I'm setting the client as the caller, because sourcemod freaks out if the caller isn't a regular CBaseEntity.
|
||||
AcceptEntityInput(targetEntity, event.targetInput, event.activator, event.caller, event.outputID);
|
||||
}
|
||||
else if(!strcmp("!caller", event.target, false))
|
||||
{
|
||||
@ -249,8 +315,8 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int entity = 0; entity < GetMaxEntities()*2; entity++) {
|
||||
|
||||
for (int entity = 0; entity < GetMaxEntities(); entity++)
|
||||
{
|
||||
if (!IsValidEntity(entity)) {
|
||||
continue;
|
||||
}
|
||||
@ -258,15 +324,14 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
char buffer[64];
|
||||
GetEntPropString(entity, Prop_Data, "m_iName", buffer, 64);
|
||||
|
||||
if (!strcmp(event.target, buffer, false)) {
|
||||
if (!strcmp(event.target, buffer, false))
|
||||
{
|
||||
targetEntity = entity;
|
||||
AcceptEntityInput(targetEntity, event.targetInput, event.activator, event.caller, event.outputID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//AcceptEntityInput(targetEntity, event.targetInput, event.activator, event.caller, event.outputID); //right now I'm setting the client as the caller, because sourcemod freaks out if the caller isn't a regular CBaseEntity.
|
||||
|
||||
#if defined DEBUG
|
||||
PrintToChat(client, "Performing output: %s, %i, %i, %s %s, %i", event.target, targetEntity, event.caller, event.targetInput, event.variantValue, event.outputID);
|
||||
#endif
|
||||
@ -275,8 +340,6 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
||||
}
|
||||
else
|
||||
{
|
||||
float timescale = Shavit_GetClientTimescale(client) != -1.0 ? Shavit_GetClientTimescale(client) : Shavit_GetStyleSettingFloat(Shavit_GetBhopStyle(client), "speed");
|
||||
|
||||
event.delay -= GetTickInterval() * timescale;
|
||||
g_aPlayerEvents[client].SetArray(i, event);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user