PlayerVisibility: 5hz instead of every tick
This commit is contained in:
parent
9f6327e615
commit
795c329f16
@ -1,5 +1,4 @@
|
|||||||
#include <sourcemod>
|
#include <sourcemod>
|
||||||
#include <sdkhooks>
|
|
||||||
#include <dhooks>
|
#include <dhooks>
|
||||||
#undef REQUIRE_PLUGIN
|
#undef REQUIRE_PLUGIN
|
||||||
#include <zombiereloaded>
|
#include <zombiereloaded>
|
||||||
@ -19,6 +18,7 @@ public Plugin myinfo =
|
|||||||
|
|
||||||
// bool CBaseEntity::AcceptInput( const char *szInputName, CBaseEntity *pActivator, CBaseEntity *pCaller, variant_t Value, int outputID )
|
// bool CBaseEntity::AcceptInput( const char *szInputName, CBaseEntity *pActivator, CBaseEntity *pCaller, variant_t Value, int outputID )
|
||||||
Handle g_hAcceptInput;
|
Handle g_hAcceptInput;
|
||||||
|
Handle g_hThinkTimer;
|
||||||
|
|
||||||
ConVar g_CVar_MaxDistance;
|
ConVar g_CVar_MaxDistance;
|
||||||
ConVar g_CVar_MinFactor;
|
ConVar g_CVar_MinFactor;
|
||||||
@ -73,12 +73,25 @@ public void OnPluginStart()
|
|||||||
AutoExecConfig(true, "plugin.PlayerVisibility");
|
AutoExecConfig(true, "plugin.PlayerVisibility");
|
||||||
|
|
||||||
HookEvent("player_spawn", Event_Spawn, EventHookMode_Post);
|
HookEvent("player_spawn", Event_Spawn, EventHookMode_Post);
|
||||||
|
HookEvent("player_death", Event_Death, EventHookMode_Post);
|
||||||
|
|
||||||
for(int client = 1; client <= MaxClients; client++)
|
for(int client = 1; client <= MaxClients; client++)
|
||||||
{
|
{
|
||||||
if(IsClientInGame(client))
|
if(IsClientInGame(client))
|
||||||
OnClientPutInServer(client);
|
OnClientPutInServer(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_hThinkTimer = CreateTimer(0.2, Timer_Think, _, TIMER_REPEAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action Timer_Think(Handle timer)
|
||||||
|
{
|
||||||
|
for(int client = 1; client <= MaxClients; client++)
|
||||||
|
{
|
||||||
|
if(IsClientInGame(client))
|
||||||
|
DoClientThink(client);
|
||||||
|
}
|
||||||
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAllPluginsLoaded()
|
public void OnAllPluginsLoaded()
|
||||||
@ -88,6 +101,8 @@ public void OnAllPluginsLoaded()
|
|||||||
|
|
||||||
public void OnPluginEnd()
|
public void OnPluginEnd()
|
||||||
{
|
{
|
||||||
|
KillTimer(g_hThinkTimer);
|
||||||
|
|
||||||
for(int client = 1; client <= MaxClients; client++)
|
for(int client = 1; client <= MaxClients; client++)
|
||||||
{
|
{
|
||||||
if(IsClientInGame(client))
|
if(IsClientInGame(client))
|
||||||
@ -118,7 +133,6 @@ public void OnClientPutInServer(int client)
|
|||||||
g_Client_Alpha[client] = 255;
|
g_Client_Alpha[client] = 255;
|
||||||
g_Client_bEnabled[client] = true;
|
g_Client_bEnabled[client] = true;
|
||||||
|
|
||||||
SDKHook(client, SDKHook_PostThinkPost, OnPostThinkPost);
|
|
||||||
DHookEntity(g_hAcceptInput, false, client);
|
DHookEntity(g_hAcceptInput, false, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,6 +241,15 @@ public void Event_Spawn(Event event, const char[] name, bool dontBroadcast)
|
|||||||
CreateTimer(0.1, Timer_SpawnPost, client, TIMER_FLAG_NO_MAPCHANGE);
|
CreateTimer(0.1, Timer_SpawnPost, client, TIMER_FLAG_NO_MAPCHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Event_Death(Event event, const char[] name, bool dontBroadcast)
|
||||||
|
{
|
||||||
|
int client = GetClientOfUserId(GetEventInt(event, "userid"));
|
||||||
|
if(!client)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_Client_bEnabled[client] = false;
|
||||||
|
}
|
||||||
|
|
||||||
public Action Timer_SpawnPost(Handle timer, int client)
|
public Action Timer_SpawnPost(Handle timer, int client)
|
||||||
{
|
{
|
||||||
if(!IsClientInGame(client) || !IsPlayerAlive(client))
|
if(!IsClientInGame(client) || !IsPlayerAlive(client))
|
||||||
@ -252,7 +275,7 @@ public void ZR_OnClientHumanPost(int client, bool respawn, bool protect)
|
|||||||
g_Client_bEnabled[client] = true;
|
g_Client_bEnabled[client] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPostThinkPost(int client)
|
public void DoClientThink(int client)
|
||||||
{
|
{
|
||||||
if(!g_Client_bEnabled[client])
|
if(!g_Client_bEnabled[client])
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user