1. Post #881
    Yes, it's me, Ollie.
    ollie's Avatar
    January 2012
    635 Posts
    GetUserGroup was never a method that was default, you always had to add it yourself.

    function _R.Player:GetUserGroup()
    	return self:GetNWString( "UserGroup" )
    end
    Thanks, really useful!
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  2. Post #882
    tr0ubl3mak3r's Avatar
    January 2009
    129 Posts
    How do you find the position of the center of the map? A lot of maps don't center on 0,0,0 unfortunately.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  3. Post #883

    February 2010
    129 Posts
    How do you find the position of the center of the map? A lot of maps don't center on 0,0,0 unfortunately.
    Ah well, impossible as the center of the map is really relative. BUUUT, if you REALLY need it, get the position where the left most brush is, get the position where the right most brush is, divide by 2, do the same thing with the other 2 sides and bham, you got the relative x and y of the center of the map.
    Reply With Quote Edit / Delete Windows 7 Brazil Show Events

  4. Post #884
    tr0ubl3mak3r's Avatar
    January 2009
    129 Posts
    Ah well, impossible as the center of the map is really relative. BUUUT, if you REALLY need it, get the position where the left most brush is, get the position where the right most brush is, divide by 2, do the same thing with the other 2 sides and bham, you got the relative x and y of the center of the map.
    Are you saying there's a way to detect brushes in lua? Or are you saying scan around with traces? I was already considering using a tracing algorithm to attempt to get the dimensions of the map, but with underground areas it will require a lot of checking. I was hoping there was some sort of function I could use to find the map center easier.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  5. Post #885
    Paid by Vil <3
    Agent766's Avatar
    July 2007
    2,703 Posts
    Just iterate through func_brushes
    Reply With Quote Edit / Delete Windows 7 United States Show Events Dumb Dumb x 1 (list)

  6. Post #886
    Free Bradley Manning!
    Persious's Avatar
    April 2010
    2,192 Posts
    Replace self with v, sorry.
    I didn't have time to test it until today, and it doesn't work.

    I added the Categories doing this:

    table.insert(Collaps, Cat1)
    table.insert(Collaps, Cat2)
    table.insert(Collaps, Cat3)
    table.insert(Collaps, Cat4)
    

    I printed the table after, and it returned:

    1 = Panel: [name:Panel][class:Panel][5,5,480,50]
    2 = Panel: [name:Panel][class:Panel][5,5,480,50]
    3 = Panel: [name:Panel][class:Panel][5,5,480,50]
    4 = Panel: [name:Panel][class:Panel][5,5,480,50]


    When I press a header, it says:
    Code:
    [@messingaround\gamemode\base\client\main_menu.lua:61] bad argument #1 to 'pairs' (table expected, got nil)	pairs	[C]:-1
    	unknown	messingaround\gamemode\base\client\main_menu.lua:61
    Reply With Quote Edit / Delete Windows 7 Faroe Islands Show Events

  7. Post #887
    I love you Danny <3
    Chessnut's Avatar
    August 2011
    2,690 Posts
    What's on line 56?
    Reply With Quote Edit / Delete United States Show Events

  8. Post #888
    THE FRESH PRINCE OF COMPTON
    Rayss's Avatar
    November 2011
    564 Posts
    I'm sure you guys get this all the time, but should I learn Java or C++ before jumping into LUA? I have no experience with programming so I'm looking to start somewhere. I want to use it for more practical applications than just Gmod, so I would appreciate a starter guide for someone who's literally never coded before.

    So far I've been looking through this guide: http://lua.gts-stolberg.de/en/Programmieren.php

    However, I doubt it'll get me far. It seems to be really simplified and probably won't help me in the long run. I just haven't had much luck finding a book or an internet source which starts from square one without assuming you know ANYTHING like what a syntax is, what a runtime environment is, etc. To get a feel for LUA I've been sifting through various addon LUA codes to see how the process is done, yet, it obviously makes little sense to me. I think doing this would be more resourceful when I actually have a grasp on the terminology of LUA and coding in general.

    I appreciate any responses I can get!
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  9. Post #889
    pennerlord's Avatar
    February 2011
    497 Posts
    I'm sure you guys get this all the time, but should I learn Java or C++ before jumping into LUA? I have no experience with programming so I'm looking to start somewhere. I want to use it for more practical applications than just Gmod, so I would appreciate a starter guide for someone who's literally never coded before.

    So far I've been looking through this guide: http://lua.gts-stolberg.de/en/Programmieren.php

    However, I doubt it'll get me far. It seems to be really simplified and probably won't help me in the long run. I just haven't had much luck finding a book or an internet source which starts from square one without assuming you know ANYTHING like what a syntax is, what a runtime environment is, etc. To get a feel for LUA I've been sifting through various addon LUA codes to see how the process is done, yet, it obviously makes little sense to me. I think doing this would be more resourceful when I actually have a grasp on the terminology of LUA and coding in general.

    I appreciate any responses I can get!
    First of all, it's called "Lua" not "LUA" (it's a name and not an acronym or something like that).

    A good start to learn Lua should be this site: http://www.lua.org/pil/
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Disagree Disagree x 1 (list)

  10. Post #890
    THE FRESH PRINCE OF COMPTON
    Rayss's Avatar
    November 2011
    564 Posts
    First of all, it's called "Lua" not "LUA" (it's a name and not an acronym or something like that).

    A good start to learn Lua should be this site: http://www.lua.org/pil/
    Yeah I have that open actually, but it seems to be aimed at people who have experience with programming.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  11. Post #891
    My DarkRP
    Drakehawke's Avatar
    February 2009
    3,490 Posts
    Yeah I have that open actually, but it seems to be aimed at people who have experience with programming.
    Yeah I never really used it, I started out in a similar way, no previous programming experience at all (infact, learning Lua was what led me into learning C++/PHP/Java), and I always found the `official` Lua documentation long winded & over-complicated.

    The tutorials on the old GMod wiki were pretty good, there are quite a few on the new one too.

    I learned from a combination of those, trial & error, the old Questions subforum (rip in peace) and other peoples stuff.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Agree Agree x 1 (list)

  12. Post #892

    May 2010
    805 Posts
    Hi, I'm having issues with scripted entities. When I set the model of a model with a ragdoll like say, http://www.garrysmod.org/downloads/?a=view&id=115389 the physics model is rotated 90 degrees on all axis away. This means I need to fiddle about with bone matrices, which are annoying and time consuming. Is there some kind of physics type I need to use aside from the usual SOLID_VPHYSICS?

    http://steamcommunity.com/id/ylsid/s...24819578009375
    http://steamcommunity.com/id/ylsid/s...24819578007546
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  13. Post #893

    January 2012
    3 Posts
    Having issues with derma. Whenever I click on something other than the panel list, the panel list goes behind the derma frame.

    Pic related.


    function DrawAssassinGunMenu()
        function Categoryitemgetname()
            if categoryitemselected == nil then
            return "Pick A Weapon"
            else
            return categoryitemselected
            end
        end
            
        local DermaPanel = vgui.Create( "DFrame" )
        DermaPanel:SetSize( 600, 325 )
        DermaPanel:SetTitle( "Gun Menu" )
        DermaPanel:SetVisible( true )
        DermaPanel:SetDraggable( false )
        DermaPanel:ShowCloseButton( true )
        DermaPanel:Center()
        DermaPanel:MakePopup()
        DermaPanel:SetBackgroundBlur( true )
            
        local TestingPanel = vgui.Create( "DPanel", DermaPanel )
        local x,y = DermaPanel:GetPos()
        TestingPanel:SetPos( 5, 25 )
        TestingPanel:SetSize( 590, 132  )
        TestingPanel.Paint = function() -- Paint function
    		--Set our rect color below us; we do this so you can see items added to this panel
            surface.SetDrawColor( 50, 50, 50, 255 ) 
            surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() ) -- Draw the rect
            end
            
        local Panel2 = vgui.Create( "DPanel", DermaPanel )
        local x,y = DermaPanel:GetPos()
        Panel2:SetPos( 5, 163 )
        Panel2:SetSize( 590, 150 )
        Panel2.Paint = function() -- Paint function
            --Set our rect color below us; we do this so you can see items added to this panel
            surface.SetDrawColor( 50, 50, 50, 255 ) 
            surface.DrawRect( 0, 0, Panel2:GetWide(), Panel2:GetTall() ) -- Draw the rect
            end
            
        local PrimaryLabel = vgui.Create("Label", DermaPanel )
        local x,y = DermaPanel:GetPos()
        PrimaryLabel:SetText("Primary Weapon")
        PrimaryLabel:SetFont("defaultbold")
        PrimaryLabel:SetPos(9, 28)
        PrimaryLabel:SizeToContents()
            
        local DescLabel = vgui.Create( "Label", Panel2 )
        DescLabel:SetText("Pick A Weapon")
        DescLabel:SetFont("defaultbold")
        DescLabel:SetPos(5, 5)
        DescLabel:SizeToContents()
            
        local DescLabel2 = vgui.Create( "Label", Panel2 )
        DescLabel2:SetText("Description text here you fucking clownshoe")
        DescLabel2:SetPos(5, 20)
        DescLabel2:SizeToContents()
            
        local DermaList = vgui.Create( "DPanelList", TestingPanel )
        local x,y = DermaPanel:GetPos()
        DermaList:SetPos( x + 12, y + 45 )
        DermaList:SetSize( DermaPanel:GetWide() - 25, 100 )
        DermaList:SetSpacing( 5 ) -- Spacing between items
        DermaList:EnableHorizontal( true ) -- Only vertical items
        DermaList:EnableVerticalScrollbar( false ) -- Allow scrollbar if you exceed the Y axis
        DermaList:MakePopup()
            
        local CreditLabel = vgui.Create( "DLabel", Panel2 )
        CreditLabel:SetFont("defaultbold")
        CreditLabel:SetPos( 5, 82 )
        CreditLabel:SetText("Credits to Unlock")
        CreditLabel:SizeToContents()
            
        local Credits = vgui.Create( "DProgressBar", Panel2)
        Credits:SetSize( 300, 40 )
        Credits:SetPos( 3, 100 )
        Credits:SetMin( 0 )
        Credits:SetMax(1000)
        Credits:SetValue(10)
            
    	local CategoryItem1Panel = vgui.Create( "DPanel", DermaList )
    	CategoryItem1Panel:SetSize(100,100)
    	CategoryItem1Panel.Paint = function() -- Paint function
            surface.SetDrawColor( 100, 100, 100, 255 ) 
            surface.DrawOutlinedRect( 0, 0, 100, 100)
            end
    	
        local CategoryItem1Gun = vgui.Create( "DModelPanel", CategoryItem1Panel )
    	CategoryItem1GunCost = 30
        CategoryItem1Gun:SetPos(1,1)
        CategoryItem1Gun:SetSize(98,98)
        CategoryItem1Gun:SetModel( "models/weapons/w_rif_ak47.mdl" )
        CategoryItem1Gun:SetToolTip("AK-47")
        CategoryItem1Gun:SetCamPos( Vector( 40, 40, 0 ) )
        CategoryItem1Gun:SetLookAt( Vector( 0, 7, 0 ) )
        CategoryItem1Gun.OnMousePressed = function()
            DescLabel:SetText("AK-47")
            DescLabel2:SetText("It costs $200,000 to fire this weapon for twelve seconds.".."\n".."Pew Pew")
            DescLabel2:SizeToContents()
            Credits:SetMin( 0 )
            Credits:SetMax(CategoryItem1GunCost)
            end
        DermaList:AddItem( CategoryItem1Panel )
    		
    	local CategoryItem2Panel = vgui.Create( "DPanel", DemaList )
    	CategoryItem2Panel:SetSize(100,100)
    	CategoryItem2Panel.Paint = function()
    		surface.SetDrawColor( 100, 100, 100, 255 ) 
    		surface.DrawOutlinedRect( 0, 0, 100, 100)
            end
    		
    	local CategoryItem2Gun = vgui.Create( "DModelPanel", CategoryItem2Panel )
    	CategoryItem2GunCost = 50
        CategoryItem2Gun:SetPos(1,1)
        CategoryItem2Gun:SetSize(98,98)
        CategoryItem2Gun:SetModel( "models/weapons/w_rif_m4a1.mdl" )
        CategoryItem2Gun:SetToolTip("M4A1")
        CategoryItem2Gun:SetCamPos( Vector( 40, 40, 0 ) )
        CategoryItem2Gun:SetLookAt( Vector( 0, 7, 0 ) )
        CategoryItem2Gun.OnMousePressed = function()
            DescLabel:SetText("M4A1")
            DescLabel2:SizeToContents()
            DescLabel2:SetText("Standard issue army stuff.")
            Credits:SetMin( 0 )
            Credits:SetMax(CategoryItem2GunCost)
            end
    	DermaList:AddItem( CategoryItem2Panel )
    end
    
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  14. Post #894
    wanksta11's Avatar
    April 2009
    1,668 Posts
    I really need help with 3d2d, the text is flat on the ground, how do I make it flat on a wall to face me?
    Ang:RotateAroundAxis(Ang:Up(), 90)
    cam.Start3D2D(Pos + Ang:Up() * 11.5, Ang, 0.11)
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  15. Post #895
    Gold Member
    Splambob's Avatar
    January 2005
    1,019 Posts
    Can someone tell me what I'm doing wrong here? I'm using WorldToLocal to get the position of one vector-angle pair (V1, A1) relative to another vector-angle pair. (V2, A2)

    With V1 = [0, 0, -20], A1 = [315, 0, 0], V2 = [0, 0, -20], A2 = [0,0,0], I expected the resulting local vector to be [0,0,0] because V1 and V2 are equal. Instead, WorldToLocal(V1, A1, V2, A2) returns a vector [0, 6.8, -18.7].

    EDIT: Solved. The compiler was reading my code better than I was; local entang, entpos = ent:getPos(), ent:getAng()


    How do you find the position of the center of the map? A lot of maps don't center on 0,0,0 unfortunately.
    AFAIK there's no way of detecting map boundaries, but util.IsInWorld can tell you what positions are within the map. You can iterate using that function over the whole map space (-16384 to 16384 xyz, obviously NOT one unit at a time D:) to gain a rough idea of where the boundaries are. This approach isn't cheap, and guessing how expensive that function is I'd recommend only doing that upon map loading
    Reply With Quote Edit / Delete Windows 7 Show Events

  16. Post #896
    L33t modl haxorz..
    Katazuro's Avatar
    March 2012
    1,356 Posts
    Agh, right now I have a hud with text alignments on each side accordingly, like text that's on the right side of my screen is aligned to the right, but i'm confused on how i would make icons/textures appear the same way it's dynamically moving with the length of the text, can anyone give some tips?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  17. Post #897
    My DarkRP
    Drakehawke's Avatar
    February 2009
    3,490 Posts
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Friendly Friendly x 1 (list)

  18. Post #898
    NitronikALT's Avatar
    September 2010
    4,869 Posts
    So, I wanted to create a set of HL2 Sweps with drastically different damage and rate of fire.

    Jvs kindly pointed me to the SWEP base in garrysmod's .gcf, but I can't wrap my head around it. Can someone please help me out?

    Sorry if this isn't the right place but I don't browse this section often
    Reply With Quote Edit / Delete Windows 7 Italy Show Events

  19. Post #899
    Awesome Gmod Servers!
    brandonj4's Avatar
    September 2011
    1,372 Posts
    So, I wanted to create a set of HL2 Sweps with drastically different damage and rate of fire.

    Jvs kindly pointed me to the SWEP base in garrysmod's .gcf, but I can't wrap my head around it. Can someone please help me out?

    Sorry if this isn't the right place but I don't browse this section often
    You wouldn't need a them to be created again you can easily do this(If this applies to the HL2 weapons):
    Weapon = ents.Create("weapon_357") --replace
    Weapon.Primary.Damage = 999
    Weapon.Primary.Delay = 0.1
    Weapon.Primary.ClipSize = 100
    Reply With Quote Edit / Delete Windows 7 Canada Show Events Disagree Disagree x 3Informative Informative x 1 (list)

  20. Post #900
    Sleazeball's Avatar
    January 2011
    110 Posts
    Can you guys help me. I keep getting Error: !IsValidGamemode. When I try to load my gamemode.. Help!?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  21. Post #901
    L33t modl haxorz..
    Katazuro's Avatar
    March 2012
    1,356 Posts
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  22. Post #902
    Fritz0005's Avatar
    December 2007
    2 Posts
    If a networked variable is set before the client loads into the server, does that networked variable get sent to the player on load? My code returns the empty string from running GetNWString() on the client. SetNWString() was run before I load my client onto the server. I tried running SetNWString() after the client was loaded and it succeeded.

    I would like the variables to be global for all players, but it should only be synced to all players if it changes. How could the NW variable be set without resending to everyone in the server again? Please let me know if you have any links to helpful information, and thank you!
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  23. Post #903
    Gold Member
    Bletotum's Avatar
    June 2008
    6,399 Posts
    How can I get a point relative to another point and angle? I want to know the relative x and y positions to an angled square, from a point on the square found with an eye trace.

    I feel I can do this using the angle from the center of the square to the eye trace point, but I cannot find the angle. Dotp, maga, and magb all print fine to the console, but ang prints #IND (indefinite?), and the game crashes if I try to use it.

    local dotp = ent:GetPos():DotProduct(tr.HitPos)
    local maga = math.sqrt(ent:GetPos().x+ent:GetPos().y+ent:GetPos().z)
    local magb = math.sqrt(tr.HitPos.x+tr.HitPos.y+tr.HitPos.z)
    local ang = math.acos(dotp/(maga*magb))
    print("dotp "..dotp)
    print("maga "..maga)
    print("magb "..magb)
    print("ang "..ang)
    testselectorent:SetPos(Angle(0,ang,0):Forward()*75)
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  24. Post #904
    My DarkRP
    Drakehawke's Avatar
    February 2009
    3,490 Posts
    As cos can never be greater than 1 or less than -1, arccos is only defined for -1 <= x <= 1, check what dotp/(maga*magb) is, I'll bet it isn't in that range.

    Can you re-word exactly what you're trying to do? I don't quite understand.

    Also assuming maga means magnitude, shouldn't it be root(x^2 + y^2 + z^2) not root( x + y + z )? That could explain the invalid value being thrown to arccos.

    Edited:

    OH you're trying to find the angle between two vectors, yeah that should work when you fix the magnitude calculation.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Lua Helper Lua Helper x 1 (list)

  25. Post #905
    Gold Member
    Bletotum's Avatar
    June 2008
    6,399 Posts
    Thanks, that solved it not working. I do not understand the values I'm getting back, though.

    While I'm not getting #IND or anything, the formula's output angle really must not be correct at all for some reason. For instance, it varies strongly depending on where the square is in the world, and which part of a straight line from the center I am looking at.

    Maybe I am misunderstanding what this formula does. What I need is a way to find the angle from the center of a plane to a point on the plane determined by the player's eyetrace. I want to use this angle to later find the x and y position of the point, using the length of the line (I plan to put this angle and its length around the world center, then read the X and Y of the point).



    I am hoping to find that angle without having to worry about the angle of the plane as a whole in world space.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  26. Post #906
    My DarkRP
    Drakehawke's Avatar
    February 2009
    3,490 Posts
    Of course it's going to vary greatly depending on the position in the world, the vectors you're finding the angle between are position vectors (i.e. from 0, 0, 0, through the center of the object)?

    Imagine drawing a line from 0, 0, 0 to ent:GetPos(), then drawing a line from 0, 0, 0, to tr.HitPos, then finding the angle between those lines, that's what the formula you're using does.

    [img]http://puu.sh/OAm3[/img]

    Is that what you're ultimately trying to find? The x, y co-ordinates the player is looking at relative to the planes origin + x/y axes?

    Edited:

    Yeah my paint skills are awful
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  27. Post #907
    Gold Member
    Bletotum's Avatar
    June 2008
    6,399 Posts
    Yes. If I could replace that 0,0,0 with a coordinate relative to the plane's angle, would that formula work for this? If so, how, and how would it know the x and y (I imagine it would have trouble knowing if you mean 181 degrees from the right, or 179 degrees from the left)?

    Edited:

    With the angle, I think I can just apply this as a yaw to the world center, get the forward vector, and multiply it by the distance between the entpos and the tracepos, to get the x and y.

    Edited:

    Oh durr, I can just use coordinates relative to the square.

    Edited:

    That solved the angle value changing due to entity position, but the values are affected for some reason by the plane entity's angle.

    Additionally, the angle value changes if I change the 140 at the end of this first line to another value. Why would the length of either vector matter when determining the angle?

    local entloc = Angle(ent:GetAngles().p,ent:GetAngles().y,ent:GetAngles().r):Right()*140 //room for modifications on the angle
    local traceloc = tr.HitPos-ent:GetPos()
    local dotp = entloc:DotProduct(traceloc)
    local maga = math.sqrt((entloc.x^2)+(entloc.y^2)+(entloc.z^2))
    local magb = math.sqrt((traceloc.x^2)+(traceloc.y^2)+(traceloc.z^2))
    local ang = math.acos(dotp/(maga*magb))*(180/math.pi)
    

    Reply With Quote Edit / Delete Windows 7 United States Show Events

  28. Post #908
    I hide under your bed
    twoski's Avatar
    July 2011
    1,793 Posts


    I'm trying to figure out how scrolling works with panels. My custom scroll buttons aren't doing anything. Also, despite being parented properly, those bottom panels still show their model panels for some reason.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  29. Post #909
    I love you Danny <3
    Chessnut's Avatar
    August 2011
    2,690 Posts
    You need to clip them.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  30. Post #910
    My DarkRP
    Drakehawke's Avatar
    February 2009
    3,490 Posts
    You'll need to use a scissor rect to clip the models properly, alternatively (and probably more easy) you can just size the DPanelList to a multiple of the size of the DModelPanels, then override the DPanelLists OnVScroll hook so it'll only move the canvas to a multiple of the size of the DModelPanels.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Useful Useful x 3Late Late x 1Lua Helper Lua Helper x 1 (list)

  31. Post #911
    Gold Member
    Crap-Head's Avatar
    May 2010
    346 Posts
    Or you could use this, not sure who made it, but its really useful and a simple solution.

    local PANEL = {}
    function PANEL:Paint()
        local x, y = self:LocalToScreen( 0, 0 )
        local w, h = self:GetSize()
         
        local sl, st, sr, sb = x, y, x + w, y + h
         
        local p = self
        while p:GetParent() do
            p = p:GetParent()
            local pl, pt = p:LocalToScreen( 0, 0 )
            local pr, pb = pl + p:GetWide(), pt + p:GetTall()
            sl = sl < pl and pl or sl
            st = st < pt and pt or st
            sr = sr > pr and pr or sr
            sb = sb > pb and pb or sb
        end
         
        render.SetScissorRect( sl, st, sr, sb, true )
            self.BaseClass.Paint( self )
        render.SetScissorRect( 0, 0, 0, 0, false )
    end
    vgui.Register( "DModelPanel2", PANEL, "DModelPanel" )
    
    Reply With Quote Edit / Delete Windows 7 Denmark Show Events Useful Useful x 3Winner Winner x 2 (list)

  32. Post #912
    Falcqn's Avatar
    July 2010
    2,652 Posts
    Is it possible to change an entity's origin? ie Offset it by a local vector
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Funny Funny x 1 (list)

  33. Post #913
    Gold Member
    Bletotum's Avatar
    June 2008
    6,399 Posts
    ent:SetPos(ent:GetPos()+Vector(offsetx,offsety,offsetz))

    Though when you say local vector, maybe you mean relative to the ent's angle?

    ent:SetPos(ent:GetPos()+(ent:GetAngles():Forward()*Length))

    You can also try Up and Right, instead of forward. Negative length number for down, left, and backward.

    If you want the entity's position plus angle relative vector offset with angular offset,

    ent:SetPos(ent:GetPos()+(Angle(ent:GetAngles().p+poffset,ent:GetAngles().y+yoffset,ent:GetAngles().r+roffset):Forward()*Length)))
    Reply With Quote Edit / Delete Windows 7 United States Show Events Artistic Artistic x 1 (list)

  34. Post #914
    Falcqn's Avatar
    July 2010
    2,652 Posts
    I don't mean move it, I mean change the origin of where its model renders from.

    Edited:

    Never mind, found it by trawling Maurits's wiki backup, Entity.SetRenderOrigin

    Edited:

    Using a ClientsideModel and parenting it works much much better
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  35. Post #915
    InfernalCookie's Avatar
    December 2010
    688 Posts
    Quick question:

    How do I make Ignite() do no damage to players other than the recipient? I tried setting the radius to zero ( ply:Ingite( 10, 0 ) player:Ignite( time, radius ) ) but it didn't work... The players do not collide with the other players of the same team by the way... And it's meant to be that way.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  36. Post #916
    Falcqn's Avatar
    July 2010
    2,652 Posts
    Does it still damage other players if you don't pass it a radius at all?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  37. Post #917
    InfernalCookie's Avatar
    December 2010
    688 Posts
    Yep.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  38. Post #918
    My DarkRP
    Drakehawke's Avatar
    February 2009
    3,490 Posts
    As a last resort you could use an EntityTakeDamage hook
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  39. Post #919

    May 2009
    665 Posts
    I didn't have time to test it until today, and it doesn't work.

    I added the Categories doing this:

    table.insert(Collaps, Cat1)
    table.insert(Collaps, Cat2)
    table.insert(Collaps, Cat3)
    table.insert(Collaps, Cat4)
    

    I printed the table after, and it returned:

    1 = Panel: [name:Panel][class:Panel][5,5,480,50]
    2 = Panel: [name:Panel][class:Panel][5,5,480,50]
    3 = Panel: [name:Panel][class:Panel][5,5,480,50]
    4 = Panel: [name:Panel][class:Panel][5,5,480,50]


    When I press a header, it says:
    Code:
    [@messingaround\gamemode\base\client\main_menu.lua:61] bad argument #1 to 'pairs' (table expected, got nil)	pairs	[C]:-1
    	unknown	messingaround\gamemode\base\client\main_menu.lua:61
    Can I see the code in a PM or something?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  40. Post #920
    Gold Member
    Trumple's Avatar
    September 2009
    5,367 Posts
    Hello guys, I'm new to Lua and I've hacked together a Gamemode.

    This function is called on round restart:

    function reset_round()
    	
    	for k,v in pairs(swaplist_to_1) do
    		local t1 = team.NumPlayers(1)
    		local t2 = team.NumPlayers(2)
    		
    		if t1 < (t2/3) then
    			--if guards are lacking, source a player from the swap list
    			if v:IsValid() then
    				v:SetTeam(1)
    			end
    			local thisKey = table.KeyFromValue( swaplist_to_1, v )
    			table.remove(swaplist_to_1, thisKey)
    		end
    	end
    	
    	for k,v in pairs(swaplist_to_2) do
    		local t1 = team.NumPlayers(1)
    		local t2 = team.NumPlayers(2)
    		
    		if t2 < (3*t1) then
    			if t1 != 1 then
    				--if prisoners are lacking, source a player from the swap list
    				if v:IsValid() then
    					--make sure this player is still valid and didnt disconnect
    					v:SetTeam(2)
    				end
    				local thisKey = table.KeyFromValue( swaplist_to_2, v )
    				table.remove(swaplist_to_2, thisKey)
    			end
    		end
    	end
    	
    	game.CleanUpMap()
    	for k, v in pairs(player.GetAll()) do
    		v:RemoveAllAmmo()--remove ammo so they can pick up weapons again
    		if v:Team() == 1 then
    			--alive guards, just respawn them
    			v:Spawn()
    		elseif v:Team() == 2 then
    			--alive prisoners, just respawn them
    			v:Spawn()
    		elseif v:Team() == 3 then
    			--dead guards, set to 1 then respawn them
    			v:SetTeam(1)
    			v:Spawn()
    		elseif v:Team() == 4 then
    			--dead prisoners, set to 2 then respawn
    			v:SetTeam(2)
    			v:Spawn()
    		end
    	end
    	game_over = false
    	
    	local alive_guards = team.GetPlayers(1)--this is a problem because what if the guards are dead? So, get the table of dead players (3) and live players and merge them, THEN pick a random value
    	local dead_guards = team.GetPlayers(3)
    	table.Merge(alive_guards, dead_guards)
    	--RunConsoleCommand("say", table.ToString(alive_guards))
    	if table.Count(alive_guards) > 0 then
    		warden = table.Random(alive_guards)--gets a random value from the table of players
    	else
    		warden = NullEntity()--if for some reason there are no guards, send a null entity
    	end
    	for k, v in pairs(player.GetAll()) do
    		v:SetNetworkedString("warden", warden:UniqueID())--update players with new warden
    	end
    	
    	timer.Destroy("update_time")
    	timer.Create("update_time", 1, 0, update_time)
    	time_remaining = 300 -- 5 minutes
    end
    

    Can anyone see why I get horrible lag on round restart? I'm willing to accept the fact it might just be the CPU getting overloaded. When the server reaches around 20 players, everyone will lag horrendously for the first 10 seconds or so. After that, everything is fine.

    Any ideas?

    Thanks
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events