1. Post #1
    Gold Member
    Spacetech's Avatar
    January 2006
    510 Posts
    gmsv_pvs allows you to master player-entity networking
    You can have full control on what entities the client will see and hear

    [release]
    Functions / Variables
    PVS_CONNECTED -- Just a random number, set to 26 from module.
    pvsSetUpdateTime(seconds) -- Set the update time for the pvs. Defaults to 1 second
    Player:UpdatePVS() -- Force a pvs update to a player
    
    hook.Add("SameInstance", "SameInstanceCheck", function(ply, ent)
        return bool -- true for ents to see each other, false to disallow them to see each other
    end)
    
    [/release]
    [release]
    Example

    require("pvs")
    
    -- Lets make sure all clients have time to actually recognise the player
    hook.Add("PlayerInitialSpawn", "PVSPlayerInitialSpawn", function(ply)
    	ply:SetColor(255, 255, 255, 0)
    	timer.Simple(5, function(ply) -- 5 seconds should be fine
    		if(IsValid(ply)) then
    			-- print("SetElasticity")
    			ply:SetColor(255, 255, 255, 255)
    			ply:SetElasticity(PVS_CONNECTED) -- Once this is set SameInstance will be called for the player
    		end
    	end, ply)
    end)
    
    -- Force update pvs for a player
    concommand.Add("pvs_update", function(ply)
    	ply:UpdatePVS()
    end)
    
    concommand.Add("pvs_setupdate", function(ply, cmd, args)
    	pvsSetUpdateTime(tonumber(args[1]))
    end)
    
    local Owner, Parent
    hook.Add("SameInstance", "SameInstanceCheck", function(ply, ent)
    	-- print(ply, ent)
    	
    	Owner = ent:GetOwner()
    	if(IsValid(Owner)) then
    		if(Owner == ply) then
    			return true
    		elseif(Owner:IsPlayer()) then
    			return false
    		end
    	end
    	
    	Parent = ent:GetParent()
    	if(IsValid(Parent)) then
    		if(Parent == ply) then
    			return true
    		elseif(Parent:IsPlayer()) then
    			return false
    		end
    	end
    	
    	return !ent:IsPlayer()
    end)
    
    [/release]
    [release]
    Notes

    The variable PVS_CONNECTED is used in a PlayerInitialSpawn hook.
    You must Player:SetElasticity(PVS_CONNECTED) to allow SameInstance hook checks to run for the player, otherwise a player may completely not exist for certain clients.
    [/release]
    [release]
    How it Works

    The module hooks onto the engine functions "CheckTransmit" and "EmitSound"

    CheckTransmit is ran every time a player's pvs is updated and when the server should send the client what it should see / what it should know exists.
    Every time CheckTransmit is ran it will check if it's time to update. If it's time to update it will run the given players ents within it's pvs through the SameInstance hook. After all the entities are ran through the hook the info is saved into a variable so if CheckTransmit is ran again before another update time it will use that last variable.

    EmitSound will use that variable to determine what a client should hear.
    [/release]
    [release]
    Download

    Source: http://spacetechmodules.googlecode.c...v_pvs/gmsv_pvs
    Windows: http://spacetechmodules.googlecode.c...e/gmsv_pvs.dll
    [/release]

    Special thanks to Darkspider and Train for the original code
    Reply With Quote Edit / Delete Reply United States Show Events Lua King Lua King x 7 (list)

  2. Post #2
    Microbe's Avatar
    March 2007
    21 Posts
    Glad you decided to release it. Will be very useful !

  3. Post #3
    Mr_Roberto's Avatar
    October 2008
    133 Posts
    haha you are on a roll spacetech

  4. Post #4
    Drew P. Richard's Avatar
    April 2010
    760 Posts
    I'm sorry for bumping this thread, I PM'ed Spacetech and he said he won't be able to work on it for a while, and told me to try asking here. Basically, whenever I try using this module it is crashing the server. I think it may have to do with one of the new updates. I was wondering if anyone could try to fix it?

  5. Post #5
    IS AWESOME@@@@@@@@@@

    January 2009
    968 Posts
    I'm sorry for bumping this thread, I PM'ed Spacetech and he said he won't be able to work on it for a while, and told me to try asking here. Basically, whenever I try using this module it is crashing the server. I think it may have to do with one of the new updates. I was wondering if anyone could try to fix it?
    Does it crash instantly? Do you have any mdmp files?
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Lua King Lua King x 1 (list)

  6. Post #6
    Drew P. Richard's Avatar
    April 2010
    760 Posts
    It crashes on when a player joins. Let me make it happen again and upload some crash dumps.

    Crash dump: http://filesmelt.com/dl/crash_srcds....5072131_1_.dmp

    Console before crash:
    Code:
    Mounting hl2.. OK
    Mounting cstrike.. OK
    Mounting dod.. Failed
    Mounting ep2.. Failed
    Mounting tf.. Failed
    Mounting episodic.. Failed
    Mounting hl2mp.. OK
    Mounting portal.. OK
    Mounting lostcoast.. Failed
    Mounting hl1.. Failed
    Mounting hl1mp.. Failed
    Mounting zeno_clash.. OK
    Garry's Mod server.dll Build #111 [Dec 18 2010 11:27:37]
    maxplayers set to 8
    Unknown command "sv_allow_wait_command"
    maxplayers set to 8
    Network: IP 216.18.219.164, mode MP, dedicated Yes, ports 27015 SV / 27005 CL
    Lua initialized (Lua 5.1)
    gm_viviparous Loaded!
    Viviparous Servers | Owner: Drew P. Richard
    gm_cmd has loaded!
    Error Vertex File for 'Humans\Group03\Female_01.mdl' checksum 1651350973 should be -1513987054
    Error Vertex File for 'Humans\Group03\Female_01.mdl' checksum 1651350973 should be -1513987054
    Error Vertex File for 'Humans\Group03\Female_02.mdl' checksum -877679977 should be 2029913059
    Error Vertex File for 'Humans\Group03\Female_02.mdl' checksum -877679977 should be 2029913059
    Error Vertex File for 'Humans\Group03\Female_03.mdl' checksum 240143532 should be 615020382
    Error Vertex File for 'Humans\Group03\Female_03.mdl' checksum 240143532 should be 615020382
    Error Vertex File for 'Humans\Group03\Female_04.mdl' checksum 1672347362 should be 1301134242
    Error Vertex File for 'Humans\Group03\Female_04.mdl' checksum 1672347362 should be 1301134242
    Error Vertex File for 'Humans\Group03\Female_06.mdl' checksum 590298028 should be -285173382
    Error Vertex File for 'Humans\Group03\Female_06.mdl' checksum 590298028 should be -285173382
    Error Vertex File for 'Humans\Group03\Female_07.mdl' checksum -1076405403 should be -710229447
    Error Vertex File for 'Humans\Group03\Female_07.mdl' checksum -1076405403 should be -710229447
    Error Vertex File for 'Humans\Group03\Male_01.mdl' checksum -229695971 should be -212341379
    Error Vertex File for 'Humans\Group03\Male_01.mdl' checksum -229695971 should be -212341379
    Error Vertex File for 'Humans\Group03\male_02.mdl' checksum -1451030114 should be -77034264
    Error Vertex File for 'Humans\Group03\male_02.mdl' checksum -1451030114 should be -77034264
    Error Vertex File for 'Humans\Group03\male_03.mdl' checksum 2003602517 should be -1034868466
    Error Vertex File for 'Humans\Group03\male_03.mdl' checksum 2003602517 should be -1034868466
    Error Vertex File for 'Humans\Group03\Male_04.mdl' checksum -1406767351 should be 100976022
    Error Vertex File for 'Humans\Group03\Male_04.mdl' checksum -1406767351 should be 100976022
    Error Vertex File for 'Humans\Group03\Male_05.mdl' checksum 1430913443 should be 1093669987
    Error Vertex File for 'Humans\Group03\Male_05.mdl' checksum 1430913443 should be 1093669987
    Error Vertex File for 'Humans\Group03\male_06.mdl' checksum -1040899698 should be 440869567
    Error Vertex File for 'Humans\Group03\male_06.mdl' checksum -1040899698 should be 440869567
    Error Vertex File for 'Humans\Group03\male_07.mdl' checksum 1372497916 should be -1469984080
    Error Vertex File for 'Humans\Group03\male_07.mdl' checksum 1372497916 should be -1469984080
    Error Vertex File for 'Humans\Group03\male_08.mdl' checksum 264500654 should be -587456159
    Error Vertex File for 'Humans\Group03\male_08.mdl' checksum 264500654 should be -587456159
    Error Vertex File for 'Humans\Group03\male_09.mdl' checksum -1185842804 should be -238698339
    Error Vertex File for 'Humans\Group03\male_09.mdl' checksum -1185842804 should be -238698339
    KeyValues Error: RecursiveLoadFromBuffer:  got EOF instead of keyname in file materials/models/weapons/w_models/soulslayer.m4a1/map3.vmt
    VertexLitGeneric, 
    KeyValues Error: RecursiveLoadFromBuffer:  got EOF instead of keyname in file materials/models/weapons/w_models/soulslayer.m4a1/map1.vmt
    VertexLitGeneric, 
    KeyValues Error: RecursiveLoadFromBuffer:  got EOF instead of keyname in file materials/models/weapons/w_models/soulslayer.m4a1/map2.vmt
    VertexLitGeneric, 
    KeyValues Error: RecursiveLoadFromBuffer:  got EOF instead of keyname in file materials/models/weapons/w_models/soulslayer.m4a1/map3.vmt
    VertexLitGeneric, 
    KeyValues Error: RecursiveLoadFromBuffer:  got EOF instead of keyname in file materials/models/weapons/w_models/soulslayer.m4a1/map1.vmt
    VertexLitGeneric, 
    KeyValues Error: RecursiveLoadFromBuffer:  got EOF instead of keyname in file materials/models/weapons/w_models/soulslayer.m4a1/map2.vmt
    VertexLitGeneric, 
    KeyValues Error: RecursiveLoadFromBuffer:  got EOF instead of keyname in file materials/models/weapons/w_models/soulslayer.m4a1/silencer.vmt
    VertexLitGeneric, 
    KeyValues Error: RecursiveLoadFromBuffer:  got EOF instead of keyname in file materials/models/weapons/w_models/soulslayer.m4a1/silencer.vmt
    VertexLitGeneric, 
    Sent a total of 863 client resources.
    LOADING PVS!
    gm_pvs: Programmed by Spacetech | Entity: 213 | hook.Call: 215 | EntIndex: 216
    Registering gamemode 'war' derived from 'base'
    ScriptEnforce is disabled
    Compressing lua files into data pack..
    Compression complete. 320 files. (0.152s)
    Executing dedicated server config file
    Connection to Steam servers successful.
       VAC secure mode is activated.
    Client "Drew P. Richard" connected (75.186.8.136:27005).
    Player [1][Drew P. Richard]	Player [1][Drew P. Richard]
    Code I am using:
    //PVS TEST
    
    MsgN("LOADING PVS!")
    require("pvs")
     
    -- Lets make sure all clients have time to actually recognise the player
    hook.Add("PlayerInitialSpawn", "PVSPlayerInitialSpawn", function(ply)
        ply:SetColor(255, 255, 255, 0)
        timer.Simple(5, function(ply) -- 5 seconds should be fine
            if(IsValid(ply)) then
               print("SetElasticity Test")
                ply:SetColor(255, 255, 255, 255)
                ply:SetElasticity(PVS_CONNECTED) -- Once this is set SameInstance will be called for the player
            end
        end, ply)
    end)
    
    hook.Add("SameInstance","SameInstanceCheck",function(ply,ent)
        print(ply, ent);
    	return true;
    end)
    

    It seems to call SameInstance just once before it crashes.

  7. Post #7
    Gold Member
    thejjokerr's Avatar
    December 2007
    2,090 Posts
    Could this module be used to stop people from getting the 'Reliable Snapshot Overflow' kick?
    Reply With Quote Edit / Delete Reply Netherlands Show Events Useful Useful x 1 (list)

  8. Post #8
    Gold Member

    July 2006
    1,951 Posts
    Does anyone have a working version of this module? It crashes me instantly. Here's a link to the dump, and the results from dumps.garrysmod.com. Below is the code that I used.

    function GM:SameInstance(ply, ent)
    	print("GM:SameInstance(", ply, ent, ")");
    	
    	return true;
    end
    Reply With Quote Edit / Delete Reply Finland Show Events Optimistic Optimistic x 1 (list)

  9. Post #9
    Mr.Thorn's Avatar
    July 2010
    201 Posts
    Yeah same, anyone? Any fix?

  10. Post #10
    Gold Member
    Spacetech's Avatar
    January 2006
    510 Posts
    Yeah same, anyone? Any fix?
    Me and voided looked into it, both of us can't figure out why it crashes.
    Reply With Quote Edit / Delete Reply United States Show Events Informative Informative x 3 (list)

  11. Post #11
    Mr.Thorn's Avatar
    July 2010
    201 Posts
    So no update coming anytime soon?

  12. Post #12
    Gold Member

    July 2006
    1,951 Posts
    Actually hold on - do you need to run this on a dedicated server?

    By looking at the code, it should error with "gm_pvs: You must run this on a dedicated server" if it's not a dedicated server, but it never seems to throw this error when I try to run it on my listen server.

  13. Post #13
    Gold Member
    Spacetech's Avatar
    January 2006
    510 Posts
    With the help of chrisaster the module now works again!
    I also renamed the module to gmsv_pvs
    Reply With Quote Edit / Delete Reply United States Show Events Lua King Lua King x 2Friendly Friendly x 1Agree Agree x 1 (list)

  14. Post #14
    Drew P. Richard's Avatar
    April 2010
    760 Posts
    I love you.
    Reply With Quote Edit / Delete Reply United States Show Events Friendly Friendly x 3Agree Agree x 1 (list)

  15. Post #15
    Odahilys's Avatar
    March 2009
    333 Posts
    Excuse me, Spacetech, but has anyone told you that you are worthy of a massive high five?
    Reply With Quote Edit / Delete Reply Germany Show Events Friendly Friendly x 5Agree Agree x 3Winner Winner x 1 (list)

  16. Post #16
    Gold Member

    July 2006
    1,951 Posts
    Awesome, thanks a lot!
    Reply With Quote Edit / Delete Reply Finland Show Events Friendly Friendly x 1 (list)

  17. Post #17
    Mr.Thorn's Avatar
    July 2010
    201 Posts
    Danke.
    Reply With Quote Edit / Delete Reply United Kingdom Show Events Friendly Friendly x 1 (list)

  18. Post #18
    Drew P. Richard's Avatar
    April 2010
    760 Posts
    It would appear that the new Source update has caused SameInstance to not even be called anymore, no errors are returned though. Could you please look into it plox?
    Reply With Quote Edit / Delete Reply United States Show Events Informative Informative x 1 (list)

  19. Post #19
    Buggzie's Avatar
    December 2009
    965 Posts
    So, you can make a timer to go through all the entities one by one, or a few at a time to prevent getting a an overflow kick, is this right?
    Reply With Quote Edit / Delete Reply Australia Show Events Dumb Dumb x 4 (list)

  20. Post #20
    Nexus435's Avatar
    July 2010
    1,458 Posts
    So, you can make a timer to go through all the entities one by one, or a few at a time to prevent getting a an overflow kick, is this right?
    I'm sorry, but you ask a lot of stupid questions.
    Reply With Quote Edit / Delete Reply United States Show Events Agree Agree x 2 (list)

  21. Post #21
    Buggzie's Avatar
    December 2009
    965 Posts
    I'm sorry, but you ask a lot of stupid questions.
    I appreciate your help, also it was one question you dumbass.

    What's this addon exactly do I was asking.
    Reply With Quote Edit / Delete Reply Australia Show Events Dumb Dumb x 2 (list)

  22. Post #22
    Drew P. Richard's Avatar
    April 2010
    760 Posts
    Read the first 2 lines of the OP.
    Reply With Quote Edit / Delete Reply United States Show Events Agree Agree x 1 (list)

  23. Post #23
    Nexus435's Avatar
    July 2010
    1,458 Posts
    Seems returning false only makes you not able to hear the entity.. but everything else seems unaffected?

  24. Post #24
    Gold Member
    Spacetech's Avatar
    January 2006
    510 Posts
    Seems returning false only makes you not able to hear the entity.. but everything else seems unaffected?
    It broke due to a source engine update and I have been unable to fix it.

  25. Post #25
    DylanWilson's Avatar
    January 2010
    272 Posts
    was this ever fixed? I have a need for it

  26. Post #26
    Nexus435's Avatar
    July 2010
    1,458 Posts
    I haven't used it in a while. Tell me whats wrong and I'll look into fixing it. The vmt indexes are probably wrong.

  27. Post #27
    TGiFallen's Avatar
    January 2010
    1,433 Posts
    this hook is added in the next version of gmod.

  28. Post #28
    Ruzza's Avatar
    December 2011
    1,137 Posts
    Is it possible to use this with util.Trace and see if theres a wall infront of the player before they can hear/see the entity behind the wall making wallhacks useless?

  29. Post #29
    Nexus435's Avatar
    July 2010
    1,458 Posts
    Is it possible to use this with util.Trace and see if theres a wall infront of the player before they can hear/see the entity behind the wall making wallhacks useless?
    On the next update I would say it is completely possible. Depends on what data is sent regardless of the hook.

  30. Post #30
    NightExcessive's Avatar
    July 2010
    20 Posts
    Does anyone have a version of this that's been updated for GMod 13?