• Problems That Don't Need Their Own Thread v5
    3,436 replies, posted
  • Solved it. I stored the getYo in a variable on the entity and was using that before but getting the value directly instead of the variable and now it works great Thank you everyone who helped
  • Avatar of code_gs
  • [QUOTE=MPan1;52765519]I still don't quite get what ENT.Type and ENT.Base and all those ENT variables actually do. Is there a list of them somewhere?[/QUOTE] Just want to note that ENT.Base is for inheritance purposes in Lua, and ENT.Type is for the engine to set the entity class internally.
  • Avatar of code_gs
  • [QUOTE=DarkDragonLov;52767665]How does one properly use the "HL1GaussBeam" effect?[/QUOTE] [url]https://github.com/VSES/SourceEngine2007/blob/43a5c90a5ada1e69ca044595383be67f40b33c61/se2007/game/client/hl1/hl1_fx_gauss.cpp#L35-L114[/url] Looks like it uses a hack to encode the entity index and attachment in one.
  • Avatar of DarkDragonLove
  • [QUOTE=code_gs;52767686][url]https://github.com/VSES/SourceEngine2007/blob/43a5c90a5ada1e69ca044595383be67f40b33c61/se2007/game/client/hl1/hl1_fx_gauss.cpp#L35-L114[/url] Looks like it uses a hack to encode the entity index and attachment in one.[/QUOTE] Helpful I guess, but I still don't know or understand how to use it through Lua in Garry's Mod. There's this, or what's the effect name for the cannon on the buggy?
  • Avatar of code_gs
  • [QUOTE=DarkDragonLov;52767737]Helpful I guess, but I still don't know or understand how to use it through Lua in Garry's Mod. There's this, or what's the effect name for the cannon on the buggy?[/QUOTE] [url]https://github.com/VSES/SourceEngine2007/blob/43a5c90a5ada1e69ca044595383be67f40b33c61/se2007/game/shared/hl1/hl1mp_weapon_gauss.cpp#L448-L456[/url] The variables for the data here correspond to [URL="https://wiki.garrysmod.com/page/Category:CEffectData"]EffectData[/URL] functions. With that, your Lua code will look like: [code]local data = EffectData() data:SetOrigin(end_position_of_beam) if (CLIENT) then data:SetEntity(Player) else data:SetEntIndex(pPlayer:EntIndex()) end --data:SetFlags(1) -- Enable for secondary fire beam util.Effect("HL1GaussBeam", data)[/code]
  • Avatar of residualgrub
  • So I am trying to use EmitSound to play sounds in rapid succession but each time it plays a sound it cuts off the previous sound early. Why is this and is there a way to get it to stop cutting off the previous sound? If not is there another sound function that will not cut the previous sound off? Note that I have a table of sounds I am choosing files from at random in the EmitSound function.
  • Avatar of code_gs
  • [QUOTE=residualgrub;52767808]So I am trying to use EmitSound to play sounds in rapid succession but each time it plays a sound it cuts off the previous sound early. Why is this and is there a way to get it to stop cutting off the previous sound? If not is there another sound function that will not cut the previous sound off? Note that I have a table of sounds I am choosing files from at random in the EmitSound function.[/QUOTE] It's probably your channel option in EmitSound -- iirc it can only play one sound per channel. If you want to play the sound in the world, EmitSound is your best option. If you just want to play it to the client with no regard to world position, you can use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/surface/PlaySound]surface.PlaySound[/url].
  • Avatar of residualgrub
  • [QUOTE=code_gs;52767831]It's probably your channel option in EmitSound -- iirc it can only play one sound per channel. If you want to play the sound in the world, EmitSound is your best option. If you just want to play it to the client with no regard to world position, you can use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/surface/PlaySound]surface.PlaySound[/url].[/QUOTE] Ya I have to play it in the world. So essentially the source engine has no set system for this in regards to playing sounds in the world?
  • Avatar of DarkDragonLove
  • [QUOTE=code_gs;52767801][url]https://github.com/VSES/SourceEngine2007/blob/43a5c90a5ada1e69ca044595383be67f40b33c61/se2007/game/shared/hl1/hl1mp_weapon_gauss.cpp#L448-L456[/url] The variables for the data here correspond to [URL="https://wiki.garrysmod.com/page/Category:CEffectData"]EffectData[/URL] functions. With that, your Lua code will look like: [code]local data = EffectData() data:SetOrigin(end_position_of_beam) if (CLIENT) then data:SetEntity(Player) else data:SetEntIndex(pPlayer:EntIndex()) end --data:SetFlags(1) -- Enable for secondary fire beam util.Effect("HL1GaussBeam", data)[/code][/QUOTE] Thank you! I see nothing though [code] local effectdata = EffectData() effectdata:SetOrigin(ply:GetEyeTrace().HitPos) if CLIENT then effectdata:SetEntity(ply) else effectdata:SetEntIndex(ply:EntIndex()) end util.Effect( "HL1GaussBeam", effectdata )[/code]
  • Avatar of code_gs
  • [QUOTE=residualgrub;52767918]Ya I have to play it in the world. So essentially the source engine has no set system for this in regards to playing sounds in the world?[/QUOTE] It's system is EmitSound, which has multiple channels.
  • Avatar of Zombine
  • I'm failing terribly at modifying the draw.TextRotated function to work inside a panel. I've tried dozens of combinations, but my math is failing me. Has anyone else done this already? For reference, the function is on this page [URL]http://wiki.garrysmod.com/page/cam/PushModelMatrix[/URL] EDIT: Solved it, here's the code in case anyone else has the problem. [code]function PANEL:DrawRotatedText(text, x, y, color, font, ang) render.PushFilterMag(TEXFILTER.ANISOTROPIC) render.PushFilterMin(TEXFILTER.ANISOTROPIC) local cx, cy = self:LocalToScreen(0, 0) surface.SetFont(font) local textWidth, textHeight = surface.GetTextSize(text) surface.SetTextColor(color) surface.SetTextPos(-textWidth / 2, -textHeight / 2) local m = Matrix() -- Negate the panel's translatiob m:Translate(Vector(cx + y, cy + x, 0)) m:SetAngles(Angle(0, ang, 0)) m:Translate(Vector(-cx, -cy, 0)) cam.PushModelMatrix(m) surface.DrawText(text) cam.PopModelMatrix() render.PopFilterMag() render.PopFilterMin() end[/code]
  • I remember a while ago there was a post about addons causing servers to crash becaue hackers could spam net messages. How would someone secure the server against that? Or is it not possible
  • [QUOTE=blackwidowman;52772596]I remember a while ago there was a post about addons causing servers to crash becaue hackers could spam net messages. How would someone secure the server against that? Or is it not possible[/QUOTE] [URL="https://github.com/Facepunch/garrysmod-issues/issues/1797"]Might be a false alarm[/URL]
  • Avatar of Matsilagi
  • How do i store a swep function as a non-local variable to use part of the OG code on a replacement? I need to add a function to TakePrimaryAmmo which makes it not consume ammo if an weapon ent suffices certain requirements WHILE keeping its original functionality, calling the original function incase the weapon doesn't have the specific modifier is the best solution, but i've been trying for like 5 hours or so and couldn't get too far. Any light on that? I've even tried to replicate the function's original behaviour but it didn't work well on one specific base.
  • Avatar of Benn20002
  • I am trying to modify a DComboBox, but I cant figure out how I can remove the default text: [IMG]https://i.gyazo.com/34cb2f4fe52b911e0054934fdd8c3f4d.png[/IMG] I am overwriting the Paint function of the DComboBox but thats not removing the text.
  • Avatar of code_gs
  • [QUOTE=Matsilagi;52773635]How do i store a swep function as a non-local variable to use part of the OG code on a replacement? I need to add a function to TakePrimaryAmmo which makes it not consume ammo if an weapon ent suffices certain requirements WHILE keeping its original functionality, calling the original function incase the weapon doesn't have the specific modifier is the best solution, but i've been trying for like 5 hours or so and couldn't get too far. Any light on that? I've even tried to replicate the function's original behaviour but it didn't work well on one specific base.[/QUOTE] It would be better to modify WEAPON.SetClip* and PLAYER.RemoveAmmo directly (which is what TakePrimaryAmmo uses internally). [code]local tInfinite = {} function InfiniteAmmo(pEntity, bInfinite) if (pEntity:IsPlayer() or pEntity:IsNPC()) then tInfinite[pPlayer] = bInfinite and true or nil end end function HasInfiniteAmmo(pPlayer) return tInfinite[pPlayer] == true end hook.Add("EntityRemoved", "InfiniteAmmo", function(pEntity) if (pEntity:IsPlayer() or pEntity:IsNPC()) then tInfinite[pEntity] = nil -- Memory cleanup end end) local WEAPON = FindMetaTable("Weapon") local fSetClip1 = WEAPON.SetClip1 function WEAPON:SetClip1(...) if (not HasInfiniteAmmo(self:GetOwner())) then fSetClip1(self, ...) end end local fSetClip2 = WEAPON.SetClip2 function WEAPON:SetClip2(...) if (not HasInfiniteAmmo(self:GetOwner())) then fSetClip2(self, ...) end end local PLAYER = FindMetaTable("Player") local fRemoveAmmo = PLAYER.RemoveAmmo function PLAYER:RemoveAmmo(...) if (not HasInfiniteAmmo(self)) then fRemoveAmmo(self, ...) end end[/code] Of course, you'll need to add some additional code to give the player ammo while infinite ammo is activated if they are empty, but this gives you a general idea.
  • Avatar of Gonzo
  • [QUOTE=Benn20002;52773918]I am trying to modify a DComboBox, but I cant figure out how I can remove the default text: [IMG]https://i.gyazo.com/34cb2f4fe52b911e0054934fdd8c3f4d.png[/IMG] I am overwriting the Paint function of the DComboBox but thats not removing the text.[/QUOTE] Take a look at child elements and/read the source code of it, take a look if there's a combobox.DLabel inside of it
  • Avatar of buu342
  • Is it possible for Gmod to access custom DLL's and such? I'd be surprised if it did since that has massive security implications, but I was wondering if I could hook my computer's AlienFX to the game's Physgun color (since I have a multicolor Physgun). Would be really neat but I doubt I can do that.
  • Avatar of code_gs
  • [QUOTE=buu342;52774302]Is it possible for Gmod to access custom DLL's and such? I'd be surprised if it did since that has massive security implications, but I was wondering if I could hook my computer's AlienFX to the game's Physgun color (since I have a multicolor Physgun). Would be really neat but I doubt I can do that.[/QUOTE] You can from a GMod module, but not directly from the Lua state.
  • Avatar of Benn20002
  • [QUOTE=gonzalolog;52774166]Take a look at child elements and/read the source code of it, take a look if there's a combobox.DLabel inside of it[/QUOTE] I already tried using PrintTable(dcbox:GetChildren()), but there's only one DPanel: 1 = Panel: [name:DPanel][class:Panel][0,0,64,24] I also tried looking up the [URL="https://github.com/Facepunch/garrysmod/blob/c3ea573be9aae395cec85688fc50a3ade67fac95/garrysmod/lua/vgui/dcombobox.lua"]source code[/URL], but I couldnt find anything except that its base is a DButton (But I also couldnt figure out how I can access the DButton Panel if there even is one..).
  • Avatar of sannys
  • [QUOTE=Benn20002;52774596]I already tried using PrintTable(dcbox:GetChildren()), but there's only one DPanel: 1 = Panel: [name:DPanel][class:Panel][0,0,64,24] I also tried looking up the [URL="https://github.com/Facepunch/garrysmod/blob/c3ea573be9aae395cec85688fc50a3ade67fac95/garrysmod/lua/vgui/dcombobox.lua"]source code[/URL], but I couldnt find anything except that its base is a DButton (But I also couldnt figure out how I can access the DButton Panel if there even is one..).[/QUOTE] DComboBox' base is DButton, whose base is DLabel, whose base is Label. It doesn't have a button or a label as a child, it inherits all of that functionality directly. I don't think there's a way you can stop a label's painting, but you can always just set the text to an empty string.
  • [QUOTE=Benn20002;52774596]I already tried using PrintTable(dcbox:GetChildren()), but there's only one DPanel: 1 = Panel: [name:DPanel][class:Panel][0,0,64,24] I also tried looking up the [URL="https://github.com/Facepunch/garrysmod/blob/c3ea573be9aae395cec85688fc50a3ade67fac95/garrysmod/lua/vgui/dcombobox.lua"]source code[/URL], but I couldnt find anything except that its base is a DButton (But I also couldnt figure out how I can access the DButton Panel if there even is one..).[/QUOTE] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/DComboBox/SetValue]DComboBox:SetValue[/url]?
  • Avatar of pilot
  • Trying to play a avi video with sound from a url on a Panel. What's the best way to go about that? I tried vgui.Create("HTML") but that just returns a grey screen when I do OpenURL("videolink")
  • Avatar of Rubat
  • [QUOTE=pilot;52775386]Trying to play a avi video with sound from a url on a Panel. What's the best way to go about that? I tried vgui.Create("HTML") but that just returns a grey screen when I do OpenURL("videolink")[/QUOTE] You can't play .avi files using web. (Even the newest Chrome or whatever)
  • Avatar of pilot
  • [QUOTE=Robotboy655;52775788]You can't play .avi files using web. (Even the newest Chrome or whatever)[/QUOTE] Is there a video file type you recommend?
  • Avatar of DarkDragonLove
  • Is there a way to create physically simulated sprites? ex: Sparks with different sprites. I don't want to create and use orange box particle systems if I don't have to.
  • Avatar of pilot
  • [QUOTE=gonzalolog;52777084]webm? mp4?[/QUOTE] Neither worked. Gif's are the only way. Nevertheless I have one more question. How would I go about shaking a Derma panel indefinitely? I think I need to do something fancy with Derma_Anim although I'm not that good with math to figure out some kind of function that will get something to rotate or even shake.
  • Avatar of RasmusG5
  • my entity makes this error when spawned on my custom gamemode but not it sandbox [lua]ERROR: Trying to derive entity loot_barrel from non existant entity base_gmodentity! ERROR: Trying to derive entity loot_barrel from non existant entity base_gmodentity! ERROR: Trying to derive entity loot_barrel from non existant entity base_gmodentity! [/lua] i got no other errors