• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
[QUOTE=Exho;47499448]Alright well how do I give them a world model then for a specific gun? Are there any addons that do this that I could use for example code?[/QUOTE] Sorry for not linking it in my previous post, I was looking for this thread: [URL="http://facepunch.com/showthread.php?t=1262934&p=40380538&viewfull=1#post40380538"]http://facepunch.com/showthread.php?t=1262934&p=40380538&viewfull=1#post40380538[/URL]
Need help with math I have two sets of values, Ya = 100 Yb = 255 Za = 255 Zb = 100 Lets say value x dictates the final outcome when value x is 0, Y = 100, Z =255 when value x is 0.5, Y = 177.5, Z = 177.5 (Between 100 and 255) when value x is 1, Y = 255, Z = 100 I'm just having a massive brainfart with how to put it all together in code
You have perfectly described the behaviour of the Lerp function [url=http://wiki.garrysmod.com/page/Global/Lerp]Lerp (x, a, b)[/url]
[QUOTE=!cake;47500419]You have perfectly described the behaviour of the Lerp function [url=http://wiki.garrysmod.com/page/Global/Lerp]Lerp (x, a, b)[/url][/QUOTE] thx
[code] if self.Primary.ShotgunReload == true then self:SendWeaponAnim( ACT_SHOTGUN_RELOAD_START ) local reloadStartDur = self.Owner:GetViewModel( ):SequenceDuration( ) self:SendWeaponAnim( ACT_VM_RELOAD ) local reloadActDur = self.Owner:GetViewModel( ):SequenceDuration( ) self:SendWeaponAnim( ACT_SHOTGUN_RELOAD_FINISH ) local reloadFinishDur = self.Owner:GetViewModel( ):SequenceDuration( ) self:SendWeaponAnim( ACT_VM_IDLE ) self:SendWeaponAnim( ACT_SHOTGUN_RELOAD_START ) timer.Create( self:EntIndex( ).." reloadTimer", reloadActDur, 0, function( ) if self:Clip1( ) == self.Primary.ClipSize or self:Ammo1( ) == 0 then self:SendWeaponAnim( ACT_SHOTGUN_RELOAD_FINISH ) timer.Stop( self:EntIndex( ).." reloadTimer" ) timer.Destroy( self:EntIndex( ).." reloadTimer" ) else self.Weapon:SetAnimation( ACT_VM_RELOAD ) self:SetClip1( self:Clip1( ) + 1 ) end end ) else[/code] Why wouldn't this play the reload animation? The start and stop is totally fine.
How do I increase the text resolution of text rendered with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/cam/Start3D2D]cam.Start3D2D[/url]? It's really pixelated by default, and I can't find any function on the wiki related to font size or resolution.
Create your font with a larger size, maximum is 128
[QUOTE=Maurdekye;47501170]How do I increase the text resolution of text rendered with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/cam/Start3D2D]cam.Start3D2D[/url]? It's really pixelated by default, and I can't find any function on the wiki related to font size or resolution.[/QUOTE] Change the scale parameter to a smaller value.
[QUOTE=wauterboi;47500817]abomination[/QUOTE] Please, don't use timers. They're pretty great at bugging out. Instead, maybe use CurTime and something short and efficient in the think hook.
[QUOTE=xaviergmail;47501173]Create your font with a larger size, maximum is 128[/QUOTE] [QUOTE=mcd1992;47501700]Change the scale parameter to a smaller value.[/QUOTE] xaviergmail's answer is what I was looking for. Just making the text smaller is not what I wanted. I needed some way to keep it the same or a similar size and make it look prettier.
Making a 3D2D nametag that floats above the players head, however I want the text to always be facing the player lookin g at it. Ideas?
-snip-
[QUOTE=Sheeplie;47504554]Making a 3D2D nametag that floats above the players head, however I want the text to always be facing the player lookin g at it. Ideas?[/QUOTE] [lua] ( pos - LocalPlayer():GetShootPos() ):Angle() [/lua] Where pos is the position of the text above the players head.
Where do I implement this? Ive tried puttng it a few places no luck
[QUOTE=Sheeplie;47504554]Making a 3D2D nametag that floats above the players head, however I want the text to always be facing the player lookin g at it. Ideas?[/QUOTE] Lucky for you, I just so happened to have written this exact code; [lua] surface.CreateFont( "NameFont", { font = "Trebuchet18", size = 128, blursize = 2, antialias = true, }) hook.Add( "PostDrawOpaqueRenderables", "draw_names_admin", function() local ply = LocalPlayer() if ply:IsAdmin() then local plyPos = ply:EyePos() for _, p in pairs( player.GetAll() ) do if p ~= ply then local targetPos = p:EyePos() local textDelta = (targetPos - plyPos) local textPos = textDelta:GetNormalized() * 10 + ply:EyePos() local textAngle = textDelta:Angle() cam.Start3D2D( textPos, Angle(0, textAngle.y - 90, 90 - textAngle.p), 0.007 ) surface.SetFont( "NameFont" ) surface.SetTextColor( 255, 255, 255, 255 ) surface.SetTextPos( 0, 0 ) surface.DrawText( p:Name() ) cam.End3D2D() end end end end ) [/lua] Put that in a clientside lua file.
Is there any way of getting the server port, other than "hostport" convar? Because that is wrong if it cannot bind to the original port, it'll be different but the convar doesn't update.
[QUOTE=Maurdekye;47505158]Lucky for you, I just so happened to have written this exact code; [lua] surface.CreateFont( "NameFont", { font = "Trebuchet18", size = 128, blursize = 2, antialias = true, }) hook.Add( "PostDrawOpaqueRenderables", "draw_names_admin", function() local ply = LocalPlayer() if ply:IsAdmin() then local plyPos = ply:EyePos() for _, p in pairs( player.GetAll() ) do if p ~= ply then local targetPos = p:EyePos() local textDelta = (targetPos - plyPos) local textPos = textDelta:GetNormalized() * 10 + ply:EyePos() local textAngle = textDelta:Angle() cam.Start3D2D( textPos, Angle(0, textAngle.y - 90, 90 - textAngle.p), 0.007 ) surface.SetFont( "NameFont" ) surface.SetTextColor( 255, 255, 255, 255 ) surface.SetTextPos( 0, 0 ) surface.DrawText( p:Name() ) cam.End3D2D() end end end end ) [/lua] Put that in a clientside lua file.[/QUOTE] This doesn't seem to be working for me I'm running sandbox offline, I tried putting myself in users.txt as an admin, I even tried changing if ply:isadmin to if ply:isplayer. When I point a camera at myself, nothing. I am runing it cl.
[QUOTE=Sheeplie;47505701]This doesn't seem to be working for me I'm running sandbox offline, I tried putting myself in users.txt as an admin, I even tried changing if ply:isadmin to if ply:isplayer. When I point a camera at myself, nothing. I am runing it cl.[/QUOTE] It doesn't show a tag for yourself. You need other players on the server.
[QUOTE=Maurdekye;47505751]It doesn't show a tag for yourself. You need other players on the server.[/QUOTE] Hm. I just tried it with bots on a listen server. Replaced ply:IsAdmin with if ply:IsPlayer. Does anything of that sort work for you. ?
[QUOTE=Sheeplie;47506152]Hm. I just tried it with bots on a listen server. Replaced ply:IsAdmin with if ply:IsPlayer. Does anything of that sort work for you. ?[/QUOTE] Not sure. I'm pretty sure player.GetAll() won't return bots.
So I want to make a function that outputs a color, but the color gradually changes to other colors in the ROYGBIV order (like a rainbow). I'm guessing it's a matter of having a HSL color table, +1 on the Hue and converting to color, but I don't know the maths required.
[QUOTE=James xX;47506368]So I want to make a function that outputs a color, but the color gradually changes to other colors in the ROYGBIV order (like a rainbow). I'm guessing it's a matter of having a HSL color table, +1 on the Hue and converting to color, but I don't know the maths required.[/QUOTE] [url]http://wiki.garrysmod.com/page/Global/ColorToHSV[/url] (Alternatively color:ToHSV()) and [url]http://wiki.garrysmod.com/page/Global/HSVToColor[/url] Adding 1 to the Hue should work fine.
Is there any way I can limit the size of a table. So say I want it to be capped at 100. If I've got 100 entries and another is added it'll remove the earliest added ones to make room.
[QUOTE=Adzter;47506775]Is there any way I can limit the size of a table. So say I want it to be capped at 100. If I've got 100 entries and another is added it'll remove the earliest added ones to make room.[/QUOTE] -snip way better solution below-
[QUOTE=Adzter;47506775]Is there any way I can limit the size of a table. So say I want it to be capped at 100. If I've got 100 entries and another is added it'll remove the earliest added ones to make room.[/QUOTE] Just do something like this, [lua]function insert ( table, value, max ) -- Have max as a argument, or a variable outside of the function. if ( table.Count ( ) == max ) then table.remove ( table, 1 ) table.insert ( table, value ) return end table.insert ( table, value ) end[/lua] [editline]n[/editline] [QUOTE=AnonTakesOver;47506855]just create a function to manage it, assuming your table increases by index, so your keys are just numbers increasing, this'll work [code] local function AddToTable( tbl, val ) if #tbl == 100 then table.remove(tbl, 1) end tbl[#tbl + 1] = val end [/code][/QUOTE] Honestly, that's not really an ideal way of doing it since #table would only return values without a variable, meaning { hello = "2" } would return 0.
Anyone know a way to organise a DPanelList into columns? This looks hella messy right now: [url]http://redostri.ch/share/2015-04-11_23-07-02.png[/url]
Use a non-deprecated Derma element: [url]http://wiki.garrysmod.com/page/Category:DIconLayout[/url]
Clientsided drawings does not load/update in (not huds or derma shit) eg. [url]http://i.imgur.com/K9QNyWI.png[/url], [url]http://i.imgur.com/TzEeDfm.png[/url], [url]http://i.imgur.com/lUXY9DR.png[/url] There is no lua errors at all in the console, i've read the code and even made improvements. It works through GMod client if server started through "Start New Game". Im hosting the server through Linux. They used to work perfectly before until restart. I understand why if nobody can answer this.
[QUOTE=Exho;47506976]Use a non-deprecated Derma element: [url]http://wiki.garrysmod.com/page/Category:DIconLayout[/url][/QUOTE] I ended up using DGrid, but thanks anyway :)
[QUOTE=Author.;47506861] Honestly, that's not really an ideal way of doing it since #table would only return values without a variable, meaning { hello = "2" } would return 0.[/QUOTE] Well your function doesn't allow string indexes anyways, so why is that a problem?
Sorry, you need to Log In to post a reply to this thread.