1. Post #241
    pennerlord's Avatar
    February 2011
    501 Posts
    What are some entry level/intermediate things to code? I don't want to be creating massive gamemodes here, I just purely want to do this for hobby as I haven't learned lua yet.
    http://www.lua.org/pil/

    http://maurits.tv/data/garrysmod/wik...e=Lua_Overview
    http://maurits.tv/data/garrysmod/wik...arted_With_Lua
    http://maurits.tv/data/garrysmod/wik...utorial_Series
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  2. Post #242
    WHY WHEN WHY
    Krizzu's Avatar
    June 2011
    173 Posts
    Where can I find weapon model list?
    Reply With Quote Edit / Delete Windows 7 Poland Show Events

  3. Post #243
    PROUD BRONY 4LYFE
    Drakehawke's Avatar
    February 2009
    3,312 Posts
    Where can I find weapon model list?
    For the default models that come with GMod? I just use the spawnmenu in-game. (Right click -> Copy to Clipboard)
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events Informative Informative x 1 (list)

  4. Post #244
    WHY WHEN WHY
    Krizzu's Avatar
    June 2011
    173 Posts
    For the default models that come with GMod? I just use the spawnmenu in-game. (Right click -> Copy to Clipboard)
    I mean models that I can use in ViewModels and WorldModels
    Reply With Quote Edit / Delete Windows 7 Poland Show Events

  5. Post #245
    PROUD BRONY 4LYFE
    Drakehawke's Avatar
    February 2009
    3,312 Posts
    I mean models that I can use in ViewModels and WorldModels
    Yep, they're in there, search for "weapon" and you get most of them, the view models mostly begin with v_, the world models mostly begin with w_.
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events Friendly Friendly x 1 (list)

  6. Post #246
    pennerlord's Avatar
    February 2011
    501 Posts
    You can also use the "Model Viewer" from Source SDK.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Friendly Friendly x 1 (list)

  7. Post #247
    WHY WHEN WHY
    Krizzu's Avatar
    June 2011
    173 Posts
    Okay, got it. Thanks.
    Now, I want to delay some action. Any Snippets?
    Reply With Quote Edit / Delete Windows 7 Poland Show Events

  8. Post #248
    JustSoFaded's Avatar
    December 2011
    432 Posts
    What are some entry level/intermediate things to code? I don't want to be creating massive gamemodes here, I just purely want to do this for hobby as I haven't learned lua yet.
    Code a simple deathmatch gamemode. The hardest part will be the currency and round system. So it should give you a bit of a challenege depending on how intricate you make the gamemode.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  9. Post #249
    PROUD BRONY 4LYFE
    Drakehawke's Avatar
    February 2009
    3,312 Posts
    Okay, got it. Thanks.
    Now, I want to delay some action. Any Snippets?
    http://maurits.tv/data/garrysmod/wik...ml?title=Timer
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events Agree Agree x 1Friendly Friendly x 1 (list)

  10. Post #250
    WHY WHEN WHY
    Krizzu's Avatar
    June 2011
    173 Posts
    Thank you! Helped a lot!
    But now:

    function SWEP:SecondaryAttack()
    concommand.Run (self.Owner,"testframe")
    end
    
    
     function testframe()
            local frame1 = vgui.Create("DFrame") --This is line 75
     
            frame1:SetPos(100,100)
            frame1:SetSize(200,200)
            frame1:SetTitle("Test")
            frame1:MakePopup()
    end
    concommand.Add( "testframe", testframe )
    

    lua\weapons\russian_roulette_v1\shared.lua:75: attempt to index global 'vgui' (a nil value)
    Reply With Quote Edit / Delete Windows 7 Poland Show Events

  11. Post #251
    Fight for justice, fight for Manning and Snowden.
    Persious's Avatar
    April 2010
    2,547 Posts
    It has to be clientside.
    Reply With Quote Edit / Delete Windows 7 Faroe Islands Show Events Agree Agree x 2 (list)

  12. Post #252
    Awesome Gmod Servers!
    brandonj4's Avatar
    September 2011
    2,065 Posts
    -snip- solved :)
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  13. Post #253
    NnyAskC's Avatar
    April 2006
    101 Posts
    Does anyone know the name of the tripmine ammo? I know the mine itself is npc_tripmine but can't find the "ammo" for it or whatever you'd use to spawn it.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  14. Post #254
    Gold Member
    Hyper Iguana's Avatar
    March 2011
    699 Posts
    Does anyone know the name of the tripmine ammo? I know the mine itself is npc_tripmine but can't find the "ammo" for it or whatever you'd use to spawn it.
    SLAM maybe?
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 1 (list)

  15. Post #255
    NnyAskC's Avatar
    April 2006
    101 Posts
    SLAM maybe?
    Well, I feel dumb. lol thanks.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  16. Post #256
    Awesome Gmod Servers!
    brandonj4's Avatar
    September 2011
    2,065 Posts
    How would I check to see if something is inside of ents.FindInSphere?

    function CheckSpawnZones()
        for k, vector in pairs(SpawnZone) do
            local entity = ents.FindInSphere(vector.Vector,300);
            for _, class in pairs(CheckFor) do
                local ent = tostring(entity:GetClass());
                if (class == ent) then
                    return;
                end
            end
        end
        return true;
    end
    

    Edited:

    function CreateSpawn(ply,cmd, args)
        local trace = ply:GetEyeTrace();
        if (trace.HitWorld) && (#args == 2) then
            AddSpawnZone(trace.HitPos, args[1], args[2], #SpawnZone + 1);
        else
            ply:ChatPrint("You must enter two arguments and look at the world!\n I.E. create_spawnpoints 'class' 'true/false'");
        end
    	timer.Create("SpawnZoneThink", 0.5, 0, function()
    		local RandomX = math.random(-100,100);
    		local RandomY = math.random(-100,100);
    		for k, v in pairs(SpawnZone) do
    			if (CheckSpawnZones() == false) then return end
    			CreateNPC(v.Class, v.Vector + Vector(RandomX, RandomY, 0))
    		end
    	end);
    end
    concommand.Add("create_spawnpoints", CreateSpawn);
     
     
    function CreateNPC(class, vector)
        local ent = ents.Create(class);
        ent:SetPos(vector);
        ent:Spawn();
    end
    
    function CheckSpawnZones()
        for k, vector in pairs(SpawnZone) do
            local entity = ents.FindInSphere(vector.Vector,175);
            for _, class in pairs(CheckFor) do
    			for k, v in pairs(entity) do
    				if v == class then
    					return true
    				else 
    					return false
    				end
    			end
            end
        end
    end
    
    I solved the first part. How do I make it so it doesn't only spawn when something is isnt in any of the spheres and just the sphere where the spawn is? I can be in one zombies spawn, and others will spawn is what I mean. For now it only spawns in the 2 spawn I create and not in the third or fourth.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  17. Post #257
    WHY WHEN WHY
    Krizzu's Avatar
    June 2011
    173 Posts
    Okay, now, is there any restriction about console command name?

    concommand.Add( "testframe", testframe )
    When I put "testframe" it says there no such a function.
    When I put "qwe" it's working.

    O.o
    Reply With Quote Edit / Delete Windows 7 Poland Show Events

  18. Post #258
    silenced deat's Avatar
    January 2012
    107 Posts
    So I want to create a command for perp when a player runs it, it gives them 500k but I can't figure out how to make it set to a specific person that runs the command.


    So far I have

    function money (SteamID, ply)
     
    sql.query( "INSERT INTO perp_users, "cash"VALUE ("500000")")
     
    concommand.Add("Money", money)
    
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  19. Post #259
    Adrammelech09's Avatar
    January 2012
    11 Posts
    I suppose it's a tiny problem but I can't seem to make it happen. AT ALL.

    the code is as follows:

    function SWEP:SecondaryAttack()

    if ( !self:CanSecondaryAttack() ) then return end

    timer.Simple(0.3,function() self.Weapon:EmitSound("Weapon_MegaPhysCannon.Charg e")
    local shoot={}
    [1]=(timer.Simple(0.3, self:ShootBullet( 4, 9, 0.06 ))
    [2]=(self:TakeSecondaryAmmo( 1 ))
    [3]=(self.Owner:ViewPunch(Angle(math.random(-0.5, -0.1))) )
    [4]=(self.Weapon:SetNextSecondaryFire( CurTime() + 0.3 ) )
    [5]=(local muzzle2 = EffectData() )
    end
    -- fruitlessly trying to put a different muzzle effect for a different shot.
    muzzle2:SetEntity(self.Weapon)
    muzzle2:SetOrigin(self.Owner:GetShootPos())
    muzzle2:SetNormal(self.Owner:GetAimVector())
    muzzle2:SetAttachment(1)
    util.Effect("HelicopterMuzzleFlash", muzzle2)
    end

    Wanted a delay on the secondary fire, which was going to be a shotgun. Tried to use a table, failed. At my wit's fucking end. HELP!!!
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  20. Post #260
    "The superior man understands what is right; the inferior man understands what will sell"
    Chessnut's Avatar
    August 2011
    3,442 Posts
    All of the indexes aren't part of a table. It should be:

    local myTable = {};
    myTable[1] = "Hello";
    myTable[2] = "World";
    myTable[3] = "stuff.";

    And so on.
    Reply With Quote Edit / Delete United States Show Events Agree Agree x 1 (list)

  21. Post #261
    pennerlord's Avatar
    February 2011
    501 Posts
    So I want to create a command for perp when a player runs it, it gives them 500k but I can't figure out how to make it set to a specific person that runs the command.


    So far I have

    function money (SteamID, ply)
     
    sql.query( "INSERT INTO perp_users, "cash"VALUE ("500000")")
     
    concommand.Add("Money", money)
    
    concommand.Add calls the function with 3 parameters: Player, Command, Arguments.

    For example, to get the steamid, you can use this code:

    concommand.Add("YourName", function(ply, cmd, args)
    	local steamid = ply:SteamID()
    end)
    
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  22. Post #262
    silenced deat's Avatar
    January 2012
    107 Posts
    concommand.Add calls the function with 3 parameters: Player, Command, Arguments.

    For example, to get the steamid, you can use this code:

    concommand.Add("YourName", function(ply, cmd, args)
    	local steamid = ply:SteamID()
    end)
    
    So its gonna look likes this:


    
    concommand.Add("Money", function(ply, cmd, args)
                      local SteamID = ply:SteamID
    sql.query( "INSERT INTO perp_users (`cash`)VALUES ('500000')" )
    
    
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  23. Post #263
    pennerlord's Avatar
    February 2011
    501 Posts
    So its gonna look likes this:


    
    concommand.Add("Money", function(ply, cmd, args)
                      local SteamID = ply:SteamID
    sql.query( "INSERT INTO perp_users (`cash`)VALUES ('500000')" )
    
    
    Your sql query is still wrong. I recommend to you to read this sql tutorial:
    http://maurits.tv/data/garrysmod/wik...QLite_Tutorial
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  24. Post #264
    silenced deat's Avatar
    January 2012
    107 Posts
    Your sql query is still wrong. I recommend to you to read this sql tutorial:
    http://maurits.tv/data/garrysmod/wik...QLite_Tutorial
    Can you please explain what i have done wrong because i'm new to lua and im getting an args error.
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  25. Post #265
    "The superior man understands what is right; the inferior man understands what will sell"
    Chessnut's Avatar
    August 2011
    3,442 Posts
    It should be:

    concommand.Add("GiveMoney", function(ply, cmd, args)
    	local steamID = ply:SteamID();
            
            sql.Query("UPDATE perp_users SET Cash = 50000 WHERE SteamID = "..steamID);
    end)
    

    Assuming that the fields I used are correct.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  26. Post #266
    silenced deat's Avatar
    January 2012
    107 Posts
    It should be:

    concommand.Add("GiveMoney", function(ply, cmd, args)
    	local steamID = ply:SteamID();
            
            sql.Query("UPDATE perp_users SET Cash = 50000 WHERE SteamID = "..steamID);
    end)
    

    Assuming that the fields I used are correct.
    Ok i will try it, and thanks! :)


    EDIT: Just tryed it and the money is not going into my bank or cash pile.
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  27. Post #267
    Gold Member
    Hyper Iguana's Avatar
    March 2011
    699 Posts
    Ok i will try it, and thanks! :)


    EDIT: Just tryed it and the money is not going into my bank or cash pile.
    Make sure those entries are the correct ones that perp uses in its SQL
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 1 (list)

  28. Post #268
    Gold Banana
    Banana Lord.'s Avatar
    May 2010
    6,421 Posts
    why doesn't he just use the function PERP uses to give players money instead of updating a SQL row which will be overwritten when the player reconnects anyway
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 2 (list)

  29. Post #269
    WHY WHEN WHY
    Krizzu's Avatar
    June 2011
    173 Posts
    why doesn't he just use the function PERP uses to give players money instead of updating a SQL row which will be overwritten when the player reconnects anyway
    Can you please explain what i have done wrong because i'm new to lua and im getting an args error.
    Maybe?

    ###

    When I use :
    chat.AddText()
    I got chat spam. How to avoid it? (Just one or four messages should be fine instead of 10k)
    Reply With Quote Edit / Delete Windows 7 Poland Show Events

  30. Post #270
    Fantym420's Avatar
    October 2010
    891 Posts
    Ok, so I have a few issues that are giving me hell, not really sure they can be fixed either but I thought I'd try and get some assistance.

    Firstly I am making a map that has a 3D Sky box that you can enter, and then the actual map shows in the middle of the 3D Sky box with everything at 1/64th scale, and when you are in the map and look up you see out of the glass case in the middle of the Sky box and see everything there 64x normal size, there is a teleport that take you between them.

    So far I can draw the player, props, vehicles, and some SENTs in miniature but I can't seem to redraw some things like fire and explosion effects, and this is the part I don't think I can do at all.

    The part I think I can fix is with my npc's some will scale just fine, but all humanish characters don't scale, i've brought and illustration:
    First What works
    Antlion's scale just fine, this is a normal first person shot.


    This shot is from a camera in the sky box room, me and the antlion are in the bottom left to the right of the health display, tiny just as they should be.


    This shot is from the camera seen in the lower left of the last shot, this camera is also in the sky box room but it is just beyond the inside wall to get a close up.


    and now...
    These next 3 are exactly the same but with mossman, she doesn't scale.
    First person shot, you can see the full size model being drawn in sky box room.


    This is from first sky box cam, again, she is full sized, =(


    and last from the close up camera.



    Any way here's the code, it's not pretty at the moment and there's shit in there that is only there because i'm trying to fix this, and it's all in one file till I get this working the way I want, then I'll clean it all up.

    
    --doesn't scale
    --zombine
    --zombie
    --fast zombie
    --antlion guard
    --antlion worker (wings)
    --roller mine (effect)
    --ragdolls
    
    renderClasses = {
                     "prop",
                     "npc", 
                     "player", 
                     "rag",
                     "env",
                     "meteor", 
                     "weapon"
                    }
    
    function IsClass( ent, class )
    
    	if ent == nil then return false end
    	if ent == NULL then return false end
    	if !ent:IsValid() then return false end
    	
    	local result = nil
    	local isClass = false
    	
    	if type(class) == "table" then
    		
    		for k,v in pairs(class) do
    			
    			result = string.find(ent:GetClass(),v)
    			if !(result == nil) then
    				isClass = true
    			end
    			result = nil
    		end
    
    	else
    		--print("Is " .. ent:GetClass() .. " a " .. class .. " : " .. tostring(!(result == nil)))	
    		result = string.find(ent:GetClass(), class)
    		if !(result == nil) then 
    			isClass = true
    		end
    	end
    	
    	return isClass
    	
    end
    
    if CLIENT then
    
    	tankPos = Vector(0,0,0) 
    	
    	renderEnts = {}
    
    	hook.Add("OnEntityCreated", "get_it", function(ent)
    		if IsClass(ent, "class") then
    			table.insert(renderEnts, ent:EntIndex())
    		end
    	end)
    	
    	for k,v in pairs(ents.GetAll()) do
           if IsClass(ent, "class") then
    			table.insert(renderEnts, ent:EntIndex())
    		end
        end
    	
    	function getRenderEnts(msgData)
    		
    		local newEnt = msgData:ReadShort()
    		
    		if table.HasValue(renderEnts, newEnt) then return end
    		
    		table.insert(renderEnts,newEnt)
    	
    	end
    	usermessage.Hook("get_render_ents", getRenderEnts)
    	
    	function getTankPos(msgData)
    		
    		tankPos = msgData:ReadVector()
    		print("tankPos: " .. tostring(tankPos))    
    	end
    
    	usermessage.Hook("get_tank_pos", getTankPos)
    
    	hook.Add("PostDrawOpaqueRenderables", "fuckinA", function()
    
    		local scale = 1 / 64
    		
    		cam.Start3D(EyePos(), EyeAngles())
    		for k,v in pairs(renderEnts) do
    		
    			local rendEnt = ents.GetByIndex(v)
    			
    			if !(rendEnt == NULL) and
    			   !(rendEnt:IsWorld()) then
    			
    				local curPos = rendEnt:GetPos()
    				local rendPos = tankPos + (curPos * scale)
    				
    				--Draw Mini
    				rendEnt:SetPos(rendPos)
    				--rendEnt:SetRenderOrigin(rendPos)
    				rendEnt:SetModelScale(Vector(scale,scale,scale))
    				if IsClass(rendEnt, "npc") or 
    					IsClass(rendEnt, "rag") then
    					rendEnt:InvalidateBoneCache()
    					rendEnt:SetupBones()
    				end
    				if rendEnt.DrawModel then
    					rendEnt:DrawModel()
    				end
    				if rendEnt.Draw then
    					rendEnt:Draw()
    				end
    				if rendEnt.DrawTranslucent then
    					rendEnt:DrawTranslucent()
    				end
    				if rendEnt:IsPlayer() and ValidEntity(rendEnt:GetActiveWeapon()) then 
    					rendEnt:GetActiveWeapon():DrawModel() 
    				end
    				
    				--Draw Normal
    				rendEnt:SetPos(curPos)
    				rendEnt:SetModelScale(Vector(1,1,1))
    				if !IsClass(rendEnt, "npc") then
    					rendEnt:DrawModel()            
    				end				
    
    				
    			else
    				table.remove(renderEnts, k)
    			end
    		end
    		cam.End3D()
    		
    		return false
    
    	end)
    end
    
    
    if SERVER then
    
        local renderEnts = {}
    	
    	function addRenderEnt(ent)
    	
    		if !table.HasValue(renderEnts,ent) then
    			
    			table.insert(renderEnts, ent)
    		
    		end
    		
    		umsg.Start("get_render_ents")
    			umsg.Short(ent:EntIndex())
    		umsg.End()
    		
    	end
    	
    	hook.Add("SetupPlayerVisibility", "fert", function(ply, ent)
    		AddOriginToPVS(Vector(0,0,0))
    		
    		for k,v in pairs(renderEnts) do
    			if ValidEntity(v) then
    				AddOriginToPVS(v:GetPos())
    			else
    				table.remove(renderEnts,k)
    			end
    		end
    		
        end
        )
        
        for k,v in pairs(ents.GetAll()) do
            if v:GetName() == "tank_middle" then
                umsg.Start("get_tank_pos")
                umsg.Vector(v:GetPos())
                umsg.End()
            end
    		
    		if !v:IsWorld() then
    			if v.GetPhysicsObject then
    				local vPhys = v:GetPhysicsObject()
    				
    				if vPhys and vPhys.IsValid and vPhys:IsValid() then
    					
    					addRenderEnt(v)
    				
    				end
    				
    			end
    		end
        end
    	
    	hook.Add("OnEntityCreated", "get_it", function(ent)
    		timer.Simple(0.01, checkEnt, ent)
    	end)
    	
    	function checkEnt(ent)
    	
    		if ValidEntity(ent) then
    			if !ent:IsWorld() then
    				if ent.GetPhysicsObject then
    					local vPhys = ent:GetPhysicsObject()
    					
    					if vPhys and vPhys.IsValid and vPhys:IsValid() then
    						
    						addRenderEnt(ent)
    					
    					end
    				else
    					if IsClass(ent, "env_") then
    						addRenderEnt(ent)
    					end
    				end
    			end
    		end
    	end
    	
    	hook.Add("PlayerInitalSpawn", "see_it", function(ply)
    		
    		for k,v in pairs(renderEnts) do
    		
    			umsg.Start("get_render_ents")
    				umsg.Short(v:EntIndex())
    			umsg.End()
    		end
    		
    	end)
    
    end
    

    Thanks for any help.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  31. Post #271
    silenced deat's Avatar
    January 2012
    107 Posts
    why doesn't he just use the function PERP uses to give players money instead of updating a SQL row which will be overwritten when the player reconnects anyway
    And what function would that be?

    is it this
    function PLAYER:SetCash ( value, stopSendToClient) self:SetPrivateInt("cash", value, stopSendToClient); end
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  32. Post #272
    Fight for justice, fight for Manning and Snowden.
    Persious's Avatar
    April 2010
    2,547 Posts
    local SoundPlayer = {}
    local Sounds = {}
    
    function SoundPlayer.AddSound(Text, Destination)
    table.insert(Sounds, {Text = Text, Destination = Destination})
    end
    
    SoundPlayer.AddSound("lol", "vo/eli_lab/al_laugh02.wav")
    
    function SoundPlayer.ChatFunction( ply, text )
    	if ply:IsValid() then
    		for k,v in pairs(Sounds) do
    			if string.find( text, k ) then
    				ply:EmitSound(Sounds[k], 500, 100)
    				return text
    			end
    		end
    	end
    end
    hook.Add("PlayerSay", "SoundPlayer.ChatFunction", SoundPlayer.ChatFunction)
    

    It doesn't emit the sound. No clue what I'm doing wrong tho.
    Reply With Quote Edit / Delete Windows 7 Faroe Islands Show Events

  33. Post #273
    Awesome Gmod Servers!
    brandonj4's Avatar
    September 2011
    2,065 Posts
    local SoundPlayer = {}
    local Sounds = {}
    
    function SoundPlayer.AddSound(Text, Destination)
    table.insert(Sounds, {Text = Text, Destination = Destination})
    end
    
    SoundPlayer.AddSound("lol", "vo/eli_lab/al_laugh02.wav")
    
    function SoundPlayer.ChatFunction( ply, text )
    	if ply:IsValid() then
    		for k,v in pairs(Sounds) do
    			if string.find( text, k ) then
    				ply:EmitSound(Sounds[k], 500, 100)
    				return text
    			end
    		end
    	end
    end
    hook.Add("PlayerSay", "SoundPlayer.ChatFunction", SoundPlayer.ChatFunction)
    

    It doesn't emit the sound. No clue what I'm doing wrong tho.
    I have a question, why do you use k and then Sounds[k]? shouldnt it be the variables k and v since you are using the loop?
      if string.find( text, k ) then
                    ply:EmitSound(Sounds[k], 500, 100)
                    return text
    
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  34. Post #274
    Awesome Gmod Servers!
    brandonj4's Avatar
    September 2011
    2,065 Posts
    How would I create a ragdoll to be the model in a SENT? I've tried before and it does this weird hull dragging thing..
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  35. Post #275
    MoronYard
    _nonSENSE's Avatar
    May 2010
    1,264 Posts
    I have a question, why do you use k and then Sounds[k]? shouldnt it be the variables k and v since you are using the loop?
      if string.find( text, k ) then
                    ply:EmitSound(Sounds[k], 500, 100)
                    return text
    
    He can use either. He does need to add .Destination, though:

    if ply:IsValid() then
        for k,v in pairs(Sounds) do
            if string.find( text, k ) then
                ply:EmitSound(Sounds[k].Destination, 500, 100) -- or v.Destination
                return text
            end
        end
    end
    
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  36. Post #276
    Fantym420's Avatar
    October 2010
    891 Posts
    How would I create a ragdoll to be the model in a SENT? I've tried before and it does this weird hull dragging thing..
    yea, i've tried this before too and all I got was the ragdoll in a T pose, I think the functions to fix this are in the beta. But since I don't have the beta I can't test it.

    I think these functions are it:

    from beta update 14 list
    Added Ent:SetHitboxSet( i | string )
    Added Ent:GetHitboxSet() (returns i, str)
    Added Ent:GetHitboxSetCount()
    Added Ent:GetHitboxBone()
    Added Ent:GetBoneController( i ) (returns float)
    Added Ent:SetBoneController( i, float )

    at least I hope so because ragdoll SENTs would be fun to mess with.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  37. Post #277
    WHY WHEN WHY
    Krizzu's Avatar
    June 2011
    173 Posts
    I can't see firstperson reload animations!

    self.Owner:SetAnimation( PLAYER_RELOAD) --firstperson, not working
    self.Weapon:SendWeaponAnim( ACT_VM_RELOAD ) --thirdperson, working	
    

    any idea how to repair it?
    Reply With Quote Edit / Delete Windows 7 Poland Show Events

  38. Post #278
    Fight for justice, fight for Manning and Snowden.
    Persious's Avatar
    April 2010
    2,547 Posts
    He can use either. He does need to add .Destination, though:

    if ply:IsValid() then
        for k,v in pairs(Sounds) do
            if string.find( text, k ) then
                ply:EmitSound(Sounds[k].Destination, 500, 100) -- or v.Destination
                return text
            end
        end
    end
    
    Thanks both. I thought I missed something like that.

    Edited:

    Hm, still isn't emiting the sound.

    function SoundPlayer.ChatFunction( ply, text )
    
    if ply:Alive() then
        
        for k,v in pairs(Sounds) do
    
            if string.find( text, k ) then
    
                ply:EmitSound(Sounds[k].Destination, 500, 100) -- or v.Destination
    
                	return text
    
            	end
    
        	end
    
    	end
    
    end
    hook.Add("PlayerSay", "SoundPlayer.ChatFunction", SoundPlayer.ChatFunction)
    
    Reply With Quote Edit / Delete Windows 7 Faroe Islands Show Events

  39. Post #279
    Awesome Gmod Servers!
    brandonj4's Avatar
    September 2011
    2,065 Posts
    function ItemPickUpMenu()
    	local ItemPickUpFrame = vgui.Create( "DFrame" ) -- Creates the frame itself
    	ItemPickUpFrame:SetPos( 50,50 ) -- Position on the players screen
    	ItemPickUpFrame:SetSize( 200, 100 ) -- Size of the frame
    	ItemPickUpFrame:SetTitle( "" ) -- Title of the frame
    	ItemPickUpFrame:SetVisible( true )
    	ItemPickUpFrame:SetDraggable( true ) -- Draggable by mouse?
    	ItemPickUpFrame:ShowCloseButton( true ) -- Show the close button?
    	ItemPickUpFrame:MakePopup() -- Show the frame
    	ItemPickUpFrame:Center()
    	
    	local ItemPickUpPList = vgui.Create("DPanelList", ItemPickUpFrame)
    	ItemPickUpPList:SetPos(2,24)
    	ItemPickUpPList:SetSize(200-4,100-26)
    	ItemPickUpPList:SetPadding(5)
    	Icon = vgui.Create("SpawnIcon") --Create the icon
    	Icon:SetPos(20, 20) 
    	Icon:SetModel("models/FoodNHouseholdItems/bacon_2.mdl")
    	Icon.OnMousePressed = function()--This is the function to use. 
    		Icon:Remove()--return false to disable the pressing effect
    		LocalPlayer():ChatPrint("Icon Removed")
    		
    		LocalPlayer():AddMoney(10)
    		
    		LocalPlayer():ChatPrint("10bucks")
    	end
    	ItemPickUpPList:AddItem(Icon)
    end
    concommand.Add("dotu_item_pickup", ItemPickUpMenu)
    
    Any idea how I would add 10 bucks to their player when they press it?
    Icon:Remove()--return false to disable the pressing effect
    		LocalPlayer():ChatPrint("Icon Removed")
    		
    		LocalPlayer():AddMoney(10)
    		
    		LocalPlayer():ChatPrint("10bucks")
    


    The addmoney command is serverside i cant run clientside unless i use console commands.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  40. Post #280
    WHY WHEN WHY
    Krizzu's Avatar
    June 2011
    173 Posts
    local ItemPickUpPList = vgui.Create("DPanelList", ItemPickUpFrame)
        ItemPickUpPList:SetPos(2,24)
        ItemPickUpPList:SetSize(200-4,100-26)
        ItemPickUpPList:SetPadding(5)
        Icon = vgui.Create("SpawnIcon") --Create the icon
        Icon:SetPos(20, 20)
        Icon:SetModel("models/FoodNHouseholdItems/bacon_2.mdl")
        Icon.OnMousePressed = function()--This is the function to use.
            Icon:Remove()--return false to disable the pressing effect
            LocalPlayer():ChatPrint("Icon Removed")
             if SERVER then
                     self.Owner:AddMoney(10)
             end
            LocalPlayer():ChatPrint("10bucks")
        end
        ItemPickUpPList:AddItem(Icon)
    end
    concommand.Add("dotu_item_pickup", ItemPickUpMenu)
    

    Maybe something like this.
    Reply With Quote Edit / Delete Windows 7 Poland Show Events