• What do you need help with? V3
    6,419 replies, posted
[b][url=http://wiki.garrysmod.com/?title=Player.InVehicle]Player.InVehicle [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] (Link is broken, use pennerlord's link below)
[QUOTE=Jinx786;34603670]How would I make an if(LocalPlayer() is driving a vehicle) please?[/QUOTE] [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index492c.html?title=Player.InVehicle"]Player.InVehicle[/URL]
Thank you!
[lua]if (LocalPlayer():InVehicle()) then[/lua] [editline]8th February 2012[/editline] [img]http://facepunch.com/fp/emoot/ninja.gif[/img] [editline]8th February 2012[/editline] Oh shit I'm super late.
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: [url]http://shrani.si/f/3G/An/2KsFibjw/countryside0007.jpg[/url]
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.
-ninja'd by 2 hours of this thread not being updated despite an F5...- That was weird.
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.
[QUOTE=Jinx786;34605362]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: [url]http://shrani.si/f/3G/An/2KsFibjw/countryside0007.jpg[/url][/QUOTE] 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.
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 [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[/LUA]
[QUOTE=werewolf0020;34608871] [LUA] for k,v in pairs(file.Find("stranded/gamemode/items/","stranded/gamemode/items/*.lu/a")) do[/LUA][/QUOTE] Really? That's not how you use file.Find. +spelling mistakes
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[/CODE] And well...since file.findinlua has been reemplased with file.find then how should i use it?
Is there any simple code to easily modify a v_model's origins? (with x y z values ofc)
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?
[QUOTE=G-Enigma;34609391]Is there any simple code to easily modify a v_model's origins? (with x y z values ofc)[/QUOTE] SWEPs have a hook called SWEP:GetViewModelPosition(pos,ang), use that. Example: [lua] function SWEP:GetViewModelPosition(pos,ang) ang.p = ang.p+1 return pos,ang end [/lua] Also you can modify it in CalcView somehow (can't remember and the gmod wiki is down).
[QUOTE=SFArial;34611614]SWEPs have a hook called SWEP:GetViewModelPosition(pos,ang), use that. Example: [lua] function SWEP:GetViewModelPosition(pos,ang) ang.p = ang.p+1 return pos,ang end [/lua] Also you can modify it in CalcView somehow (can't remember and the gmod wiki is down).[/QUOTE] Thanks! If you google the wiki though, somebody has a mirror up and it has most of the stuff. :)
-snip- helped, thanks ArmageddonScr.
[QUOTE=BooTs;34614286]And also, how do I make it so you don't have the chance to respawn after you die?[/QUOTE] [lua] function GM:PlayerDeathThink() return false end -- Something like this. [/lua] Also with rounds you want to account for players disconnecting, not just dying.
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.
emitter.Add adds a single particle to an already existing [B]lua[/B] particle emitter. You are looking for [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index09d2.html?title=G.ParticleEffect"]this[/URL].
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
[QUOTE=Mrkrabz;34620288]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[/QUOTE] I may be wrong but you could run a sqlite server that uses the gmod database.
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. [lua] 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[/lua] 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.
[QUOTE=Kidd;34623244]It works if I do PrintTable(ingredients.unicorntear) but not if I do PrintTable(ingredients.newName).[/QUOTE] Either change [lua] local newName = string.lower(string.Replace(ingredient," ",""))[/lua] to [lua] ingredients.newName = string.lower(string.Replace(ingredient," ",""))[/lua] Or change [lua] PrintTable(ingredients.newName)[/lua] to [lua] PrintTable(newName)[/lua] Either one, depending on what you want, but not both, because then it still won't work
[QUOTE=Kidd;34623244]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. [lua] 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[/lua] 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.[/QUOTE] Maybe because ingredients.newName doesn't exist? Or am I missing something else?
[QUOTE=SFArial;34623400]Maybe because ingredients.newName doesn't exist? Or am I missing something else?[/QUOTE] Thanks to raBBish I figured it out. I was just doing it the wrong way.
Do [lua]ingredients[newName][/lua]
[QUOTE=pennerlord;34621035]I may be wrong but you could run a sqlite server that uses the gmod database.[/QUOTE] What do you mean by running the gmod database?
[lua]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)[/lua] 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?
anyhow i can make it so that theres no way to unfreeze the props? [LUA]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 )[/LUA]
Sorry, you need to Log In to post a reply to this thread.