1. Post #121
    MoronYard
    _nonSENSE's Avatar
    May 2010
    1,264 Posts
    Player.InVehicle

    (Link is broken, use pennerlord's link below)
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Lua Helper Lua Helper x 1 (list)

  2. Post #122
    pennerlord's Avatar
    February 2011
    501 Posts
    How would I make an if(LocalPlayer() is driving a vehicle) please?
    Player.InVehicle
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Lua Helper Lua Helper x 1 (list)

  3. Post #123
    Jinx786's Avatar
    October 2010
    380 Posts
    Thank you!
    Reply With Quote Edit / Delete Windows 7 Slovenia Show Events Friendly Friendly x 2 (list)

  4. Post #124
    Gold Member
    ralle105's Avatar
    October 2005
    4,627 Posts
    if (LocalPlayer():InVehicle()) then

    Edited:



    Edited:

    Oh shit I'm super late.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events Funny Funny x 3Friendly Friendly x 2 (list)

  5. Post #125
    Jinx786's Avatar
    October 2010
    380 Posts
    Oh, sorry, I forgot to ask in my previous question, how do I get health of vehicle Im currently driving? Im trying to write relevant vehicle info on the HUD: http://shrani.si/f/3G/An/2KsFibjw/countryside0007.jpg
    Reply With Quote Edit / Delete Windows 7 Slovenia Show Events

  6. Post #126
    Epinephrine's Avatar
    March 2010
    79 Posts
    Does anybody know how I can add a background blur behind my panels? In this case it would be behind my scoreboard so im not using derma, just panels. I've seen Derma_DrawBackgroundBlur, but frankly I am a total scrub when it comes to materials and that just blows my mind.
    Reply With Quote Edit / Delete Windows 7 Anonymous Proxy Show Events

  7. Post #127
    wizardsbane's Avatar
    January 2008
    372 Posts
    -ninja'd by 2 hours of this thread not being updated despite an F5...-

    That was weird.
    Reply With Quote Edit / Delete Windows Vista United States Show Events

  8. Post #128
    Gold Member
    Killer_Steel's Avatar
    October 2007
    1,362 Posts
    Still working on my own project, still have nothing to show for it (coding hobby + college = depression).

    Stuck on getting effects to actually create themselves. Right now I've got a debug particle, but I'm only using its file name.

    Do you need the full path for the particle, or just the name of it? Using the HL2Ep2 particles. Particle I'm trying to use is vortigaunt_charge_token_b.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  9. Post #129
    SFArial's Avatar
    May 2009
    1,174 Posts
    Oh, sorry, I forgot to ask in my previous question, how do I get health of vehicle Im currently driving? Im trying to write relevant vehicle info on the HUD: http://shrani.si/f/3G/An/2KsFibjw/countryside0007.jpg
    I don't think cars have health. If it's some kind of a lua modified vehicle then look around in the addon that it came with.
    Reply With Quote Edit / Delete Windows 7 Hungary Show Events Agree Agree x 1 (list)

  10. Post #130
    werewolf0020's Avatar
    October 2009
    5,619 Posts
    so well testing my gamemode in Gmod Beta

    since the old way to find a file has been deleted and now i use file.find(path,LUA_PATH) when using file.Find( etc etc ,etc path) i get no errors whatever but the file doesnt seem to be included i even added a log to see if it was being included but it isnt


    Code so far on shared.lua

    local function SDInitItems()
    	for k,v in pairs(file.Find("stranded/gamemode/items/","stranded/gamemode/items/*.lu/a")) do
             
    			ITEM = {}
    		SDInclude(v, "items/", "sh");
    
    		SD.Inventory[v] = ITEM
    	
    	    
    	end
    	ITEM = nil;
    end
    Reply With Quote Edit / Delete Windows 7 Venezuela Show Events

  11. Post #131
    MoronYard
    _nonSENSE's Avatar
    May 2010
    1,264 Posts
    	for k,v in pairs(file.Find("stranded/gamemode/items/","stranded/gamemode/items/*.lu/a")) do
    Really? That's not how you use file.Find. +spelling mistakes
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Funny Funny x 1 (list)

  12. Post #132
    werewolf0020's Avatar
    October 2009
    5,619 Posts
    When i pasted the code the last part got messed up and...Thats not how i should use file.find?

    Before (on the normal gmod) i used

    Code:
    file.FindInLua("stranded/gamemode/vgui/*.lua")) do
    And well...since file.findinlua has been reemplased with file.find then how should i use it?
    Reply With Quote Edit / Delete Windows 7 Venezuela Show Events

  13. Post #133
    G-Enigma's Avatar
    June 2011
    326 Posts
    Is there any simple code to easily modify a v_model's origins? (with x y z values ofc)
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  14. Post #134

    June 2011
    80 Posts
    I was wondering what a beginner in lua should make? I just started lua and I've read all the tutorials and have made some things with derma and what not but I don't know what I should make to get better at it?. Something that is a bit more challenging but not too hard. Any ideas?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  15. Post #135
    SFArial's Avatar
    May 2009
    1,174 Posts
    Is there any simple code to easily modify a v_model's origins? (with x y z values ofc)
    SWEPs have a hook called SWEP:GetViewModelPosition(pos,ang), use that. Example:
    function  SWEP:GetViewModelPosition(pos,ang)
    ang.p = ang.p+1
    return pos,ang
    end
    


    Also you can modify it in CalcView somehow (can't remember and the gmod wiki is down).
    Reply With Quote Edit / Delete Windows 7 Hungary Show Events

  16. Post #136
    G-Enigma's Avatar
    June 2011
    326 Posts
    SWEPs have a hook called SWEP:GetViewModelPosition(pos,ang), use that. Example:
    function  SWEP:GetViewModelPosition(pos,ang)
    ang.p = ang.p+1
    return pos,ang
    end
    


    Also you can modify it in CalcView somehow (can't remember and the gmod wiki is down).
    Thanks!
    If you google the wiki though, somebody has a mirror up and it has most of the stuff. :)
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  17. Post #137

    June 2011
    80 Posts
    -snip- helped, thanks ArmageddonScr.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Friendly Friendly x 1 (list)

  18. Post #138
    ASK ME ABOUT MY SAM 6420 FETISH
    ArmageddonScr's Avatar
    July 2011
    691 Posts
    And also, how do I make it so you don't have the chance to respawn after you die?
    function GM:PlayerDeathThink()
          return false
    end -- Something like this.
    

    Also with rounds you want to account for players disconnecting, not just dying.
    Reply With Quote Edit / Delete Windows XP United States Show Events

  19. Post #139
    Gold Member
    Killer_Steel's Avatar
    October 2007
    1,362 Posts
    Just gonna remake my question here...

    I'm looking for the proper way to call a particle path. I'm trying to use the vortigaunt_charge_token_b particle, but I'm not sure if I'm doing it right, or the particle is just too small to see, or it's invisible.

    I'm only using local particle = emitter.Add("vortigaunt_charge_token_b")

    Ignore if I'm missing any arguments, I'm just showing what I'm trying to do. Is there any extra path elements I should add, or am I just calling a non-existant particle? And no, no errors appear.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  20. Post #140
    SFArial's Avatar
    May 2009
    1,174 Posts
    emitter.Add adds a single particle to an already existing lua particle emitter. You are looking for this.
    Reply With Quote Edit / Delete Windows 7 Hungary Show Events

  21. Post #141
    Title

    August 2009
    300 Posts
    Is SQL Local only? What I mean by that is, can PHP contact the SQL tables in garrysmod? Everything is local as I've installed PHP on the same server. How would PHP even contact the table? It's not like MYSQL where there is a username/password afaik
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  22. Post #142
    pennerlord's Avatar
    February 2011
    501 Posts
    Is SQL Local only? What I mean by that is, can PHP contact the SQL tables in garrysmod? Everything is local as I've installed PHP on the same server. How would PHP even contact the table? It's not like MYSQL where there is a username/password afaik
    I may be wrong but you could run a sqlite server that uses the gmod database.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  23. Post #143
    Okay so basically I am grabbing the name of an item and then removing spaces and lowercasing it all so it will match the table name I have.
    ingredients.unicorntear = {name = "Unicorn Tear", main = "Defense", alt = "Health Regen", alt2 = "Poison"}
    function GetStats ( ingredient )
    --Grabs the stats attached to ingredient
    		local newName = string.lower(string.Replace(ingredient," ",""))
    				print(newName)
    				PrintTable(ingredients.newName) --Doesn't work
                                    PrintTable(ingredients.unicorntear) -- works
    	
    end

    It works if I do PrintTable(ingredients.unicorntear) but not if I do PrintTable(ingredients.newName).
    Probably obvious what the problem is but I can't figure it out.
    Reply With Quote Edit / Delete Windows XP United States Show Events

  24. Post #144
    my_hat_stinks's Avatar
    April 2011
    267 Posts
    It works if I do PrintTable(ingredients.unicorntear) but not if I do PrintTable(ingredients.newName).
    Either change
            local newName = string.lower(string.Replace(ingredient," ",""))
    to
            ingredients.newName = string.lower(string.Replace(ingredient," ",""))


    Or change
                    PrintTable(ingredients.newName)
    to
                    PrintTable(newName)

    Either one, depending on what you want, but not both, because then it still won't work
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  25. Post #145
    SFArial's Avatar
    May 2009
    1,174 Posts
    Okay so basically I am grabbing the name of an item and then removing spaces and lowercasing it all so it will match the table name I have.
    ingredients.unicorntear = {name = "Unicorn Tear", main = "Defense", alt = "Health Regen", alt2 = "Poison"}
    function GetStats ( ingredient )
    --Grabs the stats attached to ingredient
    		local newName = string.lower(string.Replace(ingredient," ",""))
    				print(newName)
    				PrintTable(ingredients.newName) --Doesn't work
                                    PrintTable(ingredients.unicorntear) -- works
    	
    end

    It works if I do PrintTable(ingredients.unicorntear) but not if I do PrintTable(ingredients.newName).
    Probably obvious what the problem is but I can't figure it out.
    Maybe because ingredients.newName doesn't exist? Or am I missing something else?
    Reply With Quote Edit / Delete Windows 7 Hungary Show Events

  26. Post #146
    Maybe because ingredients.newName doesn't exist? Or am I missing something else?
    Thanks to raBBish I figured it out. I was just doing it the wrong way.
    Reply With Quote Edit / Delete Windows XP United States Show Events

  27. Post #147
    Gold Member
    ralle105's Avatar
    October 2005
    4,627 Posts
    Do
    ingredients[newName]
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  28. Post #148
    Title

    August 2009
    300 Posts
    I may be wrong but you could run a sqlite server that uses the gmod database.
    What do you mean by running the gmod database?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  29. Post #149
    PencilOnDesk's Avatar
    October 2011
    120 Posts
    function bloodtest()
    	for k,v in pairs(player.GetAll()) do
     		if v:Health() >= 25 then 
     			if timer.IsTimer("NextBleedOut") then
     				timer.Destroy("NextBleedOut")
     			end
     		end
     		if v:Health() <= 24 then
     			if timer.IsTimer("NextBleedOut") then return end
     			timer.Create("NextBleedOut",1,0,function()
    				local Pos = v:GetPos() + Vector(0,0,30)
    				local effectdata = EffectData()
    				effectdata:SetStart( Pos )
    				effectdata:SetOrigin( Pos )
    				effectdata:SetScale( 1 )
    				util.Effect( "BloodImpact", effectdata )
    				local trace = {};
    				trace.start = v:GetPos() + Vector(0, 0, 256);
    				trace.endpos = trace.start + Vector(0, 0, -1024);
    				trace.filter = v;
    				trace2 = util.TraceLine(trace);
     				util.Decal("Blood", trace2.HitPos + trace2.HitNormal, trace2.HitPos - trace2.HitNormal)
    
    			end)
    		end
    	end
    end
    hook.Add("Think","Bloodoasdf",bloodtest)
    
    hook.Add("PlayerDeath","ClearTimers", function()
    	if timer.IsTimer("NextBleedOut") then
    		timer.Destroy("NextBleedOut")
    	end
    end)

    Trying to work on some sort of bleeding system where the decal is drawn under the player; However at the moment the Decal only gets drawn when the player dies. Why is this?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  30. Post #150
    Mrwhitee's Avatar
    January 2012
    31 Posts
    anyhow i can make it so that theres no way to unfreeze the props?

    local function CreateWorldProp( model, pos, ang, freeze )
    
        local ent = ents.Create( "prop_physics" )
        ent:SetModel( model )
        ent:SetPos( pos )
        ent:SetAngles( ang )
        ent:Spawn()
    
        if freeze then
        
            local phys = ent:GetPhysicsObject()
            if phys and phys:IsValid() then
    
                phys:EnableMotion( false )
    
            end
    
        end
    
        return ent
    end
    
    hook.Add( "InitPostEntity", "CreateWorldProps", function()
     
        CreateWorldProp( "models/props/de_train/de_train_signalbox_01.mdl", Vector( -1756.6875, -674.7813, -195.4688 ), Angle( 0.000, -90.011, 0.000 ), true )
        CreateWorldProp( "models/props/cs_assault/TicketMachine.mdl", Vector( -939.9688, 1551.0000, -447.5625 ), Angle( 0.000, 90.011, 0.000 ), true )
    	CreateWorldProp( "models/props_trainstation/bench_indoor001a.mdl", Vector( -117.4688, 424.2188, -176.6875 ), Angle( 0.088, 90.011, 0.000 ), true )
    	CreateWorldProp( "models/props/cs_italy/it_blc_med.mdl", Vector( -1827.7813, -656.4375, 82.5625 ), Angle( 0.000, -90.011, 0.000 ), true )
    
    end )
    Reply With Quote Edit / Delete Windows 7 Denmark Show Events

  31. Post #151
    Gold Member
    marvincmarvin's Avatar
    January 2011
    795 Posts
    Reply With Quote Edit / Delete Windows 7 United States Show Events Lua Helper Lua Helper x 1 (list)

  32. Post #152
    Fantym420's Avatar
    October 2010
    891 Posts

    try adding these (or just one or the other) before ent:Spawn()

    ent:SetKeyValue("gmod_allowphysgun","0")
    ent:SetKeyValue("gmod_allowtools","0")
    

    that should stop them from being affected by physgun and tool gun


    edited:

    lol, should have refreshed, the other way looks easier.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  33. Post #153
    SFArial's Avatar
    May 2009
    1,174 Posts
    function bloodtest()
    	for k,v in pairs(player.GetAll()) do
     		if v:Health() >= 25 then 
     			if timer.IsTimer("NextBleedOut") then
     				timer.Destroy("NextBleedOut")
     			end
     		end
     		if v:Health() <= 24 then
     			if timer.IsTimer("NextBleedOut") then return end
     			timer.Create("NextBleedOut",1,0,function()
    				local Pos = v:GetPos() + Vector(0,0,30)
    				local effectdata = EffectData()
    				effectdata:SetStart( Pos )
    				effectdata:SetOrigin( Pos )
    				effectdata:SetScale( 1 )
    				util.Effect( "BloodImpact", effectdata )
    				local trace = {};
    				trace.start = v:GetPos() + Vector(0, 0, 256);
    				trace.endpos = trace.start + Vector(0, 0, -1024);
    				trace.filter = v;
    				trace2 = util.TraceLine(trace);
     				util.Decal("Blood", trace2.HitPos + trace2.HitNormal, trace2.HitPos - trace2.HitNormal)
    
    			end)
    		end
    	end
    end
    hook.Add("Think","Bloodoasdf",bloodtest)
    
    hook.Add("PlayerDeath","ClearTimers", function()
    	if timer.IsTimer("NextBleedOut") then
    		timer.Destroy("NextBleedOut")
    	end
    end)

    Trying to work on some sort of bleeding system where the decal is drawn under the player; However at the moment the Decal only gets drawn when the player dies. Why is this?
    Just checked it for you, I'm pretty sure the decal is applied to the player.
    Reply With Quote Edit / Delete Windows 7 Hungary Show Events

  34. Post #154

    January 2012
    131 Posts
    What would be the correct way to send a string from the server to all clients?

    e.g I gave all the players a name server-side and using ply:GetRPName() returns the name string. Now I want all players in the server to know that players RP name. Should I use NetworkedString (NWString) or usermessages?

    I just can't find an optimized way to do it. How should I handle new players connecting and receiving that name?
    Reply With Quote Edit / Delete Windows 7 Estonia Show Events

  35. Post #155
    SFArial's Avatar
    May 2009
    1,174 Posts
    What would be the correct way to send a string from the server to all clients?

    e.g I gave all the players a name server-side and using ply:GetRPName() returns the name string. Now I want all players in the server to know that players RP name. Should I use NetworkedString (NWString) or usermessages?

    I just can't find an optimized way to do it. How should I handle new players connecting and receiving that name?
    NWStrings seem like your best bet because all clients need to recieve it. Usermessages are mainly for when sending data to specific clients. If you aren't changing these RP names a lot then you have nothing to worry about.
    Reply With Quote Edit / Delete Windows 7 Hungary Show Events

  36. Post #156
    pennerlord's Avatar
    February 2011
    501 Posts
    What do you mean by running the gmod database?
    Nevermind. I was wrong. Sqlite is serverless.

    Most SQL database engines are implemented as a separate server process. Programs that want to access the database communicate with the server using some kind of interprocess communication (typically TCP/IP) to send requests to the server and to receive back results. SQLite does not work this way. With SQLite, the process that wants to access the database reads and writes directly from the database files on disk. There is no intermediary server process.
    Source: http://www.sqlite.org/serverless.html

    However you can still use Sqlite with PHP.
    That might be useful: http://www.php.net/manual/en/book.sqlite.php
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  37. Post #157
    PencilOnDesk's Avatar
    October 2011
    120 Posts
    Just checked it for you, I'm pretty sure the decal is applied to the player.
    How would I fix the issue, I really can't think of another way to place the decal other than that.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  38. Post #158
    Gold Member
    confinedUser's Avatar
    October 2008
    3,534 Posts
    how do i define a local variable because according to gmod this isn't enough
    local Colors =
    {
    	border = Color( 255, 255, 255, 255),
    	background = Color( 255, 255, 255, 200 ),
    	shade = Color( 255, 255, 255, 255 ),
    	fill = Color( 0, 0, 0, 255 ),
    };
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  39. Post #159
    pennerlord's Avatar
    February 2011
    501 Posts
    how do i define a local variable because according to gmod this isn't enough
    local Colors =
    {
    	border = Color( 255, 255, 255, 255),
    	background = Color( 255, 255, 255, 200 ),
    	shade = Color( 255, 255, 255, 255 ),
    	fill = Color( 0, 0, 0, 255 ),
    };
    Like the way you are doing it now.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Agree Agree x 2 (list)

  40. Post #160
    Gold Member
    confinedUser's Avatar
    October 2008
    3,534 Posts
    Like the way you are doing it now.
    I fixed it I guess I had the "C" in colors capitalized
    Reply With Quote Edit / Delete Windows 7 United States Show Events