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

    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,
    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
    Reply With Quote Edit / Delete Windows 7 United States Show Events Lua Helper x 10Dumb x 4Funny x 2Agree x 2Lua King x 2Useful x 1 (list)

  2. Post #2
    Gold Member
    Hyper Iguana's Avatar
    March 2011
    700 Posts
    Where do I find PERP?
    Reply With Quote Edit / Delete Windows Vista United States Show Events Funny x 16Lua King x 4Optimistic x 1Useful x 1Dumb x 1 (list)

  3. Post #3
    R@Rdeathmatch's Avatar
    November 2010
    860 Posts
    Where do I find PERP?
    on dramaunlimited :D
    lol
    Reply With Quote Edit / Delete Windows XP Romania Show Events Useful x 1Lua Helper x 1Agree x 1Winner x 1Funny x 1Lua King x 1Disagree x 1 (list)

  4. Post #4
    R@Rdeathmatch's Avatar
    November 2010
    860 Posts
    1.
    Could someone give me a link were I can find gui.OpenURL?
    Cause I want to creat a button that ween is pressed will open a webpage.
    2.
    Is there any tutorial how to creat circle ?
    Reply With Quote Edit / Delete Windows XP Romania Show Events Dumb Dumb x 3 (list)

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

  6. Post #6
    Title

    August 2009
    300 Posts
    My other thread like, died or something so This is what I have just now:

    hook.Add("PhysgunPickup", "SetVarOn", function(ply, ent)
    	ent.DontPush = 1
    end)
    hook.Add("PhysgunDrop", "SetVarOff", function(ply, ent)
    	ent.DontPush = 0
    end)
    hook.Add( "ShouldCollide", "StopMinges", function(ent1,ent2)
    	if (ent1.DontPush == 1 || ent2.DontPush == 1) and (ent1:IsPlayer() || ent2:IsPlayer())  then
    
    		ent1:SetColor( 255, 255, 255, 200 )
    		return false
    		else
    		ent1:SetColor( 255, 255, 255, 255 )
    	end
    end)
    

    Problem is, it goes through players but if it collides with something or someone shoots someone they go ghosted. I need the prop you pick up to only nocollide with players and not any other props.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  7. Post #7
    R@Rdeathmatch's Avatar
    November 2010
    860 Posts
    Abot the Gui.OpenURL. After I creat the button using vgui.creat
    Tab = vgui.Create( "DPropertySheet")
    		Tab:SetParent( Banner )
    		Tab:SetPos( 248, 120 )
    		Tab:SetSize( 215, 60 )
    
    And someone told me that I need to creat a GUI.Panel, and is not possible to add gui.OpenURL inside the button.

    Edited:

    And I want to ask if is possible to add Custom Font.
    Reply With Quote Edit / Delete Windows XP Romania Show Events Dumb Dumb x 1 (list)

  8. Post #8
    Gold Member
    BlackAwps's Avatar
    July 2011
    765 Posts
    My other thread like, died or something so This is what I have just now:

    -code snip-

    Problem is, it goes through players but if it collides with something or someone shoots someone they go ghosted. I need the prop you pick up to only nocollide with players and not any other props.
    Don't set the color in the collision hook. Also, changing the collisions like that would normally break the physics engine.

    function _R.Entity:CollisionRulesChanged() -- [url]http://www.facepunch.com/threads/1150631[/url]
        -- HACK!
        local cg = self:GetCollisionGroup()
        self:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
        self:SetCollisionGroup(cg)
    end
    
    hook.Add("PhysgunPickup", "SetVarOn", function(ply, ent)
        ent.DontPush = true
    	ent:SetColor( 255, 255, 255, 200 )
    	ent:CollisionRulesChanged()
    end)
    
    hook.Add("PhysgunDrop", "SetVarOff", function(ply, ent)
        ent.DontPush = false
    	ent:SetColor( 255, 255, 255, 255 )
    	ent:CollisionRulesChanged()
    end)
    
    hook.Add( "ShouldCollide", "StopMinges", function(ent1,ent2)
        if (ent1.DontPush || ent2.DontPush) and (ent1:IsPlayer() || ent2:IsPlayer()) then
            return false
        end
    end)

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

  9. Post #9
    Gold Member
    Killer_Steel's Avatar
    October 2007
    1,362 Posts
    Anyone know of an up-to-date list of particle effects in HL2 that doesn't involve me going to the game's internal editor?

    Just need some debug particles that look semi-pretty.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  10. Post #10

    January 2012
    12 Posts
    I need help taking the blood effect and setting it to follow dead bodies. (ParticleEffectAttach)
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  11. Post #11
    Jinx786's Avatar
    October 2010
    380 Posts
    How would I create a simple speedometer that shows speed on a cars dashboard in digital (a number)? Thanks.
    Reply With Quote Edit / Delete Windows 7 Slovenia Show Events

  12. Post #12

    August 2011
    63 Posts
    Guys this is "help with" thread, not "ask for people to do it for you" thread, go do your homework and come back asking why something is not working as you think it would!
    @Killer_Steel: The Source engine wiki has a complete list of effects, google it
    @Mogarf: Read the gmod Lua wiki, there should be some pointers on how to use the particle functions around there
    @Jinx786: I'd suggest you read the HUD tutorials in the wiki and then read a bit of the "ent" class, you should be able to figure it out from there.
    Reply With Quote Edit / Delete Windows 7 Venezuela Show Events Agree Agree x 2 (list)

  13. Post #13
    "The superior man understands what is right; the inferior man understands what will sell"
    Chessnut's Avatar
    August 2011
    3,509 Posts
    Abot the Gui.OpenURL. After I creat the button using vgui.creat
    Tab = vgui.Create( "DPropertySheet")
    		Tab:SetParent( Banner )
    		Tab:SetPos( 248, 120 )
    		Tab:SetSize( 215, 60 )
    
    And someone told me that I need to creat a GUI.Panel, and is not possible to add gui.OpenURL inside the button.

    Edited:

    And I want to ask if is possible to add Custom Font.
    http://maurits.tv/data/garrysmod/wik...=Panel.SetHTML

    http://maurits.tv/data/garrysmod/wik...ace.CreateFont

    Are you even trying to search for these, at all?
    Reply With Quote Edit / Delete United States Show Events Agree Agree x 1Lua Helper Lua Helper x 1 (list)

  14. Post #14
    R@Rdeathmatch's Avatar
    November 2010
    860 Posts
    Yes i'm trying but gmod.wiki is not working properly.

    Edited:

    About Custom Font, I don't want to add this : http://maurits.tv/data/garrysmod/wik...ing_with_Fonts
    I want to try this.http://www.dafont.com/batman-forever.font
    Reply With Quote Edit / Delete Windows XP Romania Show Events

  15. Post #15
    Fight for justice, fight for Manning and Snowden.
    Persious's Avatar
    April 2010
    2,581 Posts
    Reply With Quote Edit / Delete Windows 7 Faroe Islands Show Events Agree Agree x 1 (list)

  16. Post #16
    "The superior man understands what is right; the inferior man understands what will sell"
    Chessnut's Avatar
    August 2011
    3,509 Posts
    If you do not understand, the first argument is the (custom) font.
    Since clients probbly do not have the custom font, you have to resource.AddFile it.
    Custom fonts go into resources/fonts.
    Reply With Quote Edit / Delete United States Show Events

  17. Post #17
    R@Rdeathmatch's Avatar
    November 2010
    860 Posts
    If you do not understand, the first argument is the (custom) font.
    Since clients probbly do not have the custom font, you have to resource.AddFile it.
    Custom fonts go into resources/fonts.
    This is everything what I want to know. Thx
    Reply With Quote Edit / Delete Windows XP Romania Show Events

  18. Post #18
    Gold Member
    Dorkslayz's Avatar
    September 2009
    1,666 Posts
    Does anybody have a code snippet for a decent looking chat and scoreboard?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  19. Post #19
    JustSoFaded's Avatar
    December 2011
    432 Posts
    Does anybody have a code snippet for a decent looking chat and scoreboard?
    That's not exactly a 'code snippet'. If either work well or are decent lookings between the 2 it will be atleast 750 lines.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  20. Post #20
    Gold Member
    Dorkslayz's Avatar
    September 2009
    1,666 Posts
    That's not exactly a 'code snippet'. If either work well or are decent lookings between the 2 it will be atleast 750 lines.
    I dont mean something really advanced, Just something that looks nice and operates like the normal GMod Chat and Scoreboard.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  21. Post #21
    Jinx786's Avatar
    October 2010
    380 Posts
    I'd suggest you read the HUD tutorials in the wiki and then read a bit of the "ent" class, you should be able to figure it out from there.
    Thanks, this helped a little bit but could you give me a hint on how to get the current velocity? Thanks!
    Reply With Quote Edit / Delete Windows 7 Slovenia Show Events

  22. Post #22
    sintwins's Avatar
    November 2009
    712 Posts
    Just wondering whether there is a way to stop a player opening the console or main menu?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Agree Agree x 1 (list)

  23. Post #23
    R@Rdeathmatch's Avatar
    November 2010
    860 Posts
    I dont mean something really advanced, Just something that looks nice and operates like the normal GMod Chat and Scoreboard.
    I start to creat a Custom ScoreBoard for Deathrun or for other gamemodes that have 2 team.
    Reply With Quote Edit / Delete Windows XP Romania Show Events Dumb Dumb x 1 (list)

  24. Post #24
    Title

    August 2009
    300 Posts
    Rather long post, but what I'm aiming for is to display Text over the job "Icon" so you can see what the job title is without having to put your mouse over it. I cant find the exact place in this function to do this. (This is for the Darkrp F4 job menu)

    function JobsTab()
    	local hordiv = vgui.Create("DHorizontalDivider")
    	hordiv:SetLeftWidth(370)
    	function hordiv.m_DragBar:OnMousePressed() end
    	hordiv.m_DragBar:SetCursor("none")
    	local Panel
    	local Information
    	function hordiv:Update()
    		if Panel and Panel:IsValid() then
    			Panel:Remove()
    		end
    		Panel = vgui.Create( "DPanelList")
    		Panel:SetSize(370, 540)
    		Panel:SetSpacing(1)
    		Panel:EnableHorizontal( true )
    		Panel:EnableVerticalScrollbar( true )
    		Panel:SetSkin("DarkRP")
    		
    		
    		local Info = {}
    		local model
    		local modelpanel
    		local function UpdateInfo(a)
    			if Information and Information:IsValid() then
    				Information:Remove()
    			end
    			Information = vgui.Create( "DPanelList" )
    			Information:SetPos(378,0)
    			Information:SetSize(370, 540)
    			Information:SetSpacing(10)
    			Information:EnableHorizontal( false )
    			Information:EnableVerticalScrollbar( true )
    			Information:SetSkin("DarkRP")
    			function Information:Rebuild() -- YES IM OVERRIDING IT AND CHANGING ONLY ONE LINE BUT I HAVE A FUCKING GOOD REASON TO DO IT!
    				local Offset = 0
    				if ( self.Horizontal ) then
    					local x, y = self.Padding, self.Padding;
    					for k, panel in pairs( self.Items ) do
    						local w = panel:GetWide()
    						local h = panel:GetTall()
    						if ( x + w  > self:GetWide() ) then
    							x = self.Padding
    							y = y + h + self.Spacing
    						end
    						panel:SetPos( x, y )
    						x = x + w + self.Spacing
    						Offset = y + h + self.Spacing
    					end
    				else
    					for k, panel in pairs( self.Items ) do
    						if not panel:IsValid() then return end
    						panel:SetSize( self:GetCanvas():GetWide() - self.Padding * 2, panel:GetTall() )
    						panel:SetPos( self.Padding, self.Padding + Offset )
    						panel:InvalidateLayout( true )
    						Offset = Offset + panel:GetTall() + self.Spacing
    					end
    					Offset = Offset + self.Padding	
    				end
    				self:GetCanvas():SetTall( Offset + (self.Padding) - self.Spacing ) 
    			end
    			
    			if type(Info) == "table" and #Info > 0 then
    				for k,v in ipairs(Info) do
    					local label = vgui.Create("DLabel")
    					label:SetText(v)
    					label:SizeToContents()
    					if label:IsValid() then
    						Information:AddItem(label)
    					end
    				end
    			end
    
    			if model and type(model) == "string" and a ~= false then
    				modelpanel = vgui.Create("DModelPanel")
    				modelpanel:SetModel(model)
    				modelpanel:SetSize(90,230)
    				modelpanel:SetAnimated(true)
    				modelpanel:SetFOV(90)
    				modelpanel:SetAnimSpeed(1)
    				if modelpanel:IsValid() then
    					Information:AddItem(modelpanel)
    				end
    			end
    			hordiv:SetLeft(Panel)
    			hordiv:SetRight(Information)
    		end
    		UpdateInfo()
    		
    		local function AddIcon(Model, name, description, Weapons, command, special, specialcommand)
    			local icon = vgui.Create("SpawnIcon")
    			local IconModel = Model
    			if type(Model) == "table" then
    				IconModel = Model[math.random(#Model)]
    			end
    			icon:SetModel(IconModel)
    			icon:SetIconSize(120)
    			icon:SetToolTip()
    			icon.OnCursorEntered = function()
    				icon.PaintOverOld = icon.PaintOver 
    				icon.PaintOver = icon.PaintOverHovered
    				Info[1] = LANGUAGE.job_name .. name 
    				Info[2] = LANGUAGE.job_description .. description
    				Info[3] = LANGUAGE.job_weapons .. Weapons
    				model = IconModel
    				UpdateInfo()
    			end
    			icon.OnCursorExited = function()
    				if ( icon.PaintOver == icon.PaintOverHovered ) then 
    					icon.PaintOver = icon.PaintOverOld 
    				end
    				Info = {}
    				if modelpanel and modelpanel:IsValid() and icon:IsValid() then
    					modelpanel:Remove()
    					UpdateInfo(false)
    				end
    			end
    			
    			icon.DoClick = function()
    				local function DoChatCommand(frame)
    					if special then
    						local menu = DermaMenu()
    						menu:AddOption("Vote", function() LocalPlayer():ConCommand("say "..command) frame:Close() end)
    						menu:AddOption("Do not vote", function() LocalPlayer():ConCommand("say " .. specialcommand) frame:Close() end)
    						menu:Open()
    					else
    						LocalPlayer():ConCommand("say " .. command)
    						frame:Close()
    					end
    				end
    				
    				if type(Model) == "table" and #Model > 0 then
    					hordiv:GetParent():GetParent():Close()
    					local frame = vgui.Create( "DFrame" )
    					frame:SetTitle( "Choose model" )
    					frame:SetVisible(true)
    					frame:MakePopup()
    					
    					local levels = 1
    					local IconsPerLevel = math.floor(ScrW()/64)
    					
    					while #Model * (64/levels) > ScrW() do
    						levels = levels + 1
    					end
    					frame:SetSize(math.Min(#Model * 64, IconsPerLevel*64), math.Min(90+(64*(levels-1)), ScrH()))
    					frame:Center()
    					
    					local CurLevel = 1
    					for k,v in pairs(Model) do
    						local icon = vgui.Create("SpawnIcon", frame)
    						if (k-IconsPerLevel*(CurLevel-1)) > IconsPerLevel then
    							CurLevel = CurLevel + 1
    						end
    						icon:SetPos((k-1-(CurLevel-1)*IconsPerLevel) * 64, 25+(64*(CurLevel-1)))
    						icon:SetModel(v)
    						icon:SetIconSize(64)
    						icon:SetToolTip()
    						icon.DoClick = function()
    							RunConsoleCommand("rp_playermodel", v)
    							RunConsoleCommand("_rp_ChosenModel", v)
    							DoChatCommand(frame)
    						end
    					end
    				else
    					DoChatCommand(hordiv:GetParent():GetParent())
    				end
    			end
    			
    			if icon:IsValid() then
    				Panel:AddItem(icon)
    			end
    		end
    		
    		for k,v in ipairs(RPExtraTeams) do
    			if LocalPlayer():Team() ~= k then
    				local nodude = true
    				if v.admin == 1 and not LocalPlayer():IsAdmin() then
    					nodude = false
    				end
    				if v.admin > 1 and not LocalPlayer():IsSuperAdmin() then
    					nodude = false
    				end
    				if v.customCheck and not v.customCheck(LocalPlayer()) then
    					nodude = false
    				end
    				
    				if (type(v.NeedToChangeFrom) == "number" and LocalPlayer():Team() ~= v.NeedToChangeFrom) or (type(v.NeedToChangeFrom) == "table" and not table.HasValue(v.NeedToChangeFrom, LocalPlayer():Team())) then
    					nodude = false
    				end
    				
    				if nodude then
    					local weps = "no extra weapons"
    					if #v.Weapons > 0 then
    						weps = table.concat(v.Weapons, "\n")
    					end
    					if v.Vote then
    						local condition = ((v.admin == 0 and LocalPlayer():IsAdmin()) or (v.admin == 1 and LocalPlayer():IsSuperAdmin()) or LocalPlayer().DarkRPVars["Priv"..v.command])
    						if not v.model or not v.name or not v.Des or not v.command then chat.AddText(Color(255,0,0,255), "Incorrect team! Fix your shared.lua!") return end
    						AddIcon(v.model, v.name, v.Des, weps, "/vote"..v.command, condition, "/"..v.command)
    					else
    						if not v.model or not v.name or not v.Des or not v.command then chat.AddText(Color(255,0,0,255), "Incorrect team! Fix your shared.lua!") return end
    						AddIcon(v.model, v.name, v.Des, weps, "/"..v.command)
    					end
    				end
    			end
    		end
    	end
    	hordiv:Update()
    	return hordiv
    end
    

    I've tried with icon: and Information: but cant seem to get it right. I'm not entirely sure on how to go about doing this.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  25. Post #25
    Jinx786's Avatar
    October 2010
    380 Posts
    So I was following this tutorial: http://www.youtube.com/watch?v=oZWf3flrFSg and I get this error

    Code:
    [addons\velocity\lua\autorun\velocity.lua:8] attempt to index global 'GM' (a nil value)
    (I named it velocity because I want to make a speedometer later)

    It hides the hud perfectly but then I get the error at line
    Code:
    function GM:HUDPaint()
    Any ideas why would that be? Thanks.
    Reply With Quote Edit / Delete Windows 7 Slovenia Show Events

  26. Post #26
    PROUD BRONY 4LYFE
    Drakehawke's Avatar
    February 2009
    3,312 Posts
    GM:HUDPaint is for gamemodes, which is loaded after autorun hence it's nil when your file is ran.

    Use this instead:

    hook.Add( "HUDPaint", "DrawSpeedo?", function()
    
     -- your code here
    
    end )
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events Agree Agree x 4Lua Helper Lua Helper x 1 (list)

  27. Post #27
    Mrwhitee's Avatar
    January 2012
    31 Posts
    Im kinda wondering how. to add world props to a map. that will spawn when server starts or a script that can spawn em :)
    Reply With Quote Edit / Delete Windows 7 Denmark Show Events

  28. Post #28
    PROUD BRONY 4LYFE
    Drakehawke's Avatar
    February 2009
    3,312 Posts
    Something like:

    local function CreateWorldProp( model, pos, ang )
    
        local ent = ents.Create( "prop_physics" )
        ent:SetModel( model )
        ent:SetPos( pos )
        ent:SetAngles( ang )
        ent:Spawn()
    
        return ent
    end
    
    hook.Add( "InitPostEntity", "CreateWorldProps", function()
    
        CreateWorldProp( "models/props_borealis/bluebarrel001.mdl", Vector( 0, 0, 0 ), Angle( 0, 0, 0 ) )
        -- etc
    
    end )
    

    Anywhere serverside (lua/autorun/server/asdf.lua)
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events Lua Helper Lua Helper x 4 (list)

  29. Post #29
    Mrwhitee's Avatar
    January 2012
    31 Posts
    thanks
    Reply With Quote Edit / Delete Windows 7 Denmark Show Events Friendly Friendly x 1 (list)

  30. Post #30
    shadowndacorner's Avatar
    May 2011
    195 Posts
    So I've been working on a gamemode and decided to make a character creation screen, but the DTextEntry I'm using doesn't want to take focus. Any suggestions?

    Here's some of the code:
    --snip--

    EDIT: Fixed by using MakePopup on the EditablePanel.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  31. Post #31
    Jaded
    Pyth's Avatar
    April 2010
    2,200 Posts
    I'm really new to Lua and I'm following this guide to making a gamemode for Marble Blast Ultra to go with GameDev's maps. When I test it in GMod, the console says

    Console posted:
    Cannot change maxplayers while the server is running
    Dropped Pyth from server (Server shutting down)
    Browser Message: Uncaught ReferenceError: SetStatusChanged is not defined - :0Lua initialized (Lua 5.1)
    [gamemodes\marble_blast_ultra\gamemode\init.lua:59] function arguments expected near 'end'
    [cpp]
    There was a problem opening the gamemode file 'Marble_Blast_Ultra/gamemode/init.lua'


    Registering gamemode 'Marble_Blast_Ultra' derived from 'base'
    ScriptEnforce is disabled
    Executing listen server config file
    Lua initialized (Lua 5.1)
    Registering gamemode 'sandbox' derived from 'base'
    Registering gamemode 'Marble_Blast_Ultra' derived from 'sandbox'
    Sending 267 'User Info' ConVars to server (cl_spewuserinfoconvars to see)
    Scanning for downloaded fonts..
    Redownloading all lightmaps
    No clue what it means, but here's the init.lua.

    AddCSLuaFile( "cl_init.lua" )
    AddCSLuaFile( "shared.lua" )
    AddCSLuaFile( "specialchars.lua" )
    
    include( 'shared.lua' )
    include( 'specialchars.lua' )
    
    --on player spawn
    function GM:PlayerSpawn( ply )
    	self.BaseClass:PlayerSpawn( ply )
    	
    	ply:SetGravity ( 1 )
    	ply:SetMaxHealth ( 100, true )
    	
    	ply:SetWalkSpeed ( 325 )
    	ply:SetRunSpeed ( 325 )
    	
    end
    	
    --on player join
    function GM:PlayerInitialSpawn( ply )
    	CheckSpecialCharacters( ply )
    	if ply:IsAdmin() then
    		mbu_team2( ply )
    	else
    	joining( ply )
    	RunConsoleCommand( "mbu_start" )
    	end
    end
    
    --weapons given on player join team
    function GM:PlayerLoadout( ply )
    	if ply:Team() == 1 then
    		
    		// blank because no weapons are used
    		
    	elseif ply:Team() == 2 then
    	
    		//blank because no weapons are used
    		
    	end
    end
    
    --on player join team Players [1]
    function mbu_team1( ply )
    
    	ply:UnSpectate()
    	ply:SetTeam( 1 )
    	ply:Spawn()
    	ply:PrintMessage( HUD_PRINTTALK, "[Marble Blast Ultra]Welcome to the server!")
    	
    end
    
    --on player join team Admins [2]
    function mbu_team2( ply )
    	
    	ply:SetTeam( 2 )
    	ply:Spawn
    	ply:PrintMessage( HUD_PRINTTALK, "[Marble Blast Ultra]Welcome back, Admin.")
    
    end
    
    concommand.Add( "mbu_team1", mbu_team1 )
    
    --on player join the server pre-team selection
    function joining( ply )
    	
    	ply:Spectate( 5 )
    	ply:SetTeam( 3 )
    	
    end
    
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  32. Post #32
    Flubascrub
    Flubadoo's Avatar
    August 2009
    10,532 Posts
    AddCSLuaFile( "shared.lua" )
    
    SWEP.Author            = "Flubascrubadoo"
    SWEP.Purpose    = ""
    SWEP.Instructions = ""
    SWEP.Spawnable            = false
    SWEP.AdminSpawnable        = true
    
    SWEP.ViewModel            = "models/weapons/v_atgun.mdl"
    SWEP.WorldModel            = "models/jaanus/atgun.mdl"
    SWEP.Category		= "etest"
    SWEP.Primary.ClipSize        = 8
    SWEP.Primary.DefaultClip    = -1
    SWEP.Primary.Automatic        = false
    SWEP.Primary.Ammo            = "none"
    
    SWEP.Primary.ClipSize        = -1
    SWEP.Primary.DefaultClip    = -1
    SWEP.Secondary.Automatic    = false
    SWEP.Secondary.Ammo            = "none"
    
    SWEP.Weight                = 5
    SWEP.AutoSwitchTo        = false
    SWEP.AutoSwitchFrom        = false
    
    SWEP.PrintName            = "Heavy Plasma Sniper Rifle"            
    SWEP.Slot                = 1
    SWEP.SlotPos            = 2
    SWEP.DrawAmmo            = false
    SWEP.DrawCrosshair        = true
    
    local ShootSound = Sound( "NPC_Hunter.FlechetteShoot" )
    
    Zoom = 0
    Slomo = 0
    
    
    /*---------------------------------------------------------
    Think does nothing (insert strikethrough) something
    ---------------------------------------------------------*/
    /*function SWEP:Reload() //ugh doesnt work, but i dont care
    
        if(Slomo == 0) then
            if(SERVER) then
                RunConsoleCommand("host_timescale", "0.7")
            end
            self:EmitSound("Weapon_AR2.Special1")
            Slomo = 1
        else
            if(SERVER) then
                RunConsoleCommand("host_timescale", "1")
            end
            self:EmitSound("Weapon_AR2.Special2")
            Slomo = 0
        end
    
    end*/
    
    
    /*---------------------------------------------------------
        PrimaryAttack
    ---------------------------------------------------------*/
    function SWEP:PrimaryAttack()
        self.Weapon:SetNextPrimaryFire( CurTime() + 0.85 )
        self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
        self:EmitSound( ShootSound )
        self:ShootEffects( self )
        // The rest is only done on the server and shit
        if (!SERVER) then return end
        self:TakePrimaryAmmo( 0 )
        local x
        for x = 1, 12 do
            local r1 = math.random(-20, 20) / 10000
            local r2 = math.random(-20, 20) / 10000
            local r3 = math.random(-20, 20) / 10000
            local Forward = self.Owner:EyeAngles():Forward()
            
            local ent = ents.Create( "hunter_flechette" )
            if ( ValidEntity( ent ) ) then
                    ent:SetPos( self.Owner:GetShootPos() + Forward * 30 )
                    ent:SetAngles( self.Owner:EyeAngles() )
                ent:Spawn()
                ent:SetVelocity( Forward * 3000 ) //LET THERE BE BULLET DROP! IN THIS CASE, FLECHETTEs.
            end
        ent:Fire("addoutput","basevelocity 0 0 -5",0.1)
        ent:Fire("addoutput","basevelocity 0 0 -6",0.3)
        ent:Fire("addoutput","basevelocity 0 0 -8",0.5)
        ent:Fire("addoutput","basevelocity 0 0 -10",0.7)
        ent:Fire("addoutput","basevelocity 0 0 -13",1)
        ent:Fire("addoutput","basevelocity 0 0 -16",1.3)
        ent:Fire("addoutput","basevelocity 0 0 -19",1.5)
        ent:Fire("addoutput","basevelocity 0 0 -23",1.7) //useless mumbo jumbo
        ent:Fire("addoutput","basevelocity 0 0 -27",2)
        ent:Fire("addoutput","basevelocity 0 0 -31.5",2.3)
        ent:Fire("addoutput","basevelocity 0 0 -34",2.5)
        ent:Fire("addoutput","basevelocity 0 0 -39",2.7)
        ent:AddEffects( EF_ITEM_BLINK | EF_BRIGHTLIGHT );
        ent:SetOwner( self.Owner )
        util.ScreenShake( ent:GetPos(), 2, 2, 0.7, 100 )
        ParticleEffectAttach("larvae_glow_extract",PATTACH_ABSORIGIN_FOLLOW,ent,0) //wee
            ParticleEffectAttach("vortigaunt_hand_glow",PATTACH_ABSORIGIN_FOLLOW,ent,0)
            ParticleEffectAttach("test_beam",PATTACH_ABSORIGIN_FOLLOW,ent,0)
    	timer.Simple(2.7,function() ParticleEffectAttach("Weapon_Combine_Ion_Cannon_Explosion",PATTACH_ABSORIGIN_FOLLOW,ent,0) end)
            timer.Simple(2.7,function() ParticleEffectAttach("electrical_arc_01_system",PATTACH_ABSORIGIN_FOLLOW,ent,0) end)
            //timer.Simple(2.7,function() ParticleEffectAttach("cingularity",PATTACH_ABSORIGIN_FOLLOW,ent,0) end)
            //timer.Simple(2.7,function() ParticleEffectAttach("aurora_02b",PATTACH_ABSORIGIN_FOLLOW,ent,0) end)
        end
    end
    
    
    
    /*---------------------------------------------------------
        SecondaryAttack
    ---------------------------------------------------------*/
    function SWEP:SecondaryAttack()
    
    	if(Zoom == 0) then
    		if(SERVER) then
    			self.Owner:SetFOV( 25, 0.25 )
    		end
    		self:EmitSound("Weapon_AR2.Special1")
    		Zoom = 1
    	else
    		if(SERVER) then
    			self.Owner:SetFOV( 0, 0.25 )
    		end
    		self:EmitSound("Weapon_AR2.Special2")
    		Zoom = 0
    	end
    
    end
    
    hook.Add("EntityRemoved", "entRemoved", entityRemoved)
    

    Ugh, tried going back into Lua on a very old and simple project, but whenever the flechettes attach to an NPC, the explosion effects simply seem to go to the origin of the map rather than explode where the NPC is. How would I go about making it so that no effects appear if a flechette hits an NPC (becomes non-existant)?

    I tried something like this at around line 110 and commenting out the code pertaining to the timed effects:
    timer.Simple(2.7,function()
        if IsValid(ent) then
            ParticleEffectAttach("aurora_02b",PATTACH_ABSORIGIN_FOLLOW,ent,0)
            ParticleEffectAttach("electrical_arc_01_system",PATTACH_ABSORIGIN_FOLLOW,ent,0)
            ParticleEffectAttach("Weapon_Combine_Ion_Cannon_Explosion",PATTACH_ABSORIGIN_FOLLOW,ent,0)
            ParticleEffectAttach("cingularity",PATTACH_ABSORIGIN_FOLLOW,ent,0)
               
        end
    end)

    But all that does is completely remove the extra delayed effects attached to the flechette, although there are no effects attached to the origin of the map.

    Suggestions?

    Edited:

    Gah, nevermind, I realized the thing I did at the bottom wasn't in the primary fire function... I'm dumb.
    Reply With Quote Edit / Delete Windows 7 Qatar Show Events

  33. Post #33
    A living example of an OCD programmer
    Netheous's Avatar
    June 2009
    3,590 Posts
    function DB_GlobalSave()
    	for _, ply in pairs (player.GetAll()) do
    		if ply:IsValid() then
    			SQLaction = sql.Query("UPDATE ply_info SET money = "..ply.stats.money..", items = 'smallbattery', WHERE u_id = '"..ply:SteamID().."'")
    		end
    		if !SQLaction then
    			print(sql.LastError(SQLaction))
    		end
    	end
    end

    Timer Error: [gamemodes\nethsrp\gamemode\database.lua:54] attempt to concatenate field 'money' (a nil value)

    If anyone is curious, this is where I setup those tables:
    function DB_LoadPlayer( person )
    if !person:IsValid() then return end
    	SQLaction = sql.Query("SELECT u_id, money, items FROM ply_info WHERE u_id = '"..person:SteamID().."'")
    	if SQLaction then
    		
    		person.stats = 
    		{
    			money = SQLaction.money,
    			xp = 1337,
    			points = 1339
    		}
    			
    		person.items =
    		{
    			SQLaction.items
    		}
    		DB_SendStats( person )
    		//DB_SendItems( person )
    	else
    		DB_NewPlayer( person )
    	end
    end
    hook.Add( "PlayerInitialSpawn", "DB_LoadPlayer", DB_LoadPlayer )
    Reply With Quote Edit / Delete Windows 7 Poland Show Events

  34. Post #34
    pennerlord's Avatar
    February 2011
    503 Posts
    I'm really new to Lua and I'm following this guide to making a gamemode for Marble Blast Ultra to go with GameDev's maps. When I test it in GMod, the console says



    No clue what it means, but here's the init.lua.

    - code -
    
    Line 58:
    ply:Spawn

    Should be
    ply:Spawn()
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  35. Post #35
    Jaded
    Pyth's Avatar
    April 2010
    2,200 Posts
    Line 58:
    ply:Spawn

    Should be
    ply:Spawn()
    Oh shit, thanks.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Friendly Friendly x 1 (list)

  36. Post #36
    aurum481's Avatar
    November 2008
    2,424 Posts
    What difference between function and local function?
    You can't call local function globally?
    Reply With Quote Edit / Delete Windows XP Lithuania Show Events

  37. Post #37
    Gold Member
    Dorkslayz's Avatar
    September 2009
    1,666 Posts
    What difference between function and local function?
    You can't call local function globally?
    a local function can only be run within the block of code its been made in.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  38. Post #38
    Gold Member
    ralle105's Avatar
    October 2005
    4,644 Posts
    What difference between function and local function?
    You can't call local function globally?
    Acts like any other local, it doesn't exist outside it's scope.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  39. Post #39
    Jinx786's Avatar
    October 2010
    380 Posts
    GM:HUDPaint is for gamemodes, which is loaded after autorun hence it's nil when your file is ran.

    Use this instead:

    hook.Add( "HUDPaint", "DrawSpeedo?", function()
    
     -- your code here
    
    end )
    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.

    Edit: I have measured this:
    vehicle
    normal mode: measured max: 1580 specified max: 90 mph 144.84096 kph
    boost mode: measured max: 2110 specified max: 120 mph 193.12128 kph
    Reply With Quote Edit / Delete Windows 7 Slovenia Show Events

  40. Post #40
    Gold Member
    Dorkslayz's Avatar
    September 2009
    1,666 Posts
    Thank you very much, it works. Just one question: What units is the result in? When I walk its 250, when I run its 500, when I drive a vehicle its 800-1100.
    Since wiki is not working properly I get no uselful results for this function.
    Units per a minute at a guess.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events