• Next Update v3 - Latest update is live
    973 replies, posted
Any reason this no longer exists? [url]http://wiki.garrysmod.com/page/Entity/GetNWVarTable[/url]
Probably from the new NWVars that got reverted and never fixed.
Just wondering, why isn't it possible to send a net message DIRECTLY from one client to another?
[QUOTE=MPan1;49011299]Just wondering, why isn't it possible to send a net message DIRECTLY from one client to another?[/QUOTE] I don't think clients have any direct connection, save for MAYBE some very specific exceptions that I don't know of (are there any?)
[QUOTE=MPan1;49011299]Just wondering, why isn't it possible to send a net message DIRECTLY from one client to another?[/QUOTE] You're connected to the server, not the other clients.
[lua] AddCSLuaFile() if DbgPrint == nil then DbgPrint = epoe.Print end SoundEnv = SoundEnv or { SoundCache = {}, Sounds = {}, InsideHook = false, Channels = { [CHAN_AUTO] = {}, [CHAN_WEAPON] = {}, [CHAN_VOICE] = {}, [CHAN_ITEM] = {}, [CHAN_BODY] = {}, [CHAN_STREAM] = {}, [CHAN_STATIC] = {}, [CHAN_VOICE2] = {}, [CHAN_VOICE_BASE] = {}, [CHAN_USER_BASE] = {}, }, } local function PlaySoundChannel(channel_data) --DbgPrint("Channel Data") --PrintTable(channel_data) local pos = nil if channel_data.Pos then pos = channel_data.Pos else if channel_data.Ent == game.GetWorld() or IsValid(channel_data.Ent) then pos = channel_data.Ent:GetPos() end end if pos == nil then return end channel_data.Snd:SetPos(pos) if channel_data.DistanceBased == true then DbgPrint("DistanceBased") end if channel_data.Flags == SND_NOFLAGS then channel_data.Snd:SetVolume(channel_data.Vol) channel_data.Snd:Play() else if bit.band(channel_data.Flags, SND_CHANGE_VOL) ~= 0 then DbgPrint("Changing volume: " .. tostring(channel_data.Vol)) channel_data.Snd:SetVolume(channel_data.Vol) end if bit.band(channel_data.Flags, SND_CHANGE_PITCH) == 0 then --snd:ChangePitch(pitch) end if bit.band(channel_data.Flags, SND_STOP) ~= 0 then --if snd:IsPlaying() == true then DbgPrint("Stopping") channel_data.Snd:Stop() --end end end end function SoundEnv:PlaySound(chanIndex, soundName, ent, vol, pitch, dsp, pos, soundTime, flags) flags = flags or 0 local spatialSound = false local distanceBased = false local prefix = string.sub(soundName, 1, 1) --DbgPrint("soundName: " .. soundName) --DbgPrint("Prefix: " .. prefix) if prefix == ")" then --DbgPrint("Spatial: true") spatialSound = true soundName = string.sub(soundName, 2) elseif prefix == "^" then --DbgPrint("DistanceBased: true") spatialSound = true soundName = string.sub(soundName, 2) end local channel = self.Channels[chanIndex] if channel == nil then DbgPrint("Unknown channel: " .. tostring(chanIndex)) return end local channel_data = channel[soundName] local createInstance = false if channel_data == nil then createInstance = true else if not IsValid(channel_data.Snd) or not channel_data.Snd:IsValid() then DbgPrint("Cleaning up instance") channel[soundName] = nil createInstance = true end if channel_data.Ent ~= nil and channel_data.Ent:IsValid() == false then if channel_data.Ent ~= game.GetWorld() then DbgPrint("Cleaning up instance: Entity invalid -> " .. tostring(channel_data.Ent)) channel[soundName] = nil createInstance = true end end end if createInstance == true then DbgPrint("Creating sound instance, caching " .. soundName) --snd = CreateSound(ent, soundName) local playFlags = "noblock" if spatialSound == false and chanIndex ~= CHAN_ITEM then playFlags = playFlags .. " 3d" else playFlags = playFlags .. " mono" end sound.PlayFile("sound/" .. soundName, playFlags, function(snd, errorId, errorName) if errorId then DbgPrint("Unable to play: " .. soundName .. " -> " .. tostring(errorId) .. ", " .. errorName) return end channel_data = { Spatial = spatialSound, DistanceBased = distanceBased, Ent = ent, Flags = flags, Vol = vol, Snd = snd, Pos = pos, Chan = chanIndex, } PlaySoundChannel(channel_data) -- Update table. channel[soundName] = channel_data self.Channels[chanIndex] = channel end) else channel_data.Pos = pos channel_data.Vol = vol channel_data.Ent = ent channel_data.Snd:SetTime(0) PlaySoundChannel(channel_data) -- Update table. channel[soundName] = channel_data self.Channels[chanIndex] = channel end end function SoundEnv:Think() local ply = LocalPlayer() local ang = ply:GetAngles() for _,chan in pairs(self.Channels) do for _,channel_data in pairs(chan) do if channel_data.Chan == CHAN_ITEM then continue end if channel_data.Ent == ply then --DbgPrint("Updateing player hearing") channel_data.Snd:Set3DCone(ang.p, ang.y, ang.r) end end end end if CLIENT then hook.Add("EntityEmitSound", "HL2CoopSoundEnv", function(t) if true then --return end if bit.band(t.Flags, SND_DO_NOT_OVERWRITE_EXISTING_ON_CHANNEL) ~= 0 then DbgPrint("Unsupported flag: SND_DO_NOT_OVERWRITE_EXISTING_ON_CHANNEL") return end if bit.band(t.Flags, SND_DELAY) ~= 0 then DbgPrint("Unsupported flags: SND_DELAY") return end --PrintTable(t) --DbgPrint("Overriding sound: " .. t.SoundName) SoundEnv:PlaySound(t.Channel, t.SoundName, t.Entity, t.Volume, t.Pitch, t.DSP, t.Pos, t.SoundTime, t.Flags) return false end) hook.Add("Think", "HL2CoopSoundEnv", function() SoundEnv:Think() end) end [/lua] Can I have DSPs please? Pitch for starters would be lovely.
:snip:
[QUOTE=Z0mb1n3;49011904]do you mean this? [url]https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index67df-2.html[/url][/QUOTE] No
[QUOTE=MPan1;49011299]Just wondering, why isn't it possible to send a net message DIRECTLY from one client to another?[/QUOTE] Clients aren't connected to each other, so the server has to relay the message. Although, if you want, you [i]could[/i] simulate this in Lua. Something along the lines of: [code] -- server-side function DefineClientToClientMessage(name) util.AddNetworkString(name) net.Receive(name, function(length) local target = net.ReadEntity() -- read the rest of the message, then forward it to 'target'... I'm not writing the full code, this is just a rough outline end) end -- client-side function StartClientToClientMessage(name, target) net.Begin(name) net.WriteEntity(target) end [/code] Usage: [code] -- server-side DefineClientToClientMessage("test message") -- client-side net.Receive("test message", function(len) -- read the message and do stuff with it end) -- client-side, to send a message StartClientToClientMessage("test message", other_player) -- write stuff here with the net.Write functions net.SendToServer() -- if the word "server" here bothers you, wrap it in another function [/code]
[QUOTE=immibis;49013525]Clients aren't connected to each other, so the server has to relay the message. Although, if you want, you [i]could[/i] simulate this in Lua. Something along the lines of: [code] -- server-side function DefineClientToClientMessage(name) util.AddNetworkString(name) net.Receive(name, function(length) local target = net.ReadEntity() -- read the rest of the message, then forward it to 'target'... I'm not writing the full code, this is just a rough outline end) end -- client-side function StartClientToClientMessage(name, target) net.Begin(name) net.WriteEntity(target) end [/code] Usage: [code] -- server-side DefineClientToClientMessage("test message") -- client-side net.Receive("test message", function(len) -- read the message and do stuff with it end) -- client-side, to send a message StartClientToClientMessage("test message", other_player) -- write stuff here with the net.Write functions net.SendToServer() -- if the word "server" here bothers you, wrap it in another function [/code][/QUOTE] It's a really bad idea to have this function available to the clients and especially bad to have dynamic writing and reading. Just relay it through the server with the correct checks like you normally would. With this function, you can use a Lua decompressor to find clientside code on the server your connected to and open menus your not supposed to be opening (that a good coder would know to make sure they add IsAdmin checkers to every net message on), change data client to client they're not supposed to be changing that could even be malicious at times and open up the other client to some worse effects if there's code that's really, really shit. And yes, the clients can just do net.Receivers["whatever"]() but only voluntarily. If you're going to do this, do it right. Add the correct checkers and only whitelist/use specific net messages.
[QUOTE=(AMS-$)ILOVEPIE;49010576]no you don't need the source code for gmod, you can detour or vtable hook the functions to point to your own code.[/QUOTE] Detouring and hooking awesomiums functions is quite a bother. If you want to have it easier, try basing it of this [url]https://github.com/Leystryku/die_awesomium/[/url]. [QUOTE=Handsome Matt;49011580]An updated Steamworks API with proper bindings would allow something like this.[/QUOTE] Actually, it would be quite easy to add support for packages from other sources than the server ( even without steamworks ). However, clients having other clients IP's sounds like a really bad idea for a game like garrysmod ( worse than in the old player_connect days ). Being able to send raw data directly between the client-server however would be pretty rad, easy to do and opens a lot of new possibilities ( users wouldn't have to deal with any of gmod's networking limitations anymore ).
[code] * Fixed combine mines not detecting players in Single Player ( And player in the last player slot in multiplayer ) * Fixed util.TraceLine and Entity:FireBullets not hitting player hitboxes outside of their hull if there is a prop behind said hitbox * Added new soundscript stuff from TF2 update & new map icons * Added CreateParticleSystem( Entity e, string eff, int PartAttachment, int EntAttachment = 0, Vector offset = 0 ) - returns CNewParticleEffect * Added CNewParticleEffect.IsValid() * Added CNewParticleEffect.SetControlPoint( int cpID, Vector offset ) * Added CNewParticleEffect.SetControlPointOrientation( int cpID, Vector fwd, Vector right, Vector up ) * Added CNewParticleEffect.SetSortOrigin( Vector origin ) * Added CNewParticleEffect.GetEffectName() - Returns string * Added CNewParticleEffect.StartEmission( bInfiniteOnly = false ) * Added CNewParticleEffect.StopEmission( bInfiniteOnly = false, bRemoveAllParticles = false, bWakeOnStop = false ) * Added CNewParticleEffect.GetOwner() - returns entity from CreateParticleSystem * Added CNewParticleEffect.AddControlPoint( int cpID, Entity ent, int PartAttachment, int EntAttachment = 0, Vector offset = 0 ) * Added CNewParticleEffect.StopEmissionAndDestroyImmediately() [/code] Latest stuff. I don't know when it will arrive on Dev, since the Linux build server is dead again. [editline]30th October 2015[/editline] All new functions are Clientside only.
[QUOTE=Robotboy655;49014316]-CNewParticleEffect-[/QUOTE] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/CreateParticleEffect]Entity:CreateParticleEffect[/url] should return this object as well.
[QUOTE=Jvs;49014616][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/CreateParticleEffect]Entity:CreateParticleEffect[/url] should return this object as well.[/QUOTE] It cannot due to the fact that it uses util.Effect internally to create the particle effect, that's why there's a new function to create them in the first place. [editline]30th October 2015[/editline] Oh wait, never mind, that function actually doesn't use util.Effect, the global ones do.
And maybe add even an Entity:GetAllParticles(), which goes over through entity->ParticleProp()->m_ParticleEffects and returns them in a table ( you can just use the pParticleEffect contained in ParticleEffectList_t ), just in case there's some particles which have been fired with the global functions that you mentioned above ( which do fire and forget ) and we want to handle them. Clientside still, of course.
[QUOTE=Robotboy655;49014316][code] * Added CNewParticleEffect.StopEmissionAndDestroyImmediately() [/code] Latest stuff. I don't know when it will arrive on Dev, since the Linux build server is dead again. [editline]30th October 2015[/editline] All new functions are Clientside only.[/QUOTE] wait wait wait, do you mean we can destroy particles that doesn't have emitters? Like most of tf2's unusual effects?! Edit: Fucking yes, now you can delete ghost particles!!!!
[img]http://i.imgur.com/2QO8uym.png[/img]
Can we have a fix for this? [lua] if CLIENT then game.AddParticles("particles/item_fx.pcf") PrecacheParticleSystem("duel_blue") PARTICLE = CreateParticleSystem(LocalPlayer(),"duel_blue",4,1) end [/lua] Reloading a file with this, where a particles has been created before (Even with old particle creation methods) will cause a crash without reason
How does lua_error_url work and what does it do? I tried messing around with it today and couldn't get anything from it and the help command doesn't do anything either. It would be nice if it could be used as a way to create an easy way to view everyone's lua errors.
[QUOTE=meharryp;49017698]How does lua_error_url work and what does it do? I tried messing around with it today and couldn't get anything from it and the help command doesn't do anything either. It would be nice if it could be used as a way to create an easy way to view everyone's lua errors.[/QUOTE] Pretty sure it sends HTTP requests with data about the error to the given URL.
[QUOTE=meharryp;49017698]How does lua_error_url work and what does it do? I tried messing around with it today and couldn't get anything from it and the help command doesn't do anything either. It would be nice if it could be used as a way to create an easy way to view everyone's lua errors.[/QUOTE] Essentially it fires a post request at whatever URL you specify and both clientside and server errors will get fired to that link. Post variables being - hash, error, stack, realm, addon, os and ds (dedicated server). The only real issue it has at the moment is that if a player disconnects and enters singleplayer you can end up with errors from addons / scripts they have on their client and not on your server.
Too bad that global error reporting thing (errors.garrysmod.com) we had went down a while ago.
[QUOTE=Teddi Orange;49018303]Essentially it fires a post request at whatever URL you specify and both clientside and server errors will get fired to that link. Post variables being - hash, error, stack, realm, addon, os and ds (dedicated server). The only real issue it has at the moment is that if a player disconnects and enters singleplayer you can end up with errors from addons / scripts they have on their client and not on your server.[/QUOTE] In that case you can probably just check the ds value before inputting it in to whatever.
[QUOTE=meharryp;49020495]In that case you can probably just check the ds value before inputting it in to whatever.[/QUOTE] You can however if you want to capture errors from the client the ds flag will be 0 as opposed to 1. Usually the easy way to filter out the majority of errors is to check if the addon field is populated. Okay it means you can't filter if workshop addons are being naughty but that's where the majority of errors (I found at least) came from when this bug occurred. I did file a report on github about this a while back but it's yet to be fixed.
The best method is to use the lua error module found somewhere, it picks up clientside errors aswell (even if only hosted on the server). I tried using lua_error_url but it's far too unreliable and it seems to ignore sending sometimes and whatnot.
[QUOTE=Grocel;49020191]Too bad that global error reporting thing (errors.garrysmod.com) we had went down a while ago.[/QUOTE] Same can be said about [url]http://dumps.garrysmod.com/[/url] ,even though Python1320 provides a alternative ( [url]http://dumps.metastruct.uk.to/[/url] ). :v
[code] * Fixed Combine Mine leaving looping sound behind if removed while the sound is playing * Fixed a bug with Bugbait and Grenade weapons where you can have both stuck in unusable state * Fixed SF_TRIG_TOUCH_DEBRIS not working in any tigger entity * Fixed Weapon.GetActivity() not returning any values * Added Weapon.GetWeaponViewModel() - returns string * Added Weapon.GetWeaponWorldModel() - returns string * Added Weapon.GetWeight() - returns int * Added Weapon.HasAmmo() - returns bool * Added Weapon.AllowsAutoSwitchTo() - returns bool * Added Weapon.AllowsAutoSwitchFrom() - returns bool[/code] Latest changes.
[QUOTE=BillyOnWiiU;49013895] If you're going to do this, do it right. Add the correct checkers and only whitelist/use specific net messages.[/QUOTE] What? It does only relay specific messages. That's what DefineClientToClientMessage is for on the server. It should be fairly obvious that if you're using the server as a dumb relay, then clients need to properly validate what they receive. That's related to the general idea, not my suggested way to do it. Btw, I'd also recommend having the server tell the receiving client which client sent the message.
[vid]http://www.aritzcracker.ca/uploads/aritz/Garry's%20Mod%202015-11-01%2011_13_49%20AM.mp4[/vid] [url]https://github.com/Facepunch/garrysmod-issues/issues/2279[/url] The hook works properly on the server, but not the client.
You are trying to fix your problem the wrong way around. I actually had encountered the problem just a few weeks ago and have come up with this solution: [url]https://github.com/garrynewman/garrysmod/commit/d8d8748d9fc8132edfbbbdedc30bbaf0a9820e3e[/url] It's simple enough to use, just do not use stecil calls while the function points to your entity: [code]if ( halo.RenderedEntity() == self ) then return end[/code]
Sorry, you need to Log In to post a reply to this thread.