• What do you need help with? V3
    6,419 replies, posted
[url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index7110-2.html[/url] [code] ] lua_run_cl LocalPlayer():GetActiveWeapon().TestFunc = function() print("hi") end ] lua_run Drake():GetActiveWeapon():CallOnClient( "TestFunc", "" ) -- (clientside) hi [/code]
[QUOTE=Drakehawke;38752587][url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index7110-2.html[/url] [code] ] lua_run_cl LocalPlayer():GetActiveWeapon().TestFunc = function() print("hi") end ] lua_run Drake():GetActiveWeapon():CallOnClient( "TestFunc", "" ) -- (clientside) hi [/code][/QUOTE] Kewl, I did a function myself for a sent using umsg. I named it CallOnClient, too. So this is it basically the same for sweps.
Is there an easy way to explode a string using several seperators? For example, if I had the string [CODE] 'abcdefghijklmnopqrstuvwxyz' [/CODE] and I wanted to explode it by the letters 'd', 'j', 'o', and 'y' so I'd get a result of [CODE] { 'abc', 'efghi', 'klmn', 'pqrstuvwx', 'z' } [/CODE]
[URL="http://facepunch.com/showthread.php?t=1160598&p=38741371#post38741371"]http://facepunch.com/showthread.php?t=1160598&p=38741371#post38741371[/URL] any help? ;_;
[QUOTE=Sezasm;38752722]Is there an easy way to explode a string using several seperators? For example, if I had the string [CODE] 'abcdefghijklmnopqrstuvwxyz' [/CODE] and I wanted to explode it by the letters 'd', 'j', 'o', and 'y' so I'd get a result of [CODE] { 'abc', 'efghi', 'klmn', 'pqrstuvwx', 'z' } [/CODE][/QUOTE] [lua] string.Explode("[djoy]", str, true) --explodes str by the letters 'd', 'j', 'o', and 'y' [/lua]
Sorry, I'm a complete noob with no experience at all in coding besides a little javascript. I thought I could fix this code by switching the experimental fonts to HUDNumber, which should be a font included with GMod. It doesn't show up at all in GMod. I put it in lua/autorun/client: this might be wrong as well. [lua] paraHud = {}; paraHud.SUPER_SIZE = 0.05/2; -- 3D Hud Scale (Def: 0.05) paraHud.SUPER_DISTANCE = 25/2; -- 3D Hud Distance (Def: 25) paraHud.SUPER_ANGLE = 20; -- 3D Hud Angle (Def: 20) paraHud.SUPER_COLOR = Color(229, 178, 85, 255); paraHud.ScreenWidth = 0; paraHud.ScreenHeight = 0; paraHud.ScreenFOV = 0; -- 15 DEGREES -- 16:9 FOV90 (2/2/1) 0.4 DIFF -- 16:9 FOV75 (2.4/2/1) -- 16:10 FOV90 (2.15/2/1) 0.45 DIFF -- 16:10 FOV75 (2.6/2/1) -- 4:3 FOV90 (2.6/2/1) 0.55 DIFF -- 4:3 FOV75 (3.15/2/1) function GM:HUDPaint() --paraHud.Health(); --paraHud.Need(); --paraHud.Test3D(); paraHud.CheckDimensions(); -- Draw 3D Hud cam.Start3D(EyePos(), EyeAngles()) --paraHud.SuperHud(); cam.End3D() --paraHud.GetPlayerInfo(); end function GM:HUDShouldDraw(name) local draw = true; if(name == "CHudHealth" or name == "CHudBattery" or name == "CHudAmmo" or name == "CHudSecondaryAmmo") then draw = false; end return draw; end function paraHud.CheckDimensions() local width = ScrW(); local height = ScrH(); local fov = LocalPlayer():GetFOV(); if(paraHud.ScreenWidth ~= width or paraHud.ScreenHeight ~= height or (fov >= 75 and paraHud.ScreenFOV ~= fov)) then paraHud.ChangeRatios(width, height, fov); end return; end function paraHud.ChangeRatios(width, height, fov) local fovDiff = fov - 75; if(width / height == 16 / 9) then paraHud.SUPER_SIZE = 0.05 / (2.4 - 0.4 * (fovDiff / 15)); print("Changed to 16:9 mode!"); elseif(width / height == 16 / 10) then paraHud.SUPER_SIZE = 0.05 / (2.6 - 0.45 * (fovDiff / 15)); print("Changed to 16:10 mode!"); else paraHud.SUPER_SIZE = 0.05 / (3.15 - 0.55 * (fovDiff / 15)); print("Changed to 4:3 mode!"); end paraHud.ScreenWidth = width; paraHud.ScreenHeight = height; paraHud.ScreenFOV = fov; return; end function paraHud.Health3D(pl, pos, ang) local health = pl:Health(); cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/4 ); draw.DrawText(health, "HUDNumber", -440*4, 182*4, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER ); cam.End3D2D(); surface.SetFont("HUDNumber"); cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/2 ); draw.DrawText("/100", "HUDNumber", (-440*2)+(surface.GetTextSize(health)/2), 194*2, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER ); draw.DrawText("Alien Host", "HUDNumber", -440*2, 212*2, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER ); cam.End3D2D(); return; end function paraHud.Weapon3D(pl, pos, ang) local weapon = pl:GetActiveWeapon(); if(weapon ~= nil) then local weaponType = weapon:GetPrintName(); local weaponMag = weapon:Clip1(); local weaponAmmo = pl:GetAmmoCount(weapon:GetPrimaryAmmoType()); if(weaponMag < 0) then if(weaponAmmo > 0) then -- Basic cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/4 ); draw.DrawText(weaponAmmo, "HUDNumber", 440*4, 182*4, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER ); cam.End3D2D(); cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/2 ); draw.DrawText(weaponType, "HUDNumber", 440*2, 212*2, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER ); cam.End3D2D(); else -- Melee cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/2 ); draw.DrawText(weaponType, "HUDNumber", 440*2, 212*2, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER ); cam.End3D2D(); end elseif(weaponAmmo < 1 and weaponMag < 1) then -- No Ammo cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/2 ); draw.DrawText(weaponType, "HUDNumber", 440*2, 212*2, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER ); cam.End3D2D(); else -- Full cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/2 ); draw.DrawText("/"..weaponAmmo, "HUDNumber", 440*2, 194*2, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER ); draw.DrawText(weaponType, "HUDNumber", 440*2, 212*2, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER ); cam.End3D2D(); surface.SetFont("HUDNumber"); cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/4 ); draw.DrawText(weaponMag, "HUDNumber", (440*4)-(surface.GetTextSize("/"..weaponAmmo)*2), 182*4, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER ); cam.End3D2D(); end end return; end function paraHud.Need3D(pl, pos, ang) cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/(4*1.1) ); draw.DrawText("KILL", "HUDNumber", -460*4, -257*4, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP ); cam.End3D2D(); surface.SetFont("HUDNumber"); cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/(2*1.1) ); draw.DrawText("10x", "HUDNumber", (-458*2)+(surface.GetTextSize("PISS")/2), -255*2, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP ); draw.DrawText("Need", "HUDNumber", -460*2, -270*2, paraHud.SUPER_COLOR, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP ); cam.End3D2D(); end function paraHud.Time3D(pl, pos, ang) cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/(4*1.1) ); draw.DrawText("5:12", "HUDNumber", 460*4, -255*4, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP ); cam.End3D2D(); surface.SetFont("HUDNumber"); cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/(2*1.1) ); draw.DrawText("Extraction", "HUDNumber", 460*2, -270*2, paraHud.SUPER_COLOR, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP ); cam.End3D2D(); end function paraHud.Inventory3D(pl, pos, ang) cam.Start3D2D( pos, ang, paraHud.SUPER_SIZE/4 ); draw.DrawText("1234567890", "HUDNumber", 0, 300*4, paraHud.SUPER_COLOR, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ); surface.SetDrawColor(paraHud.SUPER_COLOR); surface.DrawLine(-200*4, 285*4, 200*4, 285*4); -- Top surface.DrawLine(-200*4, 360*4, 200*4, 360*4); -- Bottom surface.DrawLine(-200*4, 285*4, -200*4, 360*4); -- Left surface.DrawLine(200*4, 285*4, 200*4, 360*4); -- Right cam.End3D2D(); return; end function paraHud.SuperHud() local pl = LocalPlayer(); local plAng = EyeAngles(); local plPos = EyePos(); local pos = plPos; local centerAng = Angle(plAng.p, plAng.y, 0); pos = pos + (centerAng:Forward() * paraHud.SUPER_DISTANCE); centerAng:RotateAroundAxis( centerAng:Right(), 90 ); centerAng:RotateAroundAxis( centerAng:Up(), -90 ); local leftAng = Angle(centerAng.p, centerAng.y, centerAng.r); local rightAng = Angle(centerAng.p, centerAng.y, centerAng.r); leftAng:RotateAroundAxis( leftAng:Right(), paraHud.SUPER_ANGLE*-1 ); rightAng:RotateAroundAxis( rightAng:Right(), paraHud.SUPER_ANGLE ); local centerAngUp = Angle(plAng.p, plAng.y, 0); centerAngUp:RotateAroundAxis( centerAngUp:Right(), 98 ); centerAngUp:RotateAroundAxis( centerAngUp:Up(), -90 ); local leftAngUp = Angle(centerAngUp.p, centerAngUp.y, centerAngUp.r); local rightAngUp = Angle(centerAngUp.p, centerAngUp.y, centerAngUp.r); leftAngUp:RotateAroundAxis( leftAngUp:Right(), paraHud.SUPER_ANGLE*-1 ); rightAngUp:RotateAroundAxis( rightAngUp:Right(), paraHud.SUPER_ANGLE ); if(pl:Alive() == true and pl:Health() > 0) t
[QUOTE=ralle105;38752988][lua] string.Explode("[djoy]", str, true) --explodes str by the letters 'd', 'j', 'o', and 'y' [/lua][/QUOTE] I just realized how badly I worded my question. That definitely works in the example that I gave, but I didn't care to mention that I'm trying to explode by two characters instead of one. So instead of 'd', 'j', 'o', and 'y', I need to explode by '#t', '#u', '#w', and '#r'. I've been looking at the pattern page on the wiki for a solid 20 minutes and I can't seem to get anything to work. I'm sure there's a way to do it, but I've never used patterns before and most of it looks like gibberish to me. Any help?
Hello everyone. Im trying to put a button on my HUD that has a click function to a concommand. When i tried to put it on my HUD It lagged everything out and the mouse what blinking. Can someone relate to this or has any idea how i can fix it? I used a simply VGUI button code. like this. [CODE]local DButton = vgui.Create( "DButton" ) DButton:SetPos( 40, 40 ) DButton:SetText( "Please click me!" ) DButton:SetSize( 120, 60 ) DButton.DoClick = function() print( "Button was clicked!" ) end[/CODE]
I have a solid object where basically everything except players (including bullet traces) must pass through, no idea how to do that
[QUOTE=amkoc;38753438]I have a solid object where basically everything except players (including bullet traces) must pass through, no idea how to do that[/QUOTE] ShouldCollide hook should do the trick.
Is there anyway to make E drag ragdolls like it normally picks up props? I've tried having a function inside the AllowPlayerPickup hook but that doesn't seem to be called when pressing E on ragdolls.
[QUOTE=Disseminate;38753478]ShouldCollide hook should do the trick.[/QUOTE] I tried that, didn't work: [lua] hook.Add("ShouldCollide", "pootis", function(e1,e2) print("pootis!") if e1:GetClass() == "barriertest" or e2:GetClass() == "barriertest" then print("e1 ".. tostring(e1) .. "/ e2" .. tostring(e2) .. " collided!") return false end end) [/lua] Nothing is printed, ever, and I collide with it And I did do self:EnableCustomCollisions( true )
[QUOTE=amkoc;38753586]I tried that, didn't work: [lua] hook.Add("ShouldCollide", "pootis", function(e1,e2) print("pootis!") if e1:GetClass() == "barriertest" or e2:GetClass() == "barriertest" then print("e1 ".. tostring(e1) .. "/ e2" .. tostring(e2) .. " collided!") return false end end) [/lua] Nothing is printed, ever, and I collide with it[/QUOTE] Don't you need to do ent:EnableCustomCollisions( true ) now for ShouldCollide to consider it or something?
Yes, I did that. Also, it's completely transparent to traces on the cilent, but not the server
[QUOTE=Sezasm;38753411]I just realized how badly I worded my question. That definitely works in the example that I gave, but I didn't care to mention that I'm trying to explode by two characters instead of one. So instead of 'd', 'j', 'o', and 'y', I need to explode by '#t', '#u', '#w', and '#r'. I've been looking at the pattern page on the wiki for a solid 20 minutes and I can't seem to get anything to work. I'm sure there's a way to do it, but I've never used patterns before and most of it looks like gibberish to me. Any help?[/QUOTE] Unfortunately, Lua patterns don't have "or" statements (Except the "[]" one, but that only works for single characters, and not entire strings). I'll never know why they decided to not add any. So exploding around string longer than 1 character simply isn't possible with just patterns. There are solutions to this problem, though. However, your strings all begin with #. Because of this, you don't need to use or statements at all, and you don't get the aforementioned problem. [code]string.Explode( "#[tuwr]", str, true[/code] If each of your strings were different two-letter strings, then we'd need to use some additional Lua code to solve it.
[QUOTE=amkoc;38753666]Yes, I did that. Also, it's completely transparent to traces on the cilent, but not the server[/QUOTE] Is it shared?
[QUOTE=Divran;38753700]Unfortunately, Lua patterns don't have "or" statements (Except the "[]" one, but that only works for single characters, and not entire strings). I'll never know why they decided to not add any. So exploding around string longer than 1 character simply isn't possible with just patterns. There are solutions to this problem, though. However, your strings all begin with #. Because of this, you don't need to use or statements at all, and you don't get the aforementioned problem. [code]string.Explode( "#[tuwr]", str, true[/code] If each of your strings were different two-letter strings, then we'd need to use some additional Lua code to solve it.[/QUOTE] I can't believe I didn't think of that, works perfectly. Thank you!
How can I have HL2 shell effects shoot out from my swep? I figured it would be default, but only other players can see the effects. Even then, they come out as shotgun shells. SWEP.ShellEffect doesn't work.
Hello, I am trying to fix up an old GMOD 12 SWEP. It's not working right, since for some reason the SWEP goes right through the NPC I hit it with. The SWEP is Baddog's Pokeballs, and I WILL remake this function, but when it works properly first. [CODE]function ENT:Touch( ent ) if self.Entity:GetNWBool("HasHitNpc") then return false end if not self.Entity:GetNWBool("HasHitNpc") then self.Entity:SetNWBool("HasHitNpc", true) self:DoColorstuff(ent) self.Entity:EmitSound(Sound("Pokeballs/capture.wav")) end if ent:GetClass() == "npc_antlion" then self.Entity:SetNWBool("antlion", true) elseif ent:GetClass() == "npc_antlionguard" then self.Entity:SetNWBool("antlionguard", true) elseif ent:GetClass() == "npc_antlion_worker" then self.Entity:SetNWBool("antlion_worker", true) elseif ent:GetClass() == "npc_cscanner" then self.Entity:SetNWBool("cscanner", true) elseif ent:GetClass() == "npc_clawscanner" then self.Entity:SetNWBool("clawscanner", true) elseif ent:GetClass() == "npc_combine_s" and ent:GetModel() == "models/combine_soldier.mdl" then self.Entity:SetNWBool("combine_s", true) elseif ent:GetClass() == "npc_combine_s" and ent:GetModel() == "models/combine_soldier_prisonguard.mdl" then self.Entity:SetNWBool("combine_p", true) elseif ent:GetClass() == "npc_combine_s" and ent:GetModel() == "models/combine_super_soldier.mdl" then self.Entity:SetNWBool("combine_e", true) elseif ent:GetClass() == "npc_crow" then self.Entity:SetNWBool("crow", true) elseif ent:GetClass() == "npc_headcrab_fast" then self.Entity:SetNWBool("headcrab_fast", true) elseif ent:GetClass() == "npc_headcrab" then self.Entity:SetNWBool("headcrab", true) elseif ent:GetClass() == "npc_headcrab_black" then self.Entity:SetNWBool("headcrab_black", true) elseif ent:GetClass() == "npc_hunter" then self.Entity:SetNWBool("hunter", true) elseif ent:GetClass() == "npc_manhack" then self.Entity:SetNWBool("manhack", true) elseif ent:GetClass() == "npc_metropolice" then self.Entity:SetNWBool("metropolice", true) elseif ent:GetClass() == "npc_pigeon" then self.Entity:SetNWBool("pigeon", true) elseif ent:GetClass() == "npc_poisonzombie" then self.Entity:SetNWBool("poisonzombie", true) elseif ent:GetClass() == "npc_rollermine" then self.Entity:SetNWBool("rollermine", true) elseif ent:GetClass() == "npc_seagull" then self.Entity:SetNWBool("seagull", true) elseif ent:GetClass() == "npc_vortigaunt" then self.Entity:SetNWBool("vortigaunt", true) elseif ent:GetClass() == "npc_zombie" then self.Entity:SetNWBool("zombie", true) elseif ent:GetClass() == "npc_zombie_torso" then self.Entity:SetNWBool("zombie_torso", true) elseif ent:GetClass() == "npc_zombine" then self.Entity:SetNWBool("zombine", true) elseif ent:GetClass() == "npc_fastzombie" then self.Entity:SetNWBool("fastzombie", true) elseif ent:GetClass() == "npc_fastzombie_torso" then self.Entity:SetNWBool("fastzombie_torso", true) elseif ent:GetClass() == "npc_kleiner" then self.Entity:SetNWBool("kleiner", true) end end end[/CODE]
i need some help with my gamemode not loading [URL="http://facepunch.com/showthread.php?t=1231235"]http://facepunch.com/showthread.php?t=1231235[/URL]
[QUOTE=DJarthas;38753426]Hello everyone. Im trying to put a button on my HUD that has a click function to a concommand. When i tried to put it on my HUD It lagged everything out and the mouse what blinking. Can someone relate to this or has any idea how i can fix it? I used a simply VGUI button code. like this. [CODE]local DButton = vgui.Create( "DButton" ) DButton:SetPos( 40, 40 ) DButton:SetText( "Please click me!" ) DButton:SetSize( 120, 60 ) DButton.DoClick = function() print( "Button was clicked!" ) end[/CODE][/QUOTE] If you put it in GM:HUDPaint() then of course it's going to lag. You're creating a new button each frame.
[QUOTE=A Lost Sandwich;38755917]If you put it in GM:HUDPaint() then of course it's going to lag. You're creating a new button each frame.[/QUOTE] Ohh yea that makes sense
[QUOTE=Disseminate;38753781]Is it shared?[/QUOTE] Aye, that it is
I fixed most of the Pokeball SWEP addon, it's just a matter of a cycle. [url]https://dl.dropbox.com/u/97639347/stuff.txt[/url] When you "capture" an NPC, it has to be stored for "pb_base" somehow, which I am unsure how to do it. Help will be GREATLY appreciated!
Hey, I noticed recently that the scoreboard for TTT has.. disappeared and pretty much is disorganized. I've been looking through the lua for evolve and I don't get if it's Evolve's fault or my own. What's broken? It gives no errors, they just disappear. EG No dead players are showing, and my karma disappears, but everyone else is there. This isn't clientside because this happens for everyone. [editline]9th December 2012[/editline] Does evolve cause this? [editline]9th December 2012[/editline] Also this [lua] [ERROR] ...rortown/entities/weapons/weapon_ttt_flashbang/shared.lua:287: bad argument #1 to 'SetAngles' (Angle expected, got userdata) 1. SetAngles - [C]:-1 2. ThrowFar - ...rortown/entities/weapons/weapon_ttt_flashbang/shared.lua:287 3. unknown - ...rortown/entities/weapons/weapon_ttt_flashbang/shared.lua:211[/lua] If you help me I'll have your children [url]https://dl.dropbox.com/u/34091117/shared%202.lua[/url]
Is there any documentation on the new Awesomium panels? I've seen people using them, but I don't see any documentation on the wiki or anything. [editline]9th December 2012[/editline] More specifically, I'd like to create a HUD. How can I pass Lua variables to a DHTML panel.
[QUOTE=KatNotDinner;38749814]I forgot, sorry. [lua] local parent, size, bone, pos, ang, mod, and_offset function ENT:Initialize() --mod = ClientsideModel(self:GetModel()) end local LocalPlayer = LocalPlayer function ENT:Draw() parent = parent or self:GetDTEntity(1) size = size or self:GetDTFloat(1) vector = vector or hats[self:GetDTFloat(2)].vector_offset ang_offset = ang_offset or hats[self:GetDTFloat(2)].ang_offset bone = bone or parent:LookupBone( self:GetDTString( 1 ) ) pos, ang = parent:GetBonePosition(bone) --mod = mod or ClientsideModel( self:GetModel() ) /*if offset then mod:SetRenderOrigin( pos + self:offset(pos, ang )) else mod:SetRenderOrigin( pos ) end mod:SetRenderAngles( ang ) mod:SetModelScale( size, 1 ) mod:SetupBones() mod:DrawModel()*/ if parent == LocalPlayer() then return end if vector then self:SetRenderOrigin( vector( pos, ang ) ) else self:SetRenderOrigin( pos ) end if ang_offset then ang_offset(ang) self:SetRenderAngles( ang ) else self:SetRenderAngles( ang ) end self:SetModelScale( size, 1 ) self:SetupBones() self:DrawModel() end[/lua] All of the DTVars exist, all of the functions exist, i have even made debug prints to make sure, so that's not the case. The model just dissappears when facing a certain direction. I can't record it on a video cause my pc is slightly more powerfull than a microwave.[/QUOTE] Anyone ;_;
[IMG]http://puu.sh/1xow2[/IMG] What was the fix for that again? Garry cleared the Dev section, but the bug still exists.
[QUOTE=ollie;38762808]What was the fix for that again? Garry cleared the Dev section, but the bug still exists.[/QUOTE] It's still in the dev section. [url=http://www.facepunch.com/showthread.php?t=1230965]Here[/url].
Ah missed that, thank you.
Sorry, you need to Log In to post a reply to this thread.