• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
[QUOTE=PigeonPatrol;47813686]do you have multiple ones? Cache player.GetAll() to a variable at the start of your think function.[/QUOTE] I only have one for loop like that, however... it's in each of my (currently) 4 scripts individual (to be 5 in the near future) Since each script focuses on a different and specific feature, I won't merge them. [editline]27th May 2015[/editline] Uhm... maybe I can make a global variable? In each script, in an Initialize hook, check if not (var) then (var) = player.GetAll()
Is there a way to search for a texture within radius of an entity? Positive i've seen this somewhere but searching it only gives "how to get gmod textures" stuff in google. Thanks :eng101:
Have a look at [url]http://wiki.garrysmod.com/page/Structures/TraceResult[/url]
[QUOTE=xaviergmail;47813886]Have a look at [url]http://wiki.garrysmod.com/page/Structures/TraceResult[/url][/QUOTE] Thanks for a little direction but this would only help if you're looking at that texture. How could you find if the texture was just near an ent?
You could try an OOBB trace or perform more than one line trace in multiple directions. AFAIK there's no other [I]simple[/I] way to do it.
[QUOTE=xaviergmail;47813960]You could try an OOBB trace or perform more than one line trace in multiple directions. AFAIK there's no other [I]simple[/I] way to do it.[/QUOTE] Thanks for your help!
I've adopted an old gamemode and have been working on it for a while now. I seem to be having an issue where the client (has happened to multiple client - not at once) stops rendering GMod. I am able to freely move but without my game showing any change. Pressing Esc does nothing and I'm forced to restart the game. No errors at all. The reason why I'm posting here is, that I'm pretty sure it's caused by the gamemode. It's a pretty huge gamemode and I haven't read it through entirely, but I didn't know this could be caused by Lua. Does anyone of you know whether this issue could be caused by Lua or whether it's more likely a map issue (which I doubt it is)?
Using Handsome Matt's 3d2d vgui library, how do I 'parent' this panel to my view model? Everything I try doesn't follow the view model correctly [code] local client = LocalPlayer() local frame = vgui.Create( "DFrame" ) frame:SetPos( 0, 0 ) frame:SetSize( 400, 250 ) frame:SetTitle( "Test" ) hook.Add( "PreDrawViewModel", "DrawSample3D2DFrame2", function( vm, ply, wep ) if ply != client then return end if wep != self then return end local fwd = client:GetForward() local rgt = client:GetRight() local pos = vm:GetPos() local eyeAng = client:EyeAngles() local vmAng = vm:GetAngles() pos = pos + Vector( (fwd.x * 10) - (rgt.x * 2), (fwd.y * 10) - (rgt.y * 2), 0 ) local ang = Angle( 0, eyeAng.y - 90, 90 ) vgui.Start3D2D( pos, ang, 0.01 ) frame:Paint3D2D() vgui.End3D2D() end) [/code] [t]http://i.gyazo.com/6dbae80bb23bf48679b894def5f9574c.jpg[/t]
So when a player is falling, it seems that this does nothing at all: [code]local PlrVel = ply:GetVelocity() ply:SetVelocity( Vector( PlrVel.x, PlrVel.y, 0 ) )[/code] Where I'm trying to cancel out the falling speed. To cancel out the Z speed, bring it to 0. Is there a way that works? (especially since I'm trying to add even more Upward Z to the velocity, too)
[QUOTE=WalkingZombie;47822408]So when a player is falling, it seems that this does nothing at all: [code]local PlrVel = ply:GetVelocity() ply:SetVelocity( Vector( PlrVel.x, PlrVel.y, 0 ) )[/code] Where I'm trying to cancel out the falling speed. To cancel out the Z speed, bring it to 0. Is there a way that works? (especially since I'm trying to add even more Upward Z to the velocity, too)[/QUOTE] If used on a player/npc, it adds to the velocity. You gotta apply the inverse of the current velocity to cancel it out.
[QUOTE=MGCLegend;47813843]Is there a way to search for a texture within radius of an entity? Positive i've seen this somewhere but searching it only gives "how to get gmod textures" stuff in google. Thanks :eng101:[/QUOTE] Get a table using [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/ents/FindInSphere"]ents.FindInSphere[/URL] at your entity's vector and then perform a loop on the result searching [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Entity/GetMaterial"]Entity:GetMaterial[/URL] for the material you want. But do note that this will not work for parts of the map. [QUOTE=DarthTealc;47821811]Is there a way to display a Panel as a material? I want to display an avatar on a model so I figure I'd use the [URL="http://wiki.garrysmod.com/page/Category:AvatarImage"]AvatarImage panel[/URL] but I am not sure how to go about making that into a material. Doesn't need to be a panel if there's a way to display avatars other than as panels. EDIT: There's a [URL="http://wiki.garrysmod.com/page/Panel/GetHTMLMaterial"]GetHTMLMaterial[/URL] function but I can't find anything similar for AvatarImage.[/QUOTE] I don't think you can, but another way would be to use [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Panel/GetHTMLMaterial"]Panel:GetHTMLMaterial[/URL] on a page that uses the [IMG]https://steamcommunity.com/favicon.ico[/IMG] [URL="https://developer.valvesoftware.com/wiki/Steam_Web_API#GetPlayerSummaries_.28v0002.29"]steam API[/URL] to get a persons avatar via the web; I have used this method before.
[QUOTE=DarthTealc;47821811]Is there a way to display a Panel as a material? I want to display an avatar on a model so I figure I'd use the [URL="http://wiki.garrysmod.com/page/Category:AvatarImage"]AvatarImage panel[/URL] but I am not sure how to go about making that into a material. Doesn't need to be a panel if there's a way to display avatars other than as panels. EDIT: There's a [url=http://wiki.garrysmod.com/page/Panel/GetHTMLMaterial]GetHTMLMaterial[/url] function but I can't find anything similar for AvatarImage.[/QUOTE] you can render a panel as a material using rendertargets, just push your rt, call Panel:PaintManual(), then pop it, but I dunno if there's a better way to do it with avatars
How can I make the collision box of something smaller? I try to change this: [IMG]https://i.gyazo.com/f81e32b063ef9515b8324d56996562c4.png[/IMG] It has a sidecar bodygroup, and I check if that bodygroup is not shown, then I want the collision box to only cover the bike, so atleast players doesn't collide with the invisible sidecar: [IMG]https://i.gyazo.com/f6d6de3a7a86f932944a25b33741e31c.png[/IMG] I tried with SetCollisionBounds(), I tried Vector( 0, 0, 0 ) in both min and max but it still collides everywhere just can't physgun it
Creating timers in a code when it comes to SWEPs will break prediction, so is there another way to send a weapon animation after a reload? For the AR2, its viewmodel, when you reload with it, since I don't send the idle animation after the reload, just looks kinda weird, and I have no idea how to, in a timed manner, send it's idle animation.
[QUOTE=Busan1;47822777]How can I make the collision box of something smaller? I try to change this: [IMG]https://i.gyazo.com/f81e32b063ef9515b8324d56996562c4.png[/IMG] It has a sidecar bodygroup, and I check if that bodygroup is not shown, then I want the collision box to only cover the bike, so atleast players doesn't collide with the invisible sidecar: [IMG]https://i.gyazo.com/f6d6de3a7a86f932944a25b33741e31c.png[/IMG] I tried with SetCollisionBounds(), I tried Vector( 0, 0, 0 ) in both min and max but it still collides everywhere just can't physgun it[/QUOTE] Use PhysicsInitBox or something. [editline]28th May 2015[/editline] [QUOTE=A Fghtr Pilot;47823532]Creating timers in a code when it comes to SWEPs will break prediction, so is there another way to send a weapon animation after a reload? For the AR2, its viewmodel, when you reload with it, since I don't send the idle animation after the reload, just looks kinda weird, and I have no idea how to, in a timed manner, send it's idle animation.[/QUOTE] Take a look at default Fists or Medkit weapons, they should have Idle anims handled properly.
[QUOTE=Robotboy655;47823552]Use PhysicsInitBox or something. [editline]28th May 2015[/editline] Take a look at default Fists or Medkit weapons, they should have Idle anims handled properly.[/QUOTE] After looking through the Fists, it still confuses me
[QUOTE=A Fghtr Pilot;47823577]After looking through the Fists, it still confuses me[/QUOTE] You create another networkvar, you set it to CurTime() + self:SequenceDuration() after you've done your attack animation, then in your think hook you check if your idle networkvar is more than 0 and is less than curtime, then play the animation and set the var to 0. You can also do the first part when you deploy the weapon. [editline]28th May 2015[/editline] It's like making your own timer, but with actual prediction support. [editline]28th May 2015[/editline] Reference code. [code] function SWEP:SetupDataTables() self:NetworkVar( "Float" , 0 , "NextIdle" ) end function SWEP:Initialize() self:SetNextIdle( 0 ) end function SWEP:PrimaryAttack() self:SetNextPrimaryFire( CurTime() + 1 ) self:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) self:SetNextIdle( CurTime() + self:SequenceDuration() ) end function SWEP:Think() if self:GetNextIdle() ~= 0 and self:GetNextIdle() < CurTime() then self:SendWeaponAnim( ACT_VM_IDLE ) self:SetNextIdle( 0 ) end end [/code]
Hey so I'm making an esc menu, although this is more of a general table question. How do I order tables correctly? I've never been able to get the hang of it I've got this and a bunch of others in a lua file, but when I loop through NiandraEsc.ButtonsDefault to place them onto my derma menu, they get put in a completely random order rather than the one they're written inside the lua file [code] AddDefaultButtons("1", { name = "Resume Game", func = "string", icon = "materials/niandralades/esc/resume.png" } ) [/code] Someone suggested before I use a number instead of the name as the key but I may have forgotten what else they said since it's the same problem
ipairs instead of pairs Also if you're literally using "1" as they key in your table, change it to 1.
[QUOTE=vexx21322;47822460]If used on a player/npc, it adds to the velocity. You gotta apply the inverse of the current velocity to cancel it out.[/QUOTE] ... yeah I've tried that too. That didn't work. [editline]28th May 2015[/editline] When currently my Velocity Z is set as such: math.max(0,[B]math.abs(OldVel.z)[/B])+ply:GetJumpPower()*Scal:GetFloat()*3 Yeah, everything there is positive, and math.abs(OldVel.z) should negate the falling velocity, right? (Scal is a convar, and in my tests, is positive, F.Y.I.)
[code]--shared.lua in my gamemode GM.TeamBased = true --TEAM_TERROR = 1 --TEAM_COUNTERTERROR = 2 I tried these and they didn't work so I tried the numbers seen below. still doesn't work function GM:CreateTeams() team.SetUp( 1, "Terrorists", Color( 255, 0, 0 ) ) team.SetUp( 2, "Counter Terrorists", Color( 61, 87, 105 ) ) end [/code] This results in: [url]http://postimg.org/image/oipgisfyn/[/url] even though I have these two teams defined. What am I doing wrong? I need help...
Well for instance, I just debugged my script and it says the Z value of the SetVelocity vector should've been 1280.5, and I had literally just hit the peak of my jump... yet I don't go upward at all?
If you need a predicted way to nullify velocity, you can use code similar to this: [code] local isNegatingGravity = false local sv_gravity = GetConVar "sv_gravity" local function NullifyVelocity( mv ) local vel = mv:GetVelocity(); vel.z = sv_gravity:GetFloat() * FrameTime() / 2 mv:SetVelocity( vel ) end hook.Add( "SetupMove", "", function( ply, mv, cmd ) isNegatingGravity = cmd:KeyDown( IN_ATTACK ) if isNegatingGravity then NullifyVelocity( mv ) end end ) hook.Add( "FinishMove", "", function( ply, mv ) if isNegatingGravity then NullifyVelocity( mv ) end end ) [/code] The reason for removing half of the gravity in each hook is because that is the opposite of the way Source's movement system applies it.
[QUOTE=Willox;47829229]If you need a predicted way to nullify velocity, you can use code similar to this: [code] local isNegatingGravity = false local sv_gravity = GetConVar "sv_gravity" local function NullifyVelocity( mv ) local vel = mv:GetVelocity(); vel.z = sv_gravity:GetFloat() * FrameTime() / 2 mv:SetVelocity( vel ) end hook.Add( "SetupMove", "", function( ply, mv, cmd ) isNegatingGravity = cmd:KeyDown( IN_ATTACK ) if isNegatingGravity then NullifyVelocity( mv ) end end ) hook.Add( "FinishMove", "", function( ply, mv ) if isNegatingGravity then NullifyVelocity( mv ) end end ) [/code][/quote] <snip> Post too big. Correction... there is literally no change ever since I made changes based on what you said... I can set the upward velocity to 16384 and it still does nothing. UHM... so idk if what I just did is [B]OKAY[/B], or [B]ACCEPTABLE[/B]... but it works :v: [code] ply:Freeze(true) timer.Simple( 0, function() ply:Freeze(false) ply:SetVelocity( NewVel ) end )[/code] Z = math.[B]max[/B]( [B]0[/B], [B]-1[/B]*[B]OldVel.z [/B]) + ply:GetJumpPower()*Scal:GetFloat() I really didn't wanna use ply:Freeze(x) because for that one tick, the player can't really send any commands if I understand the function correctly. But what harm can one sole tick of no commands really cause?
Anyone know how to get FractionLeftSolid to work? [url]http://wiki.garrysmod.com/page/Structures/TraceResult[/url] I start the trace inside a prop and set the endpos outside, but I can't get it to return anything other than 0. StartSolid returns true at least.
[QUOTE=thegrb93;47830887]Anyone know how to get FractionLeftSolid to work? [url]http://wiki.garrysmod.com/page/Structures/TraceResult[/url] I start the trace inside a prop and set the endpos outside, but I can't get it to return anything other than 0. StartSolid returns true at least.[/QUOTE] I can't say for sure, but maybe fiddling around with filters will get it to work? [editline]29th May 2015[/editline] It might help to see some code.
[QUOTE=zerf;47828438]ipairs instead of pairs[/QUOTE] What's the difference? I've always used pairs and never had any problems.
[QUOTE=meharryp;47833479]What's the difference? I've always used pairs and never had any problems.[/QUOTE] [url]http://www.luafaq.org/#T1.10[/url] Arrays, and continuities, and things.
How do I access the value of a concommand with FCVAR_ARCHIVE on. Solved it.
Sorry but I don't map much and play around with mapping and lua in the same context. How do you get details from a map. Say if a player is in a custom zone. If the map has a "bitches only" zone then how would you find if ply is in zone "bitches only"?
Sorry, you need to Log In to post a reply to this thread.