1. Post #41
    Gold Member
    raBBish's Avatar
    March 2007
    2,667 Posts
    Thank you very much, it works. Just one question: What units is the result for GetVelocity() in? When I walk its 250, when I run its 500 (gmod walk and run are faster than normal), when I drive a vehicle its 800-1100. Id like to convert them to kph.
    Since wiki is not working properly I get no uselful results for this function.
    https://developer.valvesoftware.com/wiki/Dimensions

    It's in units per second.
    Feet per second = speed/16
    Miles per hour = (speed * 3600)/5280
    Kilometers per hour = (speed * 0.3048 * 3600)/(1000 * 16)
    Reply With Quote Edit / Delete Windows 7 Finland Show Events Lua Helper Lua Helper x 3Informative Informative x 2 (list)

  2. Post #42
    Flubascrub
    Flubadoo's Avatar
    August 2009
    10,532 Posts
    Is there a tutorial somewhere that teaches you how to make your own particle system/particle effects that can be used in conjunction with util.Effect() or ParticleEffectAttach()?

    EP2 ones are nice but I'd rather make my own.
    Reply With Quote Edit / Delete Windows 7 Qatar Show Events Agree Agree x 3 (list)

  3. Post #43
    Gold Member

    February 2005
    2,303 Posts
    Getting a weird problem on my server.

    Basically on TTT, every so often, when someone drops any weapon on the floor then tries to pick it up with their magneto stick, the weapon gets stuck inside the floor, spazzes out (With dust clouds) and the server crashes. This never used to happen on our old host, but I have no idea why a different host would affect this.

    The dumps confirmed it was a vphysics crash, but I'm not really sure what could be done to fix it aside from not letting people pick them up.
    Reply With Quote Edit / Delete Windows 7 Show Events Disagree Disagree x 1 (list)

  4. Post #44
    Mrwhitee's Avatar
    January 2012
    31 Posts
    im gonna post in this thread again. hope its fine.
    ive been trying all day to make a AmmoCrate. entity for rp that when you click use on it you would obtain 20 Pistol ammo ive been trying for 6hrs today without luck i hope theres some help out there
    Reply With Quote Edit / Delete Windows 7 Denmark Show Events

  5. Post #45
    Best Gamemode Ever
    Deadman123's Avatar
    July 2011
    1,611 Posts
    Need Help with a 3D HUD, Trying to use render targets, but dont know much about the library.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  6. Post #46
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,852 Posts
    Is there any way to sort a table by key? I have a table with 20 strings as the key and want to sort alphanumerically based on that key.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  7. Post #47
    Gold Member
    raBBish's Avatar
    March 2007
    2,667 Posts
    Is there any way to sort a table by key? I have a table with 20 strings as the key and want to sort alphanumerically based on that key.
    for k, v in SortedPairs( tbl ) do
        -- blah
    end

    The function is in lua/includes/extensions/table.lua
    Reply With Quote Edit / Delete Windows 7 Finland Show Events Lua Helper Lua Helper x 1Dumb Dumb x 1 (list)

  8. Post #48
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,852 Posts
    for k, v in SortedPairs( tbl ) do
        -- blah
    end

    The function is in lua/includes/extensions/table.lua
    Perfect, thanks
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  9. Post #49
    Title

    August 2009
    301 Posts
    How do you add 1 to network bool?

    e.g

    self.Entity:SetNWBool("fertlimit", +1)

    It was set at 0 on initialize.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Funny Funny x 1Dumb Dumb x 1Lua King Lua King x 1 (list)

  10. Post #50
    Best Gamemode Ever
    Deadman123's Avatar
    July 2011
    1,611 Posts
    How do you add 1 to network bool?

    e.g

    self.Entity:SetNWBool("fertlimit", +1)


    It was set at 0 on initialize.
    you cat 'add' to a bool, bools are 'true' or 'false'
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  11. Post #51
    Title

    August 2009
    301 Posts
    you cat 'add' to a bool, bools are 'true' or 'false'
    Yes, but bools can also be 1,2,3 etc?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Dumb Dumb x 3 (list)

  12. Post #52
    Best Gamemode Ever
    Deadman123's Avatar
    July 2011
    1,611 Posts
    no

    Edited:

    A 'Boolean' is true or false, not numbers, use NWInts instead, or something more efficient
    Reply With Quote Edit / Delete Windows 7 United States Show Events Disagree Disagree x 2Agree Agree x 1 (list)

  13. Post #53
    Blue Member
    Dennab
    June 2009
    1,031 Posts
    Yes, but bools can also be 1,2,3 etc?
    true false 1 0
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events

  14. Post #54
    Title

    August 2009
    301 Posts
    true false 1 0
    Balls to it, Ill just use the old friend variable.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Informative Informative x 1 (list)

  15. Post #55
    Blue Member
    Dennab
    June 2009
    1,031 Posts
    How do you add 1 to network bool?

    e.g

    self.Entity:SetNWBool("fertlimit", +1)

    It was set at 0 on initialize.
    Don't know why you're trying to add one, it can only be 0 or 1 so just set it to 1
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events Friendly Friendly x 1Dumb Dumb x 1 (list)

  16. Post #56
    Title

    August 2009
    301 Posts
    Don't know why you're trying to add one, it can only be 0 or 1 so just set it to 1
    I was using it for when to remove something, or when it = 5. But now coming to think about it a variable will be much easier.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Useful Useful x 1Dumb Dumb x 1 (list)

  17. Post #57
    ASK ME ABOUT MY SAM 6420 FETISH
    ArmageddonScr's Avatar
    July 2011
    691 Posts
    If you don't need the clients knowing the variable you shouldn't be using the SetNW functions, at all.
    Reply With Quote Edit / Delete Windows XP United States Show Events Dumb Dumb x 2Optimistic Optimistic x 1 (list)

  18. Post #58
    Blue Member
    Dennab
    June 2009
    1,031 Posts
    If you don't need the clients knowing the variable you shouldn't be using the SetNW functions, at all.
    ?

    Where did he say that?
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events Dumb Dumb x 1 (list)

  19. Post #59
    Jaded
    Pyth's Avatar
    April 2010
    2,200 Posts
    Trying to get a

    ply:PrintMessage( HUD_PRINTCENTER, "Out of bounds!")
    

    to appear when a player falls off of a stage, but only for the player. Putting this in init.lua will make everyone see it, but putting

    function player_initdeath( ply, wep, killer )
    	
    	ply:PrintMessage( HUD_PRINTCENTER, "Out of bounds!")
    
    end
    
    hook.Add( "PlayerDeath", "player_initalize_dvars", player_initdeath );
    

    into cl_init.lua under the derma does nothing.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Dumb Dumb x 2 (list)

  20. Post #60
    Title

    August 2009
    301 Posts
    Trying to get a

    ply:PrintMessage( HUD_PRINTCENTER, "Out of bounds!")
    

    to appear when a player falls off of a stage, but only for the player. Putting this in init.lua will make everyone see it, but putting

    function player_initdeath( ply, wep, killer )
    	
    	ply:PrintMessage( HUD_PRINTCENTER, "Out of bounds!")
    
    end
    
    hook.Add( "PlayerDeath", "player_initalize_dvars", player_initdeath );
    

    into cl_init.lua under the derma does nothing.
    You will need to define ply in init.lua, for example local ply = self.Entity.dt.owning_ent (This is for my entity) Then do

    ply:PrintMessage( HUD_PRINTCENTER, "Out of bounds!")

    Where are you calling that in init.lua?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Dumb Dumb x 5 (list)

  21. Post #61
    Jaded
    Pyth's Avatar
    April 2010
    2,200 Posts
    You will need to define ply in init.lua, for example local ply = self.Entity.dt.owning_ent (This is for my entity) Then do

    ply:PrintMessage( HUD_PRINTCENTER, "Out of bounds!")

    Where are you calling that in init.lua?
    Don't think I am, but then nothing should work, right?

    Edited:

    Putting this in init.lua

    --on player death
    
    function player_initdeath( ply, wep, killer )
    	
    	ply:PrintMessage( HUD_PRINTCHAT, ply:Nick() .. " has fallen off of the stage.\n")
    	
    	ply:PrintMessage( HUD_PRINTCENTER, "Out of bounds!")
    	
    end
    

    makes the printcenter appear but not the printchat. Sorry to everyone who's cringing, heh.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Dumb Dumb x 1 (list)

  22. Post #62
    Title

    August 2009
    301 Posts
    Don't think I am, but then nothing should work, right?

    Edited:

    Putting this in init.lua

    --on player death
    
    function player_initdeath( ply, wep, killer )
    	
    	ply:PrintMessage( HUD_PRINTCHAT, ply:Nick() .. " has fallen off of the stage.\n")
    	
    	ply:PrintMessage( HUD_PRINTCENTER, "Out of bounds!")
    	
    end
    

    makes the printcenter appear but not the printchat. Sorry to everyone who's cringing, heh.
    The server is calling this function player_initdeath( ply, wep, killer ) function, so ply is registered as the server. If the player was to call that function, ply would be the player.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Dumb Dumb x 6Useful Useful x 1 (list)

  23. Post #63
    Gold Member
    ralle105's Avatar
    October 2005
    4,648 Posts
    Mrkrabz it's nice that you're trying to help but you obviously have no idea what you're talking about.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events Agree Agree x 5Disagree Disagree x 2Dumb Dumb x 1 (list)

  24. Post #64
    Title

    August 2009
    301 Posts
    Mrkrabz it's nice that you're trying to help but you obviously have no idea what you're talking about.
    Uhr, I've had the same problem in my gamemode and I fixed it by doing local owner = w/e, then doing owner: to send the message. ply would not work because obviously the client didn't call it itself, defining the entity's owner as the client (ply) worked.

    Also, if you were going to put that, why not also be useful and post the "real" fix for him.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Dumb Dumb x 4 (list)

  25. Post #65
    pennerlord's Avatar
    February 2011
    504 Posts
    Uhr, I've had the same problem in my gamemode and I fixed it by doing local owner = w/e, then doing owner: to send the message. ply would not work because obviously the client didn't call it itself, defining the entity's owner as the client (ply) worked.

    Also, if you were going to put that, why not also be useful and post the "real" fix for him.
    What the hell are you talking about? "PlayerDeath" is a serverside function. How should the client call it?
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Agree Agree x 2Late Late x 1Dumb Dumb x 1 (list)

  26. Post #66
    Title

    August 2009
    301 Posts
    What the hell are you talking about? "PlayerDeath" is a serverside function. How should the client call it?
    Also no, I read wrong, he put the PlayerDeath function into a clientside file.

    When the player dies the server calls that function with ply being the player that died. I do understand it however I got confused where he put it into a clientside file.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Dumb Dumb x 1 (list)

  27. Post #67
    Gold Member
    ralle105's Avatar
    October 2005
    4,648 Posts
    Ah, I apologise for the misunderstanding then.

    There doesn't seem to be anything wrong with that code so I'm guessing you have another hook somewhere further down uverwriting that one.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events Agree Agree x 1Dumb Dumb x 1 (list)

  28. Post #68
    aurum481's Avatar
    November 2008
    2,512 Posts
    How do I get if prop is frozen or unfrozen?
    Reply With Quote Edit / Delete Windows XP Lithuania Show Events Dumb Dumb x 1 (list)

  29. Post #69
    pennerlord's Avatar
    February 2011
    504 Posts
    How do I get if prop is frozen or unfrozen?
    PhysObj.IsMoveable

    http://maurits.tv/data/garrysmod/wik...Obj.IsMoveable


    Edited:

    Reply With Quote Edit / Delete Windows 7 Germany Show Events Lua Helper Lua Helper x 2Funny Funny x 1Dumb Dumb x 1 (list)

  30. Post #70
    Dennab
    January 2008
    121 Posts
    How do I get if prop is frozen or unfrozen?
    Try this

    function _R.Entity:IsFrozen()
    	local phys = self:GetPhysicsObject()
    	return (phys:IsValid() and not phys:IsMoveable())
    end
    
    Reply With Quote Edit / Delete Windows XP United Kingdom Show Events Lua Helper Lua Helper x 2Dumb Dumb x 1 (list)

  31. Post #71
    shadowndacorner's Avatar
    May 2011
    195 Posts
    How do I get if prop is frozen or unfrozen?
    http://maurits.tv/data/garrysmod/wik...ty.SetMoveType
    Reply With Quote Edit / Delete Mac United States Show Events Lua Helper Lua Helper x 1Dumb Dumb x 1Disagree Disagree x 1 (list)

  32. Post #72
    G-Enigma's Avatar
    June 2011
    326 Posts
    I'm going to try to keep this simple, in hopes of someone actually being able to help.
    Basically, assuming that the v_model itself has both animations and that they work (probably), is there any reason that this:
    Code:
    function SWEP:Deploy()
    	if ( self.Weapon:Clip1() > 0 ) then
    	self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
    	else
    	self.Weapon:SendWeaponAnim( ACT_VM_DRAW_EMPTY )
    	end
    end
    would not work? Because its playing ACT_VM_DRAW even when the launcher is out of ammo, which is something it shouldn't be doing.
    Any help would be appreciated
    Reply With Quote Edit / Delete Windows 7 United States Show Events Dumb Dumb x 1 (list)

  33. Post #73
    Gold Member
    vexx21322's Avatar
    December 2008
    10,660 Posts
    How can I set up some props into a render target to draw to the screen later?
    Reply With Quote Edit / Delete Windows 7 United States Show Events Dumb Dumb x 1 (list)

  34. Post #74

    January 2012
    131 Posts
    1. What would be the best way to draw a border of a rounded rectangle? Drawing another rounded rectangle atop of the "border rectangle" blends the two colors together if alpha is below 255.
    Perhaps anyone can give me tips on how to achieve this?

    2. I decided to scoure and optimize my gamemode's code. I remember that garry's code had variables such as these ...
    local table = table
    local string = string
    local umsg = umsg
    local concommand = concommand
    
    ... defined. Can anyone explain as to why? Does it make the code run faster?
    Reply With Quote Edit / Delete Windows 7 Estonia Show Events

  35. Post #75
    JustSoFaded's Avatar
    December 2011
    432 Posts
    Does anyone have any ideas fora gradient outlined rect?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  36. Post #76
    Gold Member
    ralle105's Avatar
    October 2005
    4,648 Posts
    1. Somebody made a rounded rectangle alternative using surface.DrawPoly (don't remember who, sorry) You could use that along with the stencil buffer.
    render.ClearStencil()
    render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_ALWAYS)
    render.SetStencilPassOperation(STENCILOPERATION_REPLACE)
    render.SetStencilWriteMask(1)
    render.SetStencilReferenceValue(1)
    
    --Draw center rect
    
    render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_EQUAL)
    
    --Draw outline rect
    
    

    2. You have to do that in modules to place the variables in the modules local environment (modules don't have access to the global environment unless you create them using the package.seeall parameter)
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events Useful Useful x 2Lua Helper Lua Helper x 1 (list)

  37. Post #77
    MoronYard
    _nonSENSE's Avatar
    May 2010
    1,266 Posts
    1. What would be the best way to draw a border of a rounded rectangle? Drawing another rounded rectangle atop of the "border rectangle" blends the two colors together if alpha is below 255.
    Perhaps anyone can give me tips on how to achieve this?
    Divran sent me a code sample for an outlined rounded box. Credits to sk8 and Divran.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Useful Useful x 1Lua Helper Lua Helper x 1 (list)

  38. Post #78
    aurum481's Avatar
    November 2008
    2,512 Posts
    How do I get a Stools owner?
    Swep works with self.Owner but I can't seem to do that with Stool.
    Reply With Quote Edit / Delete Windows XP Lithuania Show Events

  39. Post #79
    Gold Member
    ralle105's Avatar
    October 2005
    4,648 Posts
    I believe it's self:GetOwner()
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events Agree Agree x 2 (list)

  40. Post #80
    Fishbrain's Avatar
    June 2009
    26 Posts

    How can I make this so when I press the Pistols category the Submachine gun category will move down so it doesn't get in the way?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Dumb Dumb x 1 (list)