experimental fix for the tp lag
This commit is contained in:
parent
f55d664311
commit
6f03346018
@ -28,6 +28,8 @@ bool chat_cooldown = false;
|
|||||||
//admins & vips
|
//admins & vips
|
||||||
bool admins[MAXPLAYERS + 1];
|
bool admins[MAXPLAYERS + 1];
|
||||||
bool vips[MAXPLAYERS + 1];
|
bool vips[MAXPLAYERS + 1];
|
||||||
|
bool teleport_hook = false;
|
||||||
|
bool multiple_hook = false;
|
||||||
|
|
||||||
//socket for bot input
|
//socket for bot input
|
||||||
Handle global_socket;
|
Handle global_socket;
|
||||||
@ -57,6 +59,7 @@ public void OnPluginStart()
|
|||||||
|
|
||||||
//hooks
|
//hooks
|
||||||
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
|
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
|
||||||
|
HookEvent("round_end", Event_RoundEnd);
|
||||||
//UDP connection
|
//UDP connection
|
||||||
connect_socket();
|
connect_socket();
|
||||||
chat_cooldown = false;
|
chat_cooldown = false;
|
||||||
@ -232,8 +235,42 @@ public Action bot_chat_cooldown(Handle timer, any data)
|
|||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void unhookAll()
|
||||||
|
{
|
||||||
|
int entity_tp = MaxClients + 1;
|
||||||
|
int entity_mp = MaxClients + 1;
|
||||||
|
while((entity_mp = FindEntityByClassname(entity_mp, "trigger_multiple")) != -1)
|
||||||
|
{
|
||||||
|
char targetName[64];
|
||||||
|
GetEntPropString(entity_mp, Prop_Data, "m_iName", targetName, sizeof(targetName));
|
||||||
|
if (strlen(targetName) > 0)
|
||||||
|
{
|
||||||
|
UnhookSingleEntityOutput(entity_mp, "OnStartTouch", OnEntityOutPut_mp);
|
||||||
|
UnhookSingleEntityOutput(entity_mp, "OnTrigger", OnEntityOutPut_mp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while((entity_tp = FindEntityByClassname(entity_tp, "trigger_teleport")) != -1)
|
||||||
|
{
|
||||||
|
char targetName[64];
|
||||||
|
GetEntPropString(entity_tp, Prop_Data, "m_iName", targetName, sizeof(targetName));
|
||||||
|
if (strlen(targetName) > 0)
|
||||||
|
{
|
||||||
|
UnhookSingleEntityOutput(entity_tp, "OnStartTouch", OnEntityOutPut_tp);
|
||||||
|
UnhookSingleEntityOutput(entity_tp, "OnTrigger", OnEntityOutPut_tp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
teleport_hook = false;
|
||||||
|
multiple_hook = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
|
||||||
|
{
|
||||||
|
unhookAll();
|
||||||
|
}
|
||||||
|
|
||||||
public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast)
|
public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast)
|
||||||
{
|
{
|
||||||
|
unhookAll();
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
for (int i = 1; i <= MaxClients; i++)
|
||||||
if (IsValidClient(i) && !IsFakeClient(i))
|
if (IsValidClient(i) && !IsFakeClient(i))
|
||||||
{
|
{
|
||||||
@ -249,8 +286,8 @@ public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast
|
|||||||
GetEntPropString(entity_mp, Prop_Data, "m_iName", targetName, sizeof(targetName));
|
GetEntPropString(entity_mp, Prop_Data, "m_iName", targetName, sizeof(targetName));
|
||||||
if (strlen(targetName) > 0)
|
if (strlen(targetName) > 0)
|
||||||
{
|
{
|
||||||
HookSingleEntityOutput(entity_mp, "OnStartTouch", OnEntityOutPut_mp);
|
HookSingleEntityOutput(entity_mp, "OnStartTouch", OnEntityOutPut_mp, true);
|
||||||
HookSingleEntityOutput(entity_mp, "OnTrigger", OnEntityOutPut_mp);
|
HookSingleEntityOutput(entity_mp, "OnTrigger", OnEntityOutPut_mp, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while((entity_tp = FindEntityByClassname(entity_tp, "trigger_teleport")) != -1)
|
while((entity_tp = FindEntityByClassname(entity_tp, "trigger_teleport")) != -1)
|
||||||
@ -259,8 +296,8 @@ public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast
|
|||||||
GetEntPropString(entity_tp, Prop_Data, "m_iName", targetName, sizeof(targetName));
|
GetEntPropString(entity_tp, Prop_Data, "m_iName", targetName, sizeof(targetName));
|
||||||
if (strlen(targetName) > 0)
|
if (strlen(targetName) > 0)
|
||||||
{
|
{
|
||||||
HookSingleEntityOutput(entity_tp, "OnStartTouch", OnEntityOutPut_tp);
|
HookSingleEntityOutput(entity_tp, "OnStartTouch", OnEntityOutPut_tp, true);
|
||||||
HookSingleEntityOutput(entity_tp, "OnTrigger", OnEntityOutPut_tp);
|
HookSingleEntityOutput(entity_tp, "OnTrigger", OnEntityOutPut_tp, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,25 +313,50 @@ public void OnEntityOutPut_mp(const char[] output, int entity_index, int client,
|
|||||||
{
|
{
|
||||||
GetEntPropVector(client, Prop_Send, "m_vecOrigin", targethuman_teleported[i]);
|
GetEntPropVector(client, Prop_Send, "m_vecOrigin", targethuman_teleported[i]);
|
||||||
CreateTimer(6.0, reset_target_tp, client);
|
CreateTimer(6.0, reset_target_tp, client);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (is_bot_player(i) && i == client)
|
else if (is_bot_player(i) && i == client)
|
||||||
|
{
|
||||||
CreateTimer(0.1, reset_target_tp, client);
|
CreateTimer(0.1, reset_target_tp, client);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!multiple_hook)
|
||||||
|
{
|
||||||
|
multiple_hook = true;
|
||||||
|
UnhookSingleEntityOutput(entity_index, "OnStartTouch", OnEntityOutPut_mp);
|
||||||
|
UnhookSingleEntityOutput(entity_index, "OnTrigger", OnEntityOutPut_mp);
|
||||||
|
//experimental if unhooking very shortly solves tp lag
|
||||||
|
CreateTimer(0.2, reset_hook_mp, INVALID_HANDLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void OnEntityOutPut_tp(const char[] output, int caller, int client, float delay)
|
public void OnEntityOutPut_tp(const char[] output, int entity_index, int client, float delay)
|
||||||
{
|
{
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
for (int i = 1; i <= MaxClients; i++)
|
||||||
if (IsValidClient(i))
|
if (IsValidClient(i))
|
||||||
{
|
{
|
||||||
|
//i is an autismbot following this player
|
||||||
if (target_friend[i] == client)
|
if (target_friend[i] == client)
|
||||||
{
|
{
|
||||||
GetEntPropVector(client, Prop_Send, "m_vecOrigin", targethuman_teleported[i]);
|
GetEntPropVector(client, Prop_Send, "m_vecOrigin", targethuman_teleported[i]);
|
||||||
CreateTimer(6.0, reset_target_tp, client);
|
CreateTimer(6.0, reset_target_tp, client);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (is_bot_player(i) && i == client)
|
else if (is_bot_player(i) && i == client)
|
||||||
|
{
|
||||||
CreateTimer(0.1, reset_target_tp, client);
|
CreateTimer(0.1, reset_target_tp, client);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!teleport_hook)
|
||||||
|
{
|
||||||
|
teleport_hook = true;
|
||||||
|
UnhookSingleEntityOutput(entity_index, "OnStartTouch", OnEntityOutPut_tp);
|
||||||
|
UnhookSingleEntityOutput(entity_index, "OnTrigger", OnEntityOutPut_tp);
|
||||||
|
//experimental if unhooking very shortly solves tp lag
|
||||||
|
CreateTimer(0.2, reset_hook_tp, INVALID_HANDLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,6 +591,18 @@ public bool is_bot_player(int client)
|
|||||||
return is_autism_bot1(client) || is_autism_bot2(client) || is_autism_bot3(client) || is_autism_bot4(client);
|
return is_autism_bot1(client) || is_autism_bot2(client) || is_autism_bot3(client) || is_autism_bot4(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Action reset_hook_mp(Handle timer, any data)
|
||||||
|
{
|
||||||
|
multiple_hook = false;
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action reset_hook_tp(Handle timer, any data)
|
||||||
|
{
|
||||||
|
teleport_hook = false;
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
|
|
||||||
public Action recursive_pressing(Handle timer, any data)
|
public Action recursive_pressing(Handle timer, any data)
|
||||||
{
|
{
|
||||||
bool found_valid_ct = false;
|
bool found_valid_ct = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user