Checking if a player is dormant or not (LUA)

Hi, long ago someone posted code that would return true/false if a player was dormant. Currently IsDormant doesnt work, and I cannot find any other way to get it to work. I know of modules such as http://pastebin.com/mF5hN8LB but I wish to use pure lua, if possible.

dormant?

If a player is dormant it means they aren’t being networked to you (pretty sure this only affects position).

If you ever wall hacked or had something that goes through the wall, notice how a player stops moving after x distance? It means they’re dormant, its set this way by the engine. I wish to have a func that will return true or false on if they are or not.

Doesn’t Visible( ) return whether or not they’re in the PVS or not?

Ent.Visible is serverside and he wants this for his hax

visible =/= dormant. Different things.

Wish to try and eliminate lag client-side

Well, have you noticed that this hook gets called when an entity is no longer being updated on the client? :: EntityRemoved

It was the source of one of my networking bugs because I ran the code shared for when an entity is removed it would remove the networked information – when players left the area to the point you couldn’t see them / they wouldn’t update, it would call it and I’d lose their info; I had to make the system SERVER-side and network to the client when something is removed to “fix” it. I haven’t tried OnEntityCreated to see if it is fired when it comes back into view; but I’d imagine it would because it calls EntityRemoved when out of the area…

You could create a simple system which takes advantage of that:

[lua]// CLIENT-side…

//
local META_ENTITY = FindMetaTable( “Entity” );

//
//
//
function META_ENTITY:IsDormant( )
return self.__Dormant || false;
end

//
//
//
hook.Add( “EntityRemoved”, function( _ent )
_ent.__Dormant = true;
end );

//
//
//
hook.Add( “OnEntityCreated”, function( _ent )
_ent.__Dormant = false;
end );[/lua]