1. Post #2921
    MPan1's Avatar
    March 2015
    3,482 Posts
    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?

  2. Post #2922
    Touhou Enthusiast
    Shendow's Avatar
    January 2011
    1,071 Posts
    Reply With Quote Edit / Delete Reply Windows 10 Firefox France Show Events Agree Agree x 1Informative Informative x 1 (list)

  3. Post #2923

    June 2017
    54 Posts
    If im making an entity and then setting a SetNWString ie set to "Yo"
    and then I create another entity and set a SetNWString to "NoYo"

    It seems to set all the entities to the latest NW string. If i'm spawning the same entity and setting different network vars is this a bad idea? The only thing I could think of is making a new variable name each time maybe by incrementing but I don't think it's possible

    local thevar(increment this somehow?) = ents.Create( "entity" )

  4. Post #2924
    Touhou Enthusiast
    Shendow's Avatar
    January 2011
    1,071 Posts
    Are you actually sure you are changing the NWString of different entities? Before setting the NWString, print the entity and see if the entity index matches with any other printed entity.

  5. Post #2925

    June 2017
    54 Posts
    Are you actually sure you are changing the NWString of different entities? Before setting the NWString, print the entity and see if the entity index matches with any other printed entity.
    Well no, but i'm unsure how to create "NEW" entities in a new variable because you can't concat variables

    Ie same function will loop spawning a new entity every 60 seconds with different nwstrings. I'm probably explaining it horribly

    Actually they have different entIndex

  6. Post #2926
    MPan1's Avatar
    March 2015
    3,482 Posts
    Well no, but i'm unsure how to create "NEW" entities in a new variable because you can't concat variables

    Ie same function will loop spawning a new entity every 60 seconds with different nwstrings. I'm probably explaining it horribly
    Why do you need that many variables? Sorry, just want to know

  7. Post #2927

    June 2017
    54 Posts
    Why do you need that many variables? Sorry, just want to know
    I don't I just want to spawn an entity and set a network variable ie 5 times with different network vars. But because its in the same variable it sets them all to the same variable I think?

  8. Post #2928
    Touhou Enthusiast
    Shendow's Avatar
    January 2011
    1,071 Posts
    Can you actually show some code so we can see what you're doing. It's hard to understand what you're trying to do and what happens.
    Reply With Quote Edit / Delete Reply Windows 10 Firefox France Show Events Agree Agree x 1 (list)

  9. Post #2929
    Gold Member
    Gfoose's Avatar
    July 2011
    766 Posts
    How do I stop clients joining my server and throwing errors about other server's addons/code? I have sv_allowcslua set to 0 and sv_cheats set 0. Yet specific few players manage to "execute" clientsided code that is not on my server. It is quite fucking annoying when they're spamming my clientside_errors.txt with useless shit.

    Code:
    [ERROR] lua/weapons/animagus_cat2/shared.lua:179: Tried to use a NULL entity!
      1. GetModel - [C]:-1
       2. MorphToHuman - lua/weapons/animagus_cat2/shared.lua:179
        3. RemoveSelf - lua/weapons/animagus_cat2/shared.lua:94
         4. unknown - lua/weapons/animagus_cat2/shared.lua:82
    
    [ERROR] lua/weapons/eoti_werewolf_swep/shared.lua:245: Tried to use a NULL entity!
      1. GetModel - [C]:-1
       2. MorphToHuman - lua/weapons/eoti_werewolf_swep/shared.lua:245
        3. RemoveSelf - lua/weapons/eoti_werewolf_swep/shared.lua:145
         4. unknown - lua/weapons/eoti_werewolf_swep/shared.lua:133
    Also why are some clients missing fonts

    Code:
    SetFontInternal: font doesn't exist (TargetIDSmall)
    SetFontInternal: font doesn't exist (DefaultFixedDropShadow)
    SetFontInternal: font doesn't exist (DefaultFixed)
    SetFontInternal: font doesn't exist (TargetIDSmall)
    SetFontInternal: font doesn't exist (DefaultFixedDropShadow)

  10. Post #2930

    June 2017
    54 Posts
    Sorry. So basically this below will run 5 times and create 5 entities.
    But I want the network string to be specific to the entity just create but it seems to overwrite them all

    Code:
    local chairstatus = ents.Create( "chairstatus" )
    chairstatus:SetPos(randomlocation)
    chairstatus:SetNWString("YoStatus", randomString)
    chairstatuse:Spawn()

  11. Post #2931
    Gold Member
    Moat's Avatar
    March 2014
    439 Posts
    Sorry. So basically this below will run 5 times and create 5 entities.
    But I want the network string to be specific to the entity just create but it seems to overwrite them all

    Code:
    local chairstatus = ents.Create( "chairstatus" )
    chairstatus:SetPos(randomlocation)
    chairstatus:SetNWString("YoStatus", randomString)
    chairstatuse:Spawn()
    You should use ENT:SetupDataTables for custom entities.

  12. Post #2932

    June 2017
    54 Posts
    I have datatables setup already

  13. Post #2933
    Gold Member
    Moat's Avatar
    March 2014
    439 Posts
    I have datatables setup already
    You're not using them correctly then. Here's a tutorial.

  14. Post #2934

    June 2017
    54 Posts
    You're not using them correctly then. Here's a tutorial.
    I feel like a idiot for mixing that up with NW strings. Thank you! But it still has the same problem :(. It still seems to overlap other entities values


    Code:
    local chairstatus = ents.Create( "chairstatus" )
    chairstatus:SetPos(randomlocation)
    chairstatus:SetYo(randomValue)
    chairstatuse:Spawn()
    After creating a few entities I then try retrieve the value from the entity itself. Note that it gives me the last value set in the datatable and not the value set on the entity when this entity was created

    Code:
    
    print(self:GetYo())

  15. Post #2935
    Gold Member
    Moat's Avatar
    March 2014
    439 Posts
    Is "randomValue" ever changed?

  16. Post #2936

    June 2017
    54 Posts
    Is "randomValue" ever changed?
    Yes which is why I cant have every entity with the same value. Any ideas?
    I've tested having it print the randomValue each time the entity spawns

  17. Post #2937
    bigdogmat's Avatar
    May 2014
    873 Posts
    You've misspelt your "chairstatuse" variable on your Entity:Spawn call, so you're probably erroring after the first spawn.

  18. Post #2938
    Gold Member
    NeatNit's Avatar
    January 2006
    2,052 Posts
    Post the full code then. Include the loop and where you define the random variables and the printing etc

  19. Post #2939
    Don't PM me about moderation - PM any of the mods.
    Robotboy655's Avatar
    May 2008
    15,827 Posts
    How do I stop clients joining my server and throwing errors about other server's addons/code? I have sv_allowcslua set to 0 and sv_cheats set 0. Yet specific few players manage to "execute" clientsided code that is not on my server. It is quite fucking annoying when they're spamming my clientside_errors.txt with useless shit.

    Code:
    [ERROR] lua/weapons/animagus_cat2/shared.lua:179: Tried to use a NULL entity!
      1. GetModel - [C]:-1
       2. MorphToHuman - lua/weapons/animagus_cat2/shared.lua:179
        3. RemoveSelf - lua/weapons/animagus_cat2/shared.lua:94
         4. unknown - lua/weapons/animagus_cat2/shared.lua:82
    
    [ERROR] lua/weapons/eoti_werewolf_swep/shared.lua:245: Tried to use a NULL entity!
      1. GetModel - [C]:-1
       2. MorphToHuman - lua/weapons/eoti_werewolf_swep/shared.lua:245
        3. RemoveSelf - lua/weapons/eoti_werewolf_swep/shared.lua:145
         4. unknown - lua/weapons/eoti_werewolf_swep/shared.lua:133
    Also why are some clients missing fonts

    Code:
    SetFontInternal: font doesn't exist (TargetIDSmall)
    SetFontInternal: font doesn't exist (DefaultFixedDropShadow)
    SetFontInternal: font doesn't exist (DefaultFixed)
    SetFontInternal: font doesn't exist (TargetIDSmall)
    SetFontInternal: font doesn't exist (DefaultFixedDropShadow)
    I think some latest Windows 10 update (or something) make some fonts deleted or something, I have seen a whole bunch of tickets with fonts missing. (Tahoma and Helvetica mostly)

  20. Post #2940

    June 2017
    54 Posts
    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

  21. Post #2941
    Shit
    On
    Shit
    code_gs's Avatar
    March 2013
    18,500 Posts
    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?
    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.

  22. Post #2942

    April 2017
    16 Posts
    How does one properly use the "HL1GaussBeam" effect?

  23. Post #2943
    Shit
    On
    Shit
    code_gs's Avatar
    March 2013
    18,500 Posts
    How does one properly use the "HL1GaussBeam" effect?
    https://github.com/VSES/SourceEngine...s.cpp#L35-L114

    Looks like it uses a hack to encode the entity index and attachment in one.

  24. Post #2944

    April 2017
    16 Posts
    https://github.com/VSES/SourceEngine...s.cpp#L35-L114

    Looks like it uses a hack to encode the entity index and attachment in one.
    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?

  25. Post #2945
    Shit
    On
    Shit
    code_gs's Avatar
    March 2013
    18,500 Posts
    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?
    https://github.com/VSES/SourceEngine....cpp#L448-L456

    The variables for the data here correspond to EffectData 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)

  26. Post #2946
    residualgrub's Avatar
    May 2011
    718 Posts
    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.

  27. Post #2947
    Shit
    On
    Shit
    code_gs's Avatar
    March 2013
    18,500 Posts
    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.
    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 surface.PlaySound.

  28. Post #2948
    residualgrub's Avatar
    May 2011
    718 Posts
    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 surface.PlaySound.
    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?

  29. Post #2949

    April 2017
    16 Posts
    https://github.com/VSES/SourceEngine....cpp#L448-L456

    The variables for the data here correspond to EffectData 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)
    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 )

  30. Post #2950
    Shit
    On
    Shit
    code_gs's Avatar
    March 2013
    18,500 Posts
    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?
    It's system is EmitSound, which has multiple channels.

  31. Post #2951
    Gold Member
    Z0mb1n3's Avatar
    December 2013
    1,296 Posts
    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 http://wiki.garrysmod.com/page/cam/PushModelMatrix

    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

  32. Post #2952

    June 2017
    54 Posts
    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

  33. Post #2953
    MPan1's Avatar
    March 2015
    3,482 Posts
    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
    Might be a false alarm

  34. Post #2954
    Gold Member
    Matsilagi's Avatar
    June 2009
    2,169 Posts
    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.

  35. Post #2955
    Benn20002's Avatar
    December 2014
    99 Posts
    I am trying to modify a DComboBox, but I cant figure out how I can remove the default text:


    I am overwriting the Paint function of the DComboBox but thats not removing the text.

  36. Post #2956
    Shit
    On
    Shit
    code_gs's Avatar
    March 2013
    18,500 Posts
    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.
    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
    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.

  37. Post #2957
    Gold Member
    gonzalolog's Avatar
    April 2011
    3,750 Posts
    I am trying to modify a DComboBox, but I cant figure out how I can remove the default text:


    I am overwriting the Paint function of the DComboBox but thats not removing the text.
    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

  38. Post #2958
    buu342's Avatar
    March 2010
    1,404 Posts
    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.

  39. Post #2959
    Shit
    On
    Shit
    code_gs's Avatar
    March 2013
    18,500 Posts
    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.
    You can from a GMod module, but not directly from the Lua state.

  40. Post #2960
    Benn20002's Avatar
    December 2014
    99 Posts
    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
    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 source code, 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..).