• gmsv_pvs - Master player-entity networking
    29 replies, posted
  • Avatar of Spacetech
  • gmsv_pvs allows you to master player-entity networking You can have full control on what entities the client will see and hear [release] [highlight]Functions / Variables[/highlight] [lua] 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) [/lua] [/release] [release] [highlight][url=https://spacetechmodules.googlecode.com/svn/trunk/examples/pvs.lua]Example[/url][/highlight] [lua] 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) [/lua] [/release] [release] [highlight]Notes[/highlight] 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] [highlight]How it Works[/highlight] 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] [highlight]Download[/highlight] Source: [url]http://spacetechmodules.googlecode.com/svn/trunk/gmsv_pvs/gmsv_pvs[/url] Windows: [url]http://spacetechmodules.googlecode.com/svn/trunk/gmsv_pvs/Release/gmsv_pvs.dll[/url] [/release] Special thanks to Darkspider and Train for the original code
  • Avatar of Drew P. Richard
  • 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?
  • [QUOTE=Drew P. Richard;27209164]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?[/QUOTE] Does it crash instantly? Do you have any mdmp files?
  • Avatar of Drew P. Richard
  • It crashes on when a player joins. Let me make it happen again and upload some crash dumps. Crash dump: [url]http://filesmelt.com/dl/crash_srcds.exe_20110105072131_1_.dmp[/url] 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] Code I am using: [lua] //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) [/lua] It seems to call SameInstance just once before it crashes.
  • Avatar of TheJjokerR
  • Could this module be used to stop people from getting the 'Reliable Snapshot Overflow' kick?
  • Does anyone have a working version of this module? It crashes me instantly. Here's [url=http://www.1337upload.net/files/crash_hl2.exe_20110312123345_1.rar]a link to the dump[/url], and [url=http://dumps.garrysmod.com/?view=3844248534]the results from dumps.garrysmod.com[/url]. Below is the code that I used. [lua]function GM:SameInstance(ply, ent) print("GM:SameInstance(", ply, ent, ")"); return true; end[/lua]
  • Avatar of Spacetech
  • [QUOTE=Mr.Thorn;28723360]Yeah same, anyone? Any fix?[/QUOTE] Me and voided looked into it, both of us can't figure out why it crashes.
  • 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.
  • Avatar of Spacetech
  • With the help of chrisaster the module now works again! I also renamed the module to gmsv_pvs
  • Avatar of Odahilys
  • Excuse me, Spacetech, but has anyone told you that you are worthy of a massive high five?
  • Avatar of Drew P. Richard
  • 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?
  • Avatar of Buggzie
  • 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?
  • Avatar of Nexus435
  • [QUOTE=Buggzie;29235877]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?[/QUOTE] I'm sorry, but you ask a lot of stupid questions.
  • Avatar of Buggzie
  • [QUOTE=Nexus435;29257141]I'm sorry, but you ask a lot of stupid questions.[/QUOTE] I appreciate your help, also it was one question you dumbass. What's this addon exactly do I was asking.
  • Avatar of Nexus435
  • Seems returning false only makes you not able to hear the entity.. but everything else seems unaffected?
  • Avatar of Spacetech
  • [QUOTE=Nexus435;30437141]Seems returning false only makes you not able to hear the entity.. but everything else seems unaffected?[/QUOTE] It broke due to a source engine update and I have been unable to fix it.
  • Avatar of Nexus435
  • 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.
  • Avatar of Ruzza
  • 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?
  • Avatar of Nexus435
  • [QUOTE=Ruzza;33667816]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?[/QUOTE] On the next update I would say it is completely possible. Depends on what data is sent regardless of the hook.