replaced HookEntityOutput with HookSingleEntityOutput for handling teleportation understanding

This commit is contained in:
christian 2022-01-02 23:25:52 +01:00
parent bc3c1e6ca5
commit f55d664311

View File

@ -57,11 +57,6 @@ public void OnPluginStart()
//hooks //hooks
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy); HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
HookEntityOutput("trigger_multiple", "OnTrigger", Trigger_Multiple);
HookEntityOutput("trigger_multiple", "OnStartTouch", Trigger_Multiple);
HookEntityOutput("trigger_teleport", "OnTrigger", trigger_teleport);
HookEntityOutput("trigger_teleport", "OnStartTouch", trigger_teleport);
//UDP connection //UDP connection
connect_socket(); connect_socket();
chat_cooldown = false; chat_cooldown = false;
@ -74,52 +69,18 @@ public void reset_target_human_tp_coord(int client)
targethuman_teleported[client][2] = 0.0; targethuman_teleported[client][2] = 0.0;
} }
public void trigger_teleport(const char[] output, int entity_index, int client, float delay)
{
if (IsValidEdict(entity_index))
for (int i = 1; i <= MaxClients; i++)
if (IsValidClient(i))
{
if (target_friend[i] == client)
{
GetEntPropVector(client, Prop_Send, "m_vecOrigin", targethuman_teleported[i]);
CreateTimer(6.0, reset_target_tp, client);
}
else if (is_bot_player(i) && i == client)
CreateTimer(0.1, reset_target_tp, client);
}
}
public void Trigger_Multiple(const char[] output, int entity_index, int client, float delay)
{
if (IsValidEdict(entity_index) && origin_command_check(entity_index))
{
for (int i = 1; i <= MaxClients; i++)
if (IsValidClient(i))
{
if (target_friend[i] == client)
{
GetEntPropVector(client, Prop_Send, "m_vecOrigin", targethuman_teleported[i]);
CreateTimer(6.0, reset_target_tp, client);
}
else if (is_bot_player(i) && i == client)
CreateTimer(0.1, reset_target_tp, client);
}
}
}
public bool origin_command_check(int entity_index) public bool origin_command_check(int entity_index)
{ {
int count_trigger = GetOutputCount(entity_index, "m_OnTrigger"); int count_trigger = GetOutputCount(entity_index, "m_OnTrigger");
int count_starttouch = GetOutputCount(entity_index, "m_OnStartTouch"); int count_starttouch = GetOutputCount(entity_index, "m_OnStartTouch");
for (int i = 0; i < count_trigger; i++) for (int i = 0; i < count_trigger; i++)
{ {
char buffer[generic_length]; char buffer[generic_length];
GetOutputParameter(entity_index, "m_OnTrigger", i, buffer, sizeof(buffer)); GetOutputParameter(entity_index, "m_OnTrigger", i, buffer, sizeof(buffer));
if (StrContains(buffer, "origin", true) != -1) if (StrContains(buffer, "origin", true) != -1)
return true; return true;
} }
for (int i = 0; i < count_starttouch; i++) for (int i = 0; i < count_starttouch; i++)
{ {
char buffer[generic_length]; char buffer[generic_length];
GetOutputParameter(entity_index, "m_OnStartTouch", i, buffer, sizeof(buffer)); GetOutputParameter(entity_index, "m_OnStartTouch", i, buffer, sizeof(buffer));
@ -280,6 +241,61 @@ public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast
target_enemy[i] = 0; target_enemy[i] = 0;
reset_target_human_tp_coord(i); reset_target_human_tp_coord(i);
} }
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)
{
HookSingleEntityOutput(entity_mp, "OnStartTouch", OnEntityOutPut_mp);
HookSingleEntityOutput(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)
{
HookSingleEntityOutput(entity_tp, "OnStartTouch", OnEntityOutPut_tp);
HookSingleEntityOutput(entity_tp, "OnTrigger", OnEntityOutPut_tp);
}
}
}
public void OnEntityOutPut_mp(const char[] output, int entity_index, int client, float delay)
{
if (IsValidEdict(entity_index) && origin_command_check(entity_index))
{
for (int i = 1; i <= MaxClients; i++)
if (IsValidClient(i))
{
if (target_friend[i] == client)
{
GetEntPropVector(client, Prop_Send, "m_vecOrigin", targethuman_teleported[i]);
CreateTimer(6.0, reset_target_tp, client);
}
else if (is_bot_player(i) && i == client)
CreateTimer(0.1, reset_target_tp, client);
}
}
}
public void OnEntityOutPut_tp(const char[] output, int caller, int client, float delay)
{
for (int i = 1; i <= MaxClients; i++)
if (IsValidClient(i))
{
if (target_friend[i] == client)
{
GetEntPropVector(client, Prop_Send, "m_vecOrigin", targethuman_teleported[i]);
CreateTimer(6.0, reset_target_tp, client);
}
else if (is_bot_player(i) && i == client)
CreateTimer(0.1, reset_target_tp, client);
}
} }
public void OnMapStart() public void OnMapStart()