1. Post #1
    taste the salty dong
    Remscar's Avatar
    September 2009
    1,822 Posts

    March 2012 Edition

    Lua questions that don't deserve their own thread go here.
    This means things like:
    How to add jobs in DarkRP,
    Where to find PERP,
    A way to stop a player opening the console or main menu,
    getting rid of that ugly ass material and rounded box in the bottom left hand corner,
    a way to detect if the mouse cursor is enabled,
    How to shoot ponies out of a gun.
    and if your IQ is above 30, then things like why vehicles aren't working on Linux servers.

    COOL STUFF TO LOOK AT!
    General Faqs: http://www.facepunch.com/threads/868...EAD-THIS-FIRST
    HOW TO LUA?: http://wiki.garrysmod.com/?title=Lua_Tutorial_Series
    GLUA WIKI: http://wiki.garrysmod.com

    Previous threads that your probably wont look at:
    Thread 1
    Thread 2
    Thread 3
    Reply With Quote Edit / Delete Windows 7 United States Show Events Optimistic x 3Dumb x 3Agree x 1Friendly x 1Lua Helper x 1Useful x 1 (list)

  2. Post #2
    Title

    August 2009
    301 Posts
    May aswell start this off, I have this function from a script that Add's XP when you kill an NPC/Player.

    function AddEXP( ply, hitgroup, dmginfo )
    	local attacker = dmginfo:GetAttacker()
    	if attacker:IsPlayer() then
    		if EXP_STOPATMAX == 1 and attacker:GetNWInt("CurLevel") == levelups[table.Count(levelups)] then return end
    		attacker:SetNWInt("Exp",attacker:GetNWInt("Exp")+EXP_INC)
    		
    		if table.HasValue(levelups,attacker:GetNWInt("Exp")) then
    			local leveln = 1
    			for k,v in ipairs(levelups) do if v == attacker:GetNWInt("Exp") then leveln = k end end
    			if leveln == table.Count(levelups) then PrintAll(attacker:Name().." has reached the maximum level!") 
    			else PrintAll(attacker:GetName().." has now reached level "..leveln.."!") end
    			attacker:SetNWInt("NextLevel",levelups[leveln+1])
    			attacker:SetNWInt("CurLevel",levelups[leveln])
    			attacker:SetNWInt("LevelNum",leveln)
    			attacker:SendLua("surface.PlaySound(\"achievements/achievement_earned.mp3\")")
    		end
    		
    	end
    end
    

    I'm needing a function so I can easily call ply:AddXP(amount of XP) or AddXP(ply, amount of XP) in my entire gamemode. I can see this
    attacker:SetNWInt("Exp",attacker:GetNWInt("Exp")+EXP_INC)
    

    I know this sets there XP, but does the code below check if there XP has gotten enough for the next level? That would be pretty annoying to include that every time I increase there XP.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Dumb Dumb x 1 (list)

  3. Post #3
    Ask me about my ex-boyfriend being raided by the FBI
    Nerdeboy's Avatar
    August 2009
    1,862 Posts
    question about xp
    The problem with your code below is that it's checking if they have the exact amount of experience needed to level up. For example, if I have 900 xp, and need 1000 to level up, and killing this NPC gives me 100, then I will level up and everything works. But if killing the NPC gives me 180, I won't level up until I hit the next marker exactly.

    Also, unrelated, but I recommend making EXP_STOPATMAX into a boolean instead of an integer.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  4. Post #4
    Title

    August 2009
    301 Posts
    The problem with your code below is that it's checking if they have the exact amount of experience needed to level up. For example, if I have 900 xp, and need 1000 to level up, and killing this NPC gives me 100, then I will level up and everything works. But if killing the NPC gives me 180, I won't level up until I hit the next marker exactly.

    Also, unrelated, but I recommend making EXP_STOPATMAX into a boolean instead of an integer.
    Oh I see what you mean, just now with this script 1 hit = 1xp so I would never have found that bug. How should I go about doing it? I've never really messed with something like this before.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  5. Post #5
    "The superior man understands what is right; the inferior man understands what will sell"
    Chessnut's Avatar
    August 2011
    3,559 Posts
    Just check if the value is equal to or greater than.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 1 (list)

  6. Post #6
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,852 Posts
    then things like why vehicles aren't working on Linux servers.
    if only someone would actually fix this it wouldn't need to be asked
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  7. Post #7
    taste the salty dong
    Remscar's Avatar
    September 2009
    1,822 Posts
    if only someone would actually fix this it wouldn't need to be asked
    Its sorta up to Garry.


    OT: Someone always rates the OP dumb...
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  8. Post #8
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,852 Posts
    Its sorta up to Garry.

    OT: Someone always rates the OP dumb...
    and it's not like garry doesn't know about it, he personally locked two or three of my threads about it because they all turned into flame wars...

    and don't feel bad, CmdrMatthew rated Niggles V3 dumb too :(
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  9. Post #9
    Fight for justice, fight for Manning and Snowden.
    Persious's Avatar
    April 2010
    2,597 Posts
    Fast question, is there a list of sounds in GMod somewhere?
    Reply With Quote Edit / Delete Windows 7 Faroe Islands Show Events

  10. Post #10
    jakeabbott96's Avatar
    June 2011
    529 Posts
    Hey there. I just started Lua literally the other day and I need some stupid help from someone with half more of a brain than myself.

    I'm making a really, really basic Derma panel so I can try and learn some Lua. I'm trying to make it so clicking the button will give me armour. That is literally all I need.

    http://maurits.tv/data/garrysmod/wik...Guide_to_Derma

    That's the link I'm using to make the script in.

    Code:
    local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself
    DermaPanel:SetPos( 50,50 ) -- Position on the players screen
    DermaPanel:SetSize( 1000, 900 ) -- Size of the frame
    DermaPanel:SetTitle( "Testing Derma Stuff" ) -- Title of the frame
    DermaPanel:SetVisible( true )
    DermaPanel:SetDraggable( true ) -- Draggable by mouse?
    DermaPanel:ShowCloseButton( true ) -- Show the close button?
    DermaPanel:MakePopup() -- Show the frame
    
    local DermaButton = vgui.Create( "DButton" )
    DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
    DermaButton:SetText( "Give ammo." )
    DermaButton:SetPos( 25, 50 )
    DermaButton:SetSize( 150, 50 )
    DermaButton.DoClick = function ()
        RunConsoleCommand( "givecurrentammo" ) -- What happens when you press the button
    end
    
    local DermaButton = vgui.Create( "DButton" )
    DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
    DermaButton:SetText( "Give armour." )
    DermaButton:SetPos( 200, 50 )
    DermaButton:SetSize( 150, 50 )
    DermaButton.DoClick = function ()
        RunConsoleCommand(  )
    end
    That's the script.

    Rate me boxes.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Winner Winner x 1 (list)

  11. Post #11
    Title

    August 2009
    301 Posts
    -snip-
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  12. Post #12
    Is there anyway to get a props weight or even size?
    Reply With Quote Edit / Delete Windows XP United States Show Events

  13. Post #13
    Reply With Quote Edit / Delete Windows 7 United States Show Events Friendly Friendly x 1 (list)

  14. Post #14
    Hey there. I just started Lua literally the other day and I need some stupid help from someone with half more of a brain than myself.

    I'm making a really, really basic Derma panel so I can try and learn some Lua. I'm trying to make it so clicking the button will give me armour. That is literally all I need.

    http://maurits.tv/data/garrysmod/wik...Guide_to_Derma

    That's the link I'm using to make the script in.

    Code:
    local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself
    DermaPanel:SetPos( 50,50 ) -- Position on the players screen
    DermaPanel:SetSize( 1000, 900 ) -- Size of the frame
    DermaPanel:SetTitle( "Testing Derma Stuff" ) -- Title of the frame
    DermaPanel:SetVisible( true )
    DermaPanel:SetDraggable( true ) -- Draggable by mouse?
    DermaPanel:ShowCloseButton( true ) -- Show the close button?
    DermaPanel:MakePopup() -- Show the frame
    
    local DermaButton = vgui.Create( "DButton" )
    DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
    DermaButton:SetText( "Give ammo." )
    DermaButton:SetPos( 25, 50 )
    DermaButton:SetSize( 150, 50 )
    DermaButton.DoClick = function ()
        RunConsoleCommand( "givecurrentammo" ) -- What happens when you press the button
    end
    
    local DermaButton = vgui.Create( "DButton" )
    DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
    DermaButton:SetText( "Give armour." )
    DermaButton:SetPos( 200, 50 )
    DermaButton:SetSize( 150, 50 )
    DermaButton.DoClick = function ()
        RunConsoleCommand(  )
    end
    That's the script.

    Rate me boxes.
    No reason to rate you boxes. You are trying to learn Lua/GLua. Though I will say you should of searched the wiki a little harder.

    Player.SetArmor

    If you think there might be a function for it there probably is. If it has to do with the player then search the Player library on the wiki.


    Well you got to call it serverside though.
    Reply With Quote Edit / Delete Windows XP United States Show Events

  15. Post #15
    Title

    August 2009
    301 Posts
    No reason to rate you boxes. You are trying to learn Lua/GLua. Though I will say you should of searched the wiki a little harder.

    Player.SetArmor

    If you think there might be a function for it there probably is. If it has to do with the player then search the Player library on the wiki.


    
    local ply = LocalPlayer() -- Sets the player using this script to the variable ply
    local amount = 55 -- A variable called amount storing an integer to use with SetArmor function.
    
    local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself
    DermaPanel:SetPos( 50,50 ) -- Position on the players screen
    DermaPanel:SetSize( 1000, 900 ) -- Size of the frame
    DermaPanel:SetTitle( "Testing Derma Stuff" ) -- Title of the frame
    DermaPanel:SetVisible( true )
    DermaPanel:SetDraggable( true ) -- Draggable by mouse?
    DermaPanel:ShowCloseButton( true ) -- Show the close button?
    DermaPanel:MakePopup() -- Show the frame
    
    local DermaButton = vgui.Create( "DButton" )
    DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
    DermaButton:SetText( "Give ammo." )
    DermaButton:SetPos( 25, 50 )
    DermaButton:SetSize( 150, 50 )
    DermaButton.DoClick = function ()
    
         RunConsoleCommand( "givecurrentammo" ) -- What happens when you press the button
    
    end
    
    local DermaButton = vgui.Create( "DButton" )
    DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
    DermaButton:SetText( "Give armour." )
    DermaButton:SetPos( 200, 50 )
    DermaButton:SetSize( 150, 50 )
    DermaButton.DoClick = function ()
    
            ply:SetArmor(amount) -- Player.SetArmor()  You change Player to the variable holding the LocalPlayer and insert the variable (or just a number) of the amount you want.
    
    end

    That's what I originally posted above, but I thought this derma script was Client sided? SetArmour is Server sided. I'm probably wrong but just a thought.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  16. Post #16
    That's what I originally posted above, but I thought this derma script was Client sided? SetArmour is Server sided. I'm probably wrong but just a thought.
    It's shared I believe.
    Reply With Quote Edit / Delete Windows XP United States Show Events

  17. Post #17
    Title

    August 2009
    301 Posts
    It's shared I believe.
    http://maurits.tv/data/garrysmod/wik...layer.SetArmor
    is server sided

    But checking the Client's armour is shared.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  18. Post #18
    http://maurits.tv/data/garrysmod/wik...layer.SetArmor
    is server sided

    But checking the Client's armour is shared.
    Well then ignore what I said.

    He will need to call it serverside then.
    Reply With Quote Edit / Delete Windows XP United States Show Events

  19. Post #19
    jakeabbott96's Avatar
    June 2011
    529 Posts
    -snip-
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  20. Post #20
    Title

    August 2009
    301 Posts
    The problem with your code below is that it's checking if they have the exact amount of experience needed to level up. For example, if I have 900 xp, and need 1000 to level up, and killing this NPC gives me 100, then I will level up and everything works. But if killing the NPC gives me 180, I won't level up until I hit the next marker exactly.

    Also, unrelated, but I recommend making EXP_STOPATMAX into a boolean instead of an integer.
    I see what you mean, I tried doing this:

    function AddEXP( ply, args )
    		ply:SetNWInt("Exp",ply:GetNWInt("Exp")+args)
    
    		if table.HasValue(levelups,ply:GetNWInt("Exp")) then
    			local leveln = 1
    			for k,v in ipairs(levelups) do if v == ply:GetNWInt("Exp") then leveln = k end end
    			if leveln == table.Count(levelups) then PrintAll(ply:Name().." has reached the maximum level!") 
    			else PrintAll(ply:GetName().." has now reached level "..leveln.."!") end
    			ply:SetNWInt("NextLevel",levelups[leveln+1])
    			ply:SetNWInt("CurLevel",levelups[leveln])
    			ply:SetNWInt("LevelNum",leveln)
    			ply:SendLua("surface.PlaySound(\"achievements/achievement_earned.mp3\")")
    		end	
    end
    

    And got the bug that you mentioned. I'm not entirely sure on how to fix this, Line 6 is what checks right?

    I also tested it by calling it with
    concommand.Add("exp_setlevel",function(ply,cmd,args)
    	if ply:IsAdmin() then
    		AddEXP( ply, tonumber(args[1]) )
    	end
    end)
    table.insert(chatcommands,{"setlevel","exp_setlevel"})
    

    It works but my XP goes over the needed amount as you said it would.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  21. Post #21

    May 2006
    24 Posts
    I see what you mean, I tried doing this:

    function AddEXP( ply, args )
    		ply:SetNWInt("Exp",ply:GetNWInt("Exp")+args)
    
    		if table.HasValue(levelups,ply:GetNWInt("Exp")) then
    			local leveln = 1
    			for k,v in ipairs(levelups) do if v == ply:GetNWInt("Exp") then leveln = k end end
    			if leveln == table.Count(levelups) then PrintAll(ply:Name().." has reached the maximum level!") 
    			else PrintAll(ply:GetName().." has now reached level "..leveln.."!") end
    			ply:SetNWInt("NextLevel",levelups[leveln+1])
    			ply:SetNWInt("CurLevel",levelups[leveln])
    			ply:SetNWInt("LevelNum",leveln)
    			ply:SendLua("surface.PlaySound(\"achievements/achievement_earned.mp3\")")
    		end	
    end
    

    And got the bug that you mentioned. I'm not entirely sure on how to fix this, Line 6 is what checks right?

    I also tested it by calling it with
    concommand.Add("exp_setlevel",function(ply,cmd,args)
    	if ply:IsAdmin() then
    		AddEXP( ply, tonumber(args[1]) )
    	end
    end)
    table.insert(chatcommands,{"setlevel","exp_setlevel"})
    

    It works but my XP goes over the needed amount as you said it would.
    Instead check to see if the XP is greater than or equal to, not if it is exactly equal to. Also, do you need to store all of that information in NWInts. All you really need is one NWInt, since NextLevel and CurLevel are both based on LevelNum.. If the levelups table exists clientside, you can just get the rest of that information clientside as well.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  22. Post #22
    jakeabbott96's Avatar
    June 2011
    529 Posts
    I tried at the armour again, but I got a new error:

    [lua\derma.lua:31] attempt to call method 'SetArmor' (a nil value)

    Code:
    local ply = LocalPlayer(Player) -- Sets the player using this script to the variable ply
    local amount = 55 -- A variable called amount storing an integer to use with SetArmor function.
     
    local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself
    DermaPanel:SetPos( 50,50 ) -- Position on the players screen
    DermaPanel:SetSize( 1000, 900 ) -- Size of the frame
    DermaPanel:SetTitle( "Testing Derma Stuff" ) -- Title of the frame
    DermaPanel:SetVisible( true )
    DermaPanel:SetDraggable( true ) -- Draggable by mouse?
    DermaPanel:ShowCloseButton( true ) -- Show the close button?
    DermaPanel:MakePopup() -- Show the frame
     
    local DermaButton = vgui.Create( "DButton" )
    DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
    DermaButton:SetText( "Give ammo." )
    DermaButton:SetPos( 25, 50 )
    DermaButton:SetSize( 150, 50 )
    DermaButton.DoClick = function ()
     
         RunConsoleCommand( "givecurrentammo" ) -- What happens when you press the button
     
    end
     
    local DermaButton = vgui.Create( "DButton" )
    DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
    DermaButton:SetText( "Give armour." )
    DermaButton:SetPos( 200, 50 )
    DermaButton:SetSize( 150, 50 )
    DermaButton.DoClick = function ()
     
            ply:SetArmor(100) -- Player.SetArmor()  You change Player to the variable holding the LocalPlayer and insert the variable (or just a number) of the amount you want.
     
    end
    I'm trying to make clicking the button give me, the player and client, some armour.
    I'm very new to Lua, by the by.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  23. Post #23
    ASK ME ABOUT MY SAM 6420 FETISH
    ArmageddonScr's Avatar
    July 2011
    691 Posts
    you're trying to use SetArmor on the client. You have to use it on the server. In a shared file, this is what your code would look like.
    if SERVER then 
        concommand.Add("setarmor",function(pl) 
           pl:SetArmor(100) 
        end) 
    else
        --menu code here, and
        DermaButton.DoClick=function() 
           RunConsoleCommand("setarmor") 
        end
    end
    
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  24. Post #24
    Cold Member
    Joshua Raphael's Avatar
    November 2011
    502 Posts
    Fast question, is there a list of sounds in GMod somewhere?
    Half-Life 2 Sound List
    Reply With Quote Edit / Delete Windows Vista United States Show Events

  25. Post #25
    jakeabbott96's Avatar
    June 2011
    529 Posts
    you're trying to use SetArmor on the client. You have to use it on the server. In a shared file, this is what your code would look like.
    if SERVER then 
        concommand.Add("setarmor",function(pl) 
           pl:SetArmor(100) 
        end) 
    else
        --menu code here, and
        DermaButton.DoClick=function() 
           RunConsoleCommand("setarmor") 
        end
    end
    
    The console says there is no "setarmor" command.

    local ply = LocalPlayer(Player) -- Sets the player using this script to the variable ply
    local amount = 55 -- A variable called amount storing an integer to use with SetArmor function.
     
    local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself
    DermaPanel:SetPos( 50,50 ) -- Position on the players screen
    DermaPanel:SetSize( 1000, 900 ) -- Size of the frame
    DermaPanel:SetTitle( "Derma panel." ) -- Title of the frame
    DermaPanel:SetVisible( true )
    DermaPanel:SetDraggable( true ) -- Draggable by mouse?
    DermaPanel:ShowCloseButton( true ) -- Show the close button?
    DermaPanel:MakePopup() -- Show the frame
     
    local DermaButton = vgui.Create( "DButton" )
    DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
    DermaButton:SetText( "Give ammo." )
    DermaButton:SetPos( 25, 50 )
    DermaButton:SetSize( 150, 50 )
    DermaButton.DoClick = function ()
     
         RunConsoleCommand( "givecurrentammo" ) -- What happens when you press the button
     
    end
     
    
    
    if SERVER then
        concommand.Add("setarmor",function(pl) 
           pl:SetArmor(100) 
        end) 
    else
       local DermaButton = vgui.Create( "DButton" )
    DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel"
    DermaButton:SetText( "Give armour." )
    DermaButton:SetPos( 200, 50 )
    DermaButton:SetSize( 150, 50 ) --menu code here, and
        DermaButton.DoClick=function() 
           RunConsoleCommand("setarmor") 
        end
    end
    
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  26. Post #26
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,852 Posts
    you are only running this on the client...
    Reply With Quote Edit / Delete Linux United States Show Events

  27. Post #27
    jakeabbott96's Avatar
    June 2011
    529 Posts
    you are only running this on the client...
    I'm totally new to Lua. This is just my first attempt at actually trying to produce anything.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  28. Post #28
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,852 Posts
    I'm totally new to Lua. This is just my first attempt at actually trying to produce anything.
    well, I'll try to explain, the concepts are pretty simple

    lua/autorun - files in this are run on the client and server
    lua/autorun/client - files in this are run ONLY on the client
    lua/autorun/server - files in this are run ONLY on the server

    you should probably put your menu stuff in autorun/client and serverside stuff in autorun/server
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  29. Post #29
    jakeabbott96's Avatar
    June 2011
    529 Posts
    well, I'll try to explain, the concepts are pretty simple

    lua/autorun - files in this are run on the client and server
    lua/autorun/client - files in this are run ONLY on the client
    lua/autorun/server - files in this are run ONLY on the server

    you should probably put your menu stuff in autorun/client and serverside stuff in autorun/server
    Okay, that I can understand. But why isn't the Lua script working?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  30. Post #30
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,852 Posts
    Okay, that I can understand. But why isn't the Lua script working?
    because you only ran that script on the client, so the server bit didn't run
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  31. Post #31
    jakeabbott96's Avatar
    June 2011
    529 Posts
    because you only ran that script on the client, so the server bit didn't run
    Specifically, where should I put and what should the code be?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  32. Post #32
    JustSoFaded's Avatar
    December 2011
    432 Posts
    lua/autorun
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  33. Post #33
    Mrwhitee's Avatar
    January 2012
    31 Posts
    my server been having some problems with random crashes this is what happends in Conlog before crash
    [03:38] Dropped [LADS]Chew-tah-lue from server (Disconnect by user.)
    [03:38] Client "[LADS]Chew-tah-lue" connected (70.15.27.134:27005).
    [03:38] Attempted to create unknown entity type !
    [03:38] NULL Ent in GiveNamedItem!
    [03:38] xX|HawX|x<STEAM_0:0:24073445> spawned model models/props_c17/furniturecouch001a.mdl
    [03:39] Azrim removed prop_physics
    [03:39] xX|HawX|x<STEAM_0:0:24073445> spawned model models/props_c17/furniturefireplace001a.mdl
    [03:39] xX|HawX|x<STEAM_0:0:24073445> spawned model models/props_junk/popcan01a.mdl
    [03:39] xX|HawX|x<STEAM_0:0:24073445> spawned model models/props_junk/popcan01a.mdl
    [03:39] xX|HawX|x<STEAM_0:0:24073445> spawned model models/props_junk/popcan01a.mdl
    [03:39] xX|HawX|x<STEAM_0:0:24073445> spawned model models/props_junk/popcan01a.mdl
    [03:39] xX|HawX|x<STEAM_0:0:24073445> spawned model models/props_junk/popcan01a.mdl
    [03:39] xX|HawX|x<STEAM_0:0:24073445> spawned model models/props_junk/popcan01a.mdl
    [03:39] xX|HawX|x<STEAM_0:0:24073445> spawned model models/props_junk/popcan01a.mdl
    [03:39] xX|HawX|x<STEAM_0:0:24073445> spawned model models/props_junk/popcan01a.mdl
    [03:39] xX|HawX|x<STEAM_0:0:24073445> spawned model models/props_junk/popcan01a.mdl
    [03:39] xX|HawX|x<STEAM_0:0:24073445> spawned model models/props_junk/popcan01a.mdl
    [03:39] xX|HawX|x<STEAM_0:0:24073445> spawned model models/props_junk/popcan01a.mdl
    [03:39] xX|HawX|x<STEAM_0:0:24073445> spawned model models/props_junk/popcan01a.mdl
    [03:39] xX|HawX|x<STEAM_0:0:24073445> spawned model models/props_junk/popcan01a.mdl
    [03:39] xX|HawX|x<STEAM_0:0:24073445> spawned model models/props_junk/popcan01a.mdl
    [03:40] ^1.:CD:. ^0Giflen<STEAM_0:0:40005235> spawned model models/props_c17/furnituresink001a.mdl
    [03:40] Entity 783 (class 'prop_physics') reported ENTITY_CHANGE_NONE but 'm_hEffectEntity' changed.
    [03:40] Entity 1048 (class 'prop_physics') reported ENTITY_CHANGE_NONE but 'm_hEffectEntity' changed.
    [03:40] Entity 653 (class 'prop_physics') reported ENTITY_CHANGE_NONE but 'm_hEffectEntity' changed.
    [03:40] attempt to
    [03:40] Lua Error Dump
    hope u guys can help abit
    Reply With Quote Edit / Delete Windows 7 Denmark Show Events

  34. Post #34
    sciaschi's Avatar
    March 2011
    76 Posts
    i need help fixing my rounds.lua...
    i have most of it right and aif u can optimize it please do i need to have it so that when a 2 players become a class they spawn at a certain position and i set v:SetPos and still didnt work

    MAX_ROUNDS = 3
    ROUND_TIME = 300 --In Seconds
    ROUND_TIMELEFT = -1
    ROUND_BREAK = 30 --Seconds
    local CurRound = 0;
      
    function ROUND_REACHED()
        -- Add some event when Current Round Reach the Max Rounds.
        -- If you have map vote thing, add it.
        -- If you need to change specific map, just add here.
        ROUND_MESSEGE( "Max Round reached. Calling Round End Event." )
    end
      
    function ROUND_MULTIPLAYER() 
        if (#player.GetAll() == 2) then
            ROUND_MESSEGE( "Starting New Round in few seconds." )
              
            timer.Simple(8,ROUND_WAIT)
        end;
    end
    --hook.Add("PlayerInitialSpawn", "ROUND_MP", ROUND_MULTIPLAYER)
      
    function ROUND_END()
        ROUND_MESSEGE( "New round starting. Prepare." )
         timer.Simple(5,ROUND_RESTART)
    end
      
    function ROUND_RESTART()
        game.CleanUpMap(); -- Reset all map entities. if you don't want it, just delete this line.
        -- Add some event when new round start.
          
        for k, v in ipairs(player.GetAll()) do
        if v:Team() == TEAM_Boxer then
         v:SetPos(Vector(12.404461,-11.611498,95.531250))
        end;
          
        if (MAX_ROUNDS == CurRound) then
            ROUND_REACHED()
        end;
          
        CurRound  = CurRound + 1;
    end
     end
      
    function ROUND_MESSEGE( say )
        for k, v in ipairs(player.GetAll()) do
           v:PrintMessage(HUD_PRINTTALK, tostring(say));
        end;
    end
     
    function ROUND_START()
         for k, v in pairs(player.GetAll()) do
         if v:Team() == TEAM_Boxer then
         v:SetPos(Vector(12.404461,-11.611498,95.531250))
         end
         ROUND_MESSEGE( "Round Starting" )
         ROUND_TIMELEFT = ROUND_TIME
         end
    end
          
          
    function ROUND_HANDLE()
        if (ROUND_TIMELEFT == -1) then -- Start the first round
            ROUND_WAIT()
            return end
         
        ROUND_TIMELEFT = ROUND_TIMELEFT - 1
         
        if (ROUND_TIMELEFT == 0) then
            if (ROUND_BREAK) then
                ROUND_START()
                ROUND_BREAK = false
            else
                ROUND_END()
                ROUND_BREAK = true
            end
        end
    end
     
    timer.Create("ROUND_HANDLE", 1, 0, ROUND_HANDLE)
     
    function ROUND_WAIT()
        if (#player.GetAll() <= 1) then
        ROUND_MESSEGE( "Need More Boxers To Start.")
        else if (#player.GetAll() == 2) then
        ROUND_MESSEGE( "Please Wait..." )
        timer.Simple(1,ROUND_START)
         end
       end
    end
    
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  35. Post #35

    February 2010
    129 Posts
    Is there a way to have multi colored text using only one DLabel?
    I didn't want to use 3 DLabels to do something like: I Like Potatos
    The "I" in red, the "Like" in white and the "Potatos" in blue
    Reply With Quote Edit / Delete Windows 7 Brazil Show Events Disagree Disagree x 1Dumb Dumb x 1 (list)

  36. Post #36
    Phaesol's Avatar
    March 2012
    46 Posts
    I'm making a small deathmatch gamemode for mostly educational purposes

    team.SetUp( 1, "Red Team", Color( 255, 99, 71, 255 ) )
    team.SetUp( 2, "Blu Team", Color( 65, 105, 255, 255 ) )

    That's kind of how my teams are created, but how can I add something so that players can't damage other players on their team? (stop friendly fire)

    Thanks facepunch :D
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  37. Post #37
    Ask me about my ex-boyfriend being raided by the FBI
    Nerdeboy's Avatar
    August 2009
    1,862 Posts
    function GM:PlayerShouldTakeDamage( ply, att )
    	return not (ply:Team() == att:Team())
    end

    Adding this to a serverside file will disable friendly fire.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Lua Helper Lua Helper x 1 (list)

  38. Post #38
    Phaesol's Avatar
    March 2012
    46 Posts
    function GM:PlayerShouldTakeDamage( ply, att )
    	return not (ply:Team() == att:Team())
    end

    Adding this to a serverside file will disable friendly fire.
    I keep getting "[gamemodes\TestDeathmatch\gamemode\init.lua:176] attempt to call method 'team' (a nil value)(Hook: PlayerShouldTakeDamage)" in console when I try to take damage.

    Also I can't figure out how to remove the default health/suit/ammo gui
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  39. Post #39
    "The superior man understands what is right; the inferior man understands what will sell"
    Chessnut's Avatar
    August 2011
    3,559 Posts
    Reply With Quote Edit / Delete Windows 7 United States Show Events Lua Helper Lua Helper x 1 (list)

  40. Post #40
    Fight for justice, fight for Manning and Snowden.
    Persious's Avatar
    April 2010
    2,597 Posts
    local tohide = { -- This is a table where the keys are the HUD items to hide
    	["CHudHealth"] = true,
    	["CHudBattery"] = true,
    	["CHudAmmo"] = true,
    	["CHudSecondaryAmmo"] = true
    }
    local function HUDShouldDraw(name) -- This is a local function because all functions should be local unless another file needs to run it
    	if (tohide[name]) then     -- If the HUD name is a key in the table
    		return false;      -- Return false.
    	end
    end
    hook.Add("HUDShouldDraw", "How to: HUD Example HUD hider", HUDShouldDraw)
    

    Taken from the wiki.

    Ninja'd :[
    Reply With Quote Edit / Delete Windows 7 Faroe Islands Show Events Lua Helper Lua Helper x 1 (list)