• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
[QUOTE=Willox;47899695]\..\ :)[/QUOTE] ./ also ./models/./props/hi.mdl [QUOTE=Willox;47899708]is this a rap battle?[/QUOTE] you win :(
[QUOTE=zerf;47899699]/./[/QUOTE] "path/prop.mdl " is this a rap battle? The sad truth is - without interfacing to the fs to get the true path name - you're screwed if you want to check if a path points to an exact file.
Anyone know how I would get started creating a "free sway" code for a SWEP? If you don't know what I mean when I say "free sway", think of the weapons Red Orchestra 2 or Insurgency, that kind of free sway.
[QUOTE=A Fghtr Pilot;47900095]Anyone know how I would get started creating a "free sway" code for a SWEP? If you don't know what I mean when I say "free sway", think of the weapons Red Orchestra 2 or Insurgency, that kind of free sway.[/QUOTE] A deadzone? Make a CalcView hook that only moves if the mouse goes past a certain distance (keep track of [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/InputMouseApply]GM/InputMouseApply[/url]?) [editline]7th June 2015[/editline] That sounds like a cool project, I'll take a stab at it.
Anyone know why this isn't working? [code] local URL = "PERFECTLY VALID URL HERE" function ENT:Use(activator, caller) -- Called when the ent is used. if not ( activator:IsPlayer() ) then return end print("Attempting to play sound") sound.PlayURL ( "URL", "", SoundPlay ) end function SoundPlay( SoundPlay ) print("SoundPlay function called") SoundPlay:SetPos( activator:GetPos() ) SoundPlay:Play() end [/code] I'm trying to make an entity play a sound clip from a url when a player presses E on it. The url is a hosted mp3 file that the playURL function works with, but it doesn't seem to be playing. This is in the cl_init.lua of my entity. Is there something im overlooking? Any help would be much appreciated.
How do would you network a derma entity in the client. I've tried to use SetNetworkedEntity, but that doesn't work?
I was just wondering where the code for the default Hl2 hud is, because I'd like to make a hud based on that and would like access to everything it uses... Thanks :D
[QUOTE=B10H4Z4RD;47902705]I was just wondering where the code for the default Hl2 hud is, because I'd like to make a hud based on that and would like access to everything it uses... Thanks :D[/QUOTE] It's not in lua..
When is it safe to call http.Post? I can't seem to get it to run on dedi server startup, though in singleplayer it seems to run just fine. I've ran it in InitPostEntity, with and without a timer and my http server doesn't seem to acknowledge the GMod server at all. Do I just have to say fuck it and use http.Fetch instead?
[QUOTE=Joeyl10;47902764]When is it safe to call http.Post? I can't seem to get it to run on dedi server startup, though in singleplayer it seems to run just fine. I've ran it in InitPostEntity, with and without a timer and my http server doesn't seem to acknowledge the GMod server at all. Do I just have to say fuck it and use http.Fetch instead?[/QUOTE] I've used it in playerinitspawn fine (or a 0 second timer)
[QUOTE=Stargazer808;47902504]How do would you network a derma entity in the client. I've tried to use SetNetworkedEntity, but that doesn't work?[/QUOTE] What?
How come I never see any custom VGUI elements released? There's themed elements for Bootstrap and .NET applications, why aren't there any for VGUI elements? The only themed elements I've seen were made for that addon specifically.
This is more of a curiosity than a problem. Is there any reason you'd ever return something from a console command function? I found [URL="https://github.com/putta-jon/gstats/blob/master/gStats/lua/autorun/server/sv_cmds.lua"]this [/URL]while randomly searching github. [code] --... concommand.Add("g_rank", function( p, c, a ) return p:Ranks() end) --... [/code] I tried asking about it in the gmod coding chat but they were busy trying to simulate masturbation with hash's lua VM (as usual (I am not joking, I can provide chatlogs)).
[QUOTE=MadParakeet;47903079]I tried asking about it in the gmod coding chat but they were busy trying to simulate masturbation with hash's lua VM (as usual (I am not joking, I can provide chatlogs)).[/QUOTE] trying? succeeding.
I'm trying to follow the stencil code at [url]http://facepunch.com/showthread.php?t=1205832&p=37280318&viewfull=1#post37280318[/url], but I'm having an issue whereby picking the entity up using the physgun causes the screen to flash the current color of the physgun. I know it has something to do with the physgun prop halo effect/ Freeze effect, but I'm unsure if there is a way to fix it.
[QUOTE=Deathbypwnage;47900959]Anyone know why this isn't working? [code] local URL = "PERFECTLY VALID URL HERE" function ENT:Use(activator, caller) -- Called when the ent is used. if not ( activator:IsPlayer() ) then return end print("Attempting to play sound") sound.PlayURL ( "URL", "", SoundPlay ) end function SoundPlay( SoundPlay ) print("SoundPlay function called") SoundPlay:SetPos( activator:GetPos() ) SoundPlay:Play() end [/code] I'm trying to make an entity play a sound clip from a url when a player presses E on it. The url is a hosted mp3 file that the playURL function works with, but it doesn't seem to be playing. This is in the cl_init.lua of my entity. Is there something im overlooking? Any help would be much appreciated.[/QUOTE] [I] sound.PlayURL ( "URL", "", SoundPlay )[/I] sound.PlayURL ([B][I] "URL"[/I][/B], "", SoundPlay ) you need to un-quote it
[QUOTE=zerf;47903173]trying? succeeding.[/QUOTE] I can assure you I have [URL="https://gist.github.com/SwadicalRag/bcfce07851ff80cccfce"]nothing[/URL] to do with this at all.
[QUOTE=man with hat;47903046]How come I never see any custom VGUI elements released? There's themed elements for Bootstrap and .NET applications, why aren't there any for VGUI elements? The only themed elements I've seen were made for that addon specifically.[/QUOTE] What would you need?
Is there a solution for errors getting mangled by "[%d]" in the error message? It doesn't happen in pure Lua... [img]http://puu.sh/ih3wt/7eed671887.png[/img]
[QUOTE=Luni;47905483]Is there a solution for errors getting mangled by "[%d]" in the error message? It doesn't happen in pure Lua... [img]http://puu.sh/ih3wt/7eed671887.png[/img][/QUOTE] A really bad reason. To hack around it just prefix all your error messages with "]". [url]http://facepunch.com/showthread.php?t=1449139&p=47061946&viewfull=1#post47061946[/url]
[QUOTE=polivlas;47903678][I] sound.PlayURL ( "URL", "", SoundPlay )[/I] sound.PlayURL ([B][I] "URL"[/I][/B], "", SoundPlay ) you need to un-quote it[/QUOTE] Hmm, I have uncommented the URL so it looks like this: [code]sound.PlayURL( URL, "", SoundPlay )[/code] But it still doesn't seem to be calling the function SoundPlay, as it isn't printing the messages to the console, and isn't playing anything. Any ideas? Im stumped. [code] local URL = "LINK TO HOSTED MP3 FILE" function ENT:Use(activator, caller) -- Called when the ent is used. if not ( activator:IsPlayer() ) then return end -- Making sure that wire users cannot trigger the secret. print("Attempting to play sound") sound.PlayURL( URL, "", SoundPlay ) end function SoundPlay( SoundPlay ) print("SoundPlay function called") SoundPlay:SetPos( activator:GetPos() ) SoundPlay:Play() end [/code]
This is copy+pasta'd from a thread I made but I figured someone here might know: Hello, I'm having an issue with an animation for a weapon ported from csgo. The animation (to inspect the weapon) has around a 6 second delay so I've tried to solve that using this: [code] function SWEP:Think() --Key is just temp for testing ofc if self.Owner:KeyPressed(IN_JUMP) then self.Weapon:SendWeaponAnim( ACT_VM_IDLE ) --play anim self.Owner:GetViewModel():SetPlaybackRate( 7 ) --set the speed high timer.Simple( 0.4, function() self.Owner:GetViewModel():SetPlaybackRate( 2 ) end ) --set speed back after 2.4 seconds to slow back down skipping the 6 seconds end end [/code] Hopefully someone will understand what I'm trying to accomplish :P
Is there a function similar to player.GetAll except it only grabs players of a certain team?
[QUOTE=Shadico;47910734]Is there a function similar to player.GetAll except it only grabs players of a certain team?[/QUOTE] team.GetPlayers()
[QUOTE=PigeonPatrol;47910761]team.GetPlayers()[/QUOTE] With this in mind, any way to incorporate that into this piece so it only applies to a certain team? In this case FACTION_CP, if that's relevant. [code]function PLUGIN:HUDPaint() client = LocalPlayer() if (client:IsAdmin() and client:GetMoveType() == MOVETYPE_NOCLIP and !client:InVehicle() and NUT_CVAR_ADMINESP:GetBool()) then sx, sy = surface.ScreenWidth(), surface.ScreenHeight() for k, v in ipairs(player.GetAll()) do if (v == client) then continue end scrPos = v:GetPos():ToScreen() marginx, marginy = sy*.1, sy*.1 x, y = math.Clamp(scrPos.x, marginx, sx - marginx), math.Clamp(scrPos.y, marginy, sy - marginy) teamColor = team.GetColor(v:Team()) distance = client:GetPos():Distance(v:GetPos()) factor = 1 - math.Clamp(distance/dimDistance, 0, 1) size = math.max(10, 32*factor) alpha = math.Clamp(255*factor, 80, 255) surface.SetDrawColor(teamColor.r, teamColor.g, teamColor.b, alpha) surface.DrawLine(sx * 0.5, sy * 0.5, x, y) surface.DrawTexturedRect(x - size/2, y - size/2, size, size) nut.util.drawText(v:Name(), x, y - size, ColorAlpha(teamColor, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, nil, alpha) end end end [/code]
So, could anyone help me getting this RT to work? It refuses to draw anything, either giving a error texture or a black screen. [code]SWEP.RTMaterialPath = "models/weapons/kf2/shared/optic" local function KF2RenderScreen() if !IsValid(LocalPlayer()) or !IsValid(LocalPlayer():GetActiveWeapon()) then return end local self = LocalPlayer():GetActiveWeapon() local w,h = ScrW(), ScrH() if !self.RTMaterialPath then return end if not self.RTMat then self.RTMat = Material( self.RTMaterialPath ) end if !self.HudCol then self.HudCol = Color(0,0,0,0) end local RTTexture = GetRenderTarget( "tfa_kf2_rt", 512, 512,true) if self.RTMat and !string.find(tostring(self.RTMat),"error") then self.RTMat:SetTexture( "$basetexture", RTTexture ) local OldRT = render.GetRenderTarget() render.SetRenderTarget( RTTexture ) render.SetViewPort( 0, 0, 512, 512 ) render.Clear( 255, 0, 0, 255, true, true) render.UpdateScreenEffectTexture() cam.Start2D() local c = self.Owner:GetWeaponColor() self.HudCol.r = c.r self.HudCol.g = c.g self.HudCol.b = c.b draw.NoTexture() surface.SetDrawColor(self.HudCol) surface.DrawRect(25,25,100,100) cam.End2D() render.SetRenderTarget( OldRT ) render.SetViewPort( 0, 0, w, h ) --render.DrawTextureToScreen(RTTexture) end end hook.Add("PreDrawOpaqueRenderables","KF2SCREENS",KF2RenderScreen)[/code] Really? No help? I tried lots of stuff but nothing worked.
[QUOTE=Shadico;47910834]With this in mind, any way to incorporate that into this piece so it only applies to a certain team? In this case FACTION_CP, if that's relevant. [code]function PLUGIN:HUDPaint() client = LocalPlayer() if (client:IsAdmin() and client:GetMoveType() == MOVETYPE_NOCLIP and !client:InVehicle() and NUT_CVAR_ADMINESP:GetBool()) then sx, sy = surface.ScreenWidth(), surface.ScreenHeight() for k, v in ipairs(player.GetAll()) do if (v == client) then continue end scrPos = v:GetPos():ToScreen() marginx, marginy = sy*.1, sy*.1 x, y = math.Clamp(scrPos.x, marginx, sx - marginx), math.Clamp(scrPos.y, marginy, sy - marginy) teamColor = team.GetColor(v:Team()) distance = client:GetPos():Distance(v:GetPos()) factor = 1 - math.Clamp(distance/dimDistance, 0, 1) size = math.max(10, 32*factor) alpha = math.Clamp(255*factor, 80, 255) surface.SetDrawColor(teamColor.r, teamColor.g, teamColor.b, alpha) surface.DrawLine(sx * 0.5, sy * 0.5, x, y) surface.DrawTexturedRect(x - size/2, y - size/2, size, size) nut.util.drawText(v:Name(), x, y - size, ColorAlpha(teamColor, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, nil, alpha) end end end [/code][/QUOTE] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/team/GetPlayers]team.GetPlayers[/url] accepts one argument: the team index. Just put FACTION_CP in as the argument and it will get all of the players from the team.
I have a table of weapons, in this format: [code] AddItemToTable("weapon_hp_crowbar", { name = "Crowbar", desc = "A firm and sturdy crowbar that should be used for mechanical work.", model = "models/weapons/crowbar.mdl", start = 500, category = CATE_WEAPONS }) [/code] I want to insert the key and start value into a new table (when the weapon is used, which I have on a PlayerDeath hook). I know I can just do the start value with table.Insert, and it looks like this: [code] 1 = 500 2 = 650 etc [/code] However, what would be the correct syntax so it's like below instead? My intention is that items only get inserted into a table once, but the value associated with them will change. [code] weapon_hp_crowbar = 500 weapon_hp_sawblade = 650 [/code] (basically I've gone back to working on my The Ship gamemode - each weapon has a starting value which you get in cash when you kill with it, the more time it's used, the lesser that value is and if I'm over complicating this, please let me know)
[QUOTE=NiandraLades;47914854]-snip-[/QUOTE] Can't tell how to access the first argument passed into AddItemToTable, but: [lua] sometbl[someStringKey] = someStringValue; [/lua] Will add/update someStringKey
[QUOTE=NiandraLades;47914854]I have a table of weapons, in this format: [code] AddItemToTable("weapon_hp_crowbar", { name = "Crowbar", desc = "A firm and sturdy crowbar that should be used for mechanical work.", model = "models/weapons/crowbar.mdl", start = 500, category = CATE_WEAPONS }) [/code] I want to insert the key and start value into a new table (when the weapon is used, which I have on a PlayerDeath hook). I know I can just do the start value with table.Insert, and it looks like this: [code] 1 = 500 2 = 650 etc [/code] However, what would be the correct syntax so it's like below instead? My intention is that items only get inserted into a table once, but the value associated with them will change. [code] weapon_hp_crowbar = 500 weapon_hp_sawblade = 650 [/code] (basically I've gone back to working on my The Ship gamemode - each weapon has a starting value which you get in cash when you kill with it, the more time it's used, the lesser that value is and if I'm over complicating this, please let me know)[/QUOTE] local t = {} function AddItemToTable( a, b ) t[a] = b.start end ??
Sorry, you need to Log In to post a reply to this thread.