• Problems That Don't Need Their Own Thread v2.0
    5,020 replies, posted
[QUOTE=Invule;46452035]Ok, thanks for helping me Sm63, StartPos is the start, what should be for the end? EndPos was not listed in the trace result link you gave me, so HitPos would work? or [lua] local tracedata = { StartPos = v:GetShootPos(), HitPos = v:GetShootPos() + v:GetAimVector() * 150 } local td = util.TraceLine( tracedata ) cam.Start3D( EyePos(), EyeAngles() ) render.SetMaterial( tracer ) render.DrawBeam( td.StartPos, td.HitPos, 3, 0, 0, Color( 50, 255, 50, 255 ) ) cam.End3D() [/lua] Still getting the error 'DrawBeam' (Vector expected, got nil)[/QUOTE] The reason is because StartPos isnt a value you can give to TraceLine, same with HitPos. The Table TraceLine returns though has support for StartPos and HitPos. [url="http://wiki.garrysmod.com/page/util/TraceLine"]here[/url]
[QUOTE=Sm63;46452126]The reason is because StartPos isnt a value you can give to TraceLine, same with HitPos. The Table TraceLine returns though has support for StartPos and HitPos. [url="http://wiki.garrysmod.com/page/util/TraceLine"]here[/url][/QUOTE] Ok, so its finally working but now theres a 2 inch line in his head. [t]http://puu.sh/cKDyq/000e85e76e.jpg[/t] Is that because of my StartPos, and HitPos? If so, what would you recommend using
[QUOTE=Invule;46452205]Ok, so its finally working but now theres a 2 inch line in his head. [t]http://puu.sh/cKDyq/000e85e76e.jpg[/t] Is that because of my StartPos, and HitPos? If so, what would you recommend using[/QUOTE] add the player to the trace filter
Finally got it working, thank you all for your help, much appreciated :)
Hey guys i'm having an issue where I am trying to send a font file and the clients do not download it. i am using the code [code] resource.AddFile("resource/fonts/ralewaylite.ttf") [/code] I have a fastDL setup, it is on there. I have the file on both server and fastDL. I have tried without and with fastDL, without and with sv_allowdownload None work. Every time you are able to see the file 'downloading' but it never actually downloads into my client folder. Im really clueless here, and ideas?
[QUOTE=Blackfire76;46452375]Hey guys i'm having an issue where I am trying to send a font file and the clients do not download it. i am using the code [code] resource.AddFile("resource/fonts/ralewaylite.ttf") [/code] I have a fastDL setup, it is on there. I have the file on both server and fastDL. I have tried without and with fastDL, without and with sv_allowdownload None work. Every time you are able to see the file 'downloading' but it never actually downloads into my client folder. Im really clueless here, and ideas?[/QUOTE] usually means that its not detecting the file in the web server. There should be some HTTP errors while joining (in console. Just open console after youve finished loading). post them
[code]Connecting to 119.252.189.12:27040... Connected to 119.252.189.12:27040 PPS Map: gm_flatgrass Players: 1 / 8 Build: 5692 Server Number: 1 Development ppsrp gm_flatgrass 8 76561198036509585 Attemped to precache unknown particle system "generic_smoke"! ConVarRef gmod_physiterations doesn't point to an existing ConVar PREP OK Warning: WorldTwoTextureBlend found on a non-displacement surface (material: gm_construct/flatgrass). This wastes perf for no benefit. clientside lua startup! Requesting texture value from var "$dummyvar" which is not a texture value (material: NULL material) kk Failed to load custom font file 'c:/program files (x86)/steam/steamapps/blackfire7667/garrysmod/garrysmod/resource/fonts/graffiare.ttf' Failed to load custom font file 'c:/program files (x86)/steam/steamapps/blackfire7667/garrysmod/garrysmod/resource/fonts/mortbats.ttf' Failed to load custom font file 'c:/program files (x86)/steam/steamapps/blackfire7667/garrysmod/garrysmod/resource/fonts/typenoksidi.ttf' Compact freed 610304 bytes Redownloading all lightmaps [/code]
[QUOTE=BlaBlaAccount;46451977]Thanks, but this isn't exactly how I wanted it to work. I've revised my script using a for loop in my last post. Maybe it will be more clear. Here it is [code] function GM:PlayerSetModel(ply) ModelMaps = {} ModelMaps["gm_construct"] = "models/player/phoenix.mdl" for k, v in pairs(ModelMaps) do if k == string.lower(game.GetMap()) then local mdl = (v) else local mdl = "models/player/phoenix.mdl" end end util.PrecacheModel(mdl) ply:SetModel(mdl) -- Always clear color state, may later be changed in TTTPlayerSetColor ply:SetColor(COLOR_WHITE) end [/code] What am I doing wrong?[/QUOTE] Read previous posts ( Exactly as Sm63 put it ); also check into "scope". A variable only exists within the "Scope" of where it was created. If you create a local variable inside an if / for / while / etc... then that variable isn't known outside of it. You're setting local mdl inside a for loop inside an if statement and else. They only exist in the if / else, and you wouldn't even be able to see it in the for loop after the end. You need to define local mdl = nil; outside of your loop and change the local mdl = to mdl =... Next, you can simplify how you target your maps by using direct access.. Putting both of them together, into a ternary operation, you'd replace [code] for k, v in pairs(ModelMaps) do if k == string.lower(game.GetMap()) then local mdl = (v) else local mdl = "models/player/phoenix.mdl" end end[/code] with [code]local _map = ModelMaps[ string.lower( game.GetMap( ) ) ]; local _mdl = ( _map ) && _map || "models/player/phoenix.mdl";[/code] Lua is built around tables, direct access is very optimized. You'd also reset your var if you continue the loop because you don't use "break;" to exit the loop once you find the right map. You could put the solution above on 1 line but it'd require you to repeat the contents of _map twice. [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/logic/ternary_operations.lua.html[/url] [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/tables/quick_intro_to_tables.lua.html[/url] [editline]10th November 2014[/editline] [QUOTE=Blackfire76;46452375]Hey guys i'm having an issue where I am trying to send a font file and the clients do not download it. i am using the code [code] resource.AddFile("resource/fonts/ralewaylite.ttf") [/code] I have a fastDL setup, it is on there. I have the file on both server and fastDL. I have tried without and with fastDL, without and with sv_allowdownload None work. Every time you are able to see the file 'downloading' but it never actually downloads into my client folder. Im really clueless here, and ideas?[/QUOTE] Make sure FastDL is setup correctly. [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/server_srcds_steamcmd/fastdl_setup_instructions.lua.html[/url] Maybe switch to a recursive loader for your files / addons ( you may want to remove the addons/ folder gma loader if you have maps; next version released with fileio will automatically handle them ) [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/server_srcds_steamcmd/setting_up_downloads_using_recursive_resource_system.lua.html[/url] Make sure when you CreateFont you use the name given inside Font Viewer rather than the filename.
[QUOTE=Blackfire76;46452414][code]Connecting to 119.252.189.12:27040... Connected to 119.252.189.12:27040 PPS Map: gm_flatgrass Players: 1 / 8 Build: 5692 Server Number: 1 Development ppsrp gm_flatgrass 8 76561198036509585 Attemped to precache unknown particle system "generic_smoke"! ConVarRef gmod_physiterations doesn't point to an existing ConVar PREP OK Warning: WorldTwoTextureBlend found on a non-displacement surface (material: gm_construct/flatgrass). This wastes perf for no benefit. clientside lua startup! Requesting texture value from var "$dummyvar" which is not a texture value (material: NULL material) kk Failed to load custom font file 'c:/program files (x86)/steam/steamapps/blackfire7667/garrysmod/garrysmod/resource/fonts/graffiare.ttf' Failed to load custom font file 'c:/program files (x86)/steam/steamapps/blackfire7667/garrysmod/garrysmod/resource/fonts/mortbats.ttf' Failed to load custom font file 'c:/program files (x86)/steam/steamapps/blackfire7667/garrysmod/garrysmod/resource/fonts/typenoksidi.ttf' Compact freed 610304 bytes Redownloading all lightmaps [/code][/QUOTE] are you sure there isnt a bigger log? Tends to be a lot bigger
[QUOTE=MeepDarknessM;46451580]this won't work since the hook isn't called with the entity as the first variable (or any variable for that matter)[/QUOTE] That's not true - from hook.Call: [code]if ( isstring( k ) ) then -- -- If it's a string, it's cool -- a, b, c, d, e, f = v( ... ) else -- -- If the key isn't a string - we assume it to be an entity -- Or panel, or something else that IsValid works on. -- if ( IsValid( k ) ) then -- -- If the object is valid - pass it as the first argument (self) -- a, b, c, d, e, f = v( k, ... ) else -- -- If the object has become invalid - remove it -- HookTable[ k ] = nil end end[/code] Anything that isn't a string can be passed as the key and it will automatically provide it as the first argument.
[QUOTE=GreenGold;46451076]If i open url in dhtml or html and that url has video auto playing how can i disable audio in panel or mute video sound?[/QUOTE] Anyone?
[QUOTE=Kogitsune;46454166]That's not true - from hook.Call: [code]if ( isstring( k ) ) then -- -- If it's a string, it's cool -- a, b, c, d, e, f = v( ... ) else -- -- If the key isn't a string - we assume it to be an entity -- Or panel, or something else that IsValid works on. -- if ( IsValid( k ) ) then -- -- If the object is valid - pass it as the first argument (self) -- a, b, c, d, e, f = v( k, ... ) else -- -- If the object has become invalid - remove it -- HookTable[ k ] = nil end end[/code] Anything that isn't a string can be passed as the key and it will automatically provide it as the first argument.[/QUOTE] you learn something new everyday!
feels like a stupid question but is it possible to draw the player avatar via draw library?
[QUOTE=_Entity;46455771]feels like a stupid question but is it possible to draw the player avatar via draw library?[/QUOTE] [url=http://wiki.garrysmod.com/page/Category:AvatarImage]AvatarImage[/url] and PANEL:SetPlayer( LocalPlayer() )
-snip fixed it.
[quote][url]http://cloud-4.steampowered.com/ugc/44235861000269675/140D497503477CA8E8439E63E8DA697A7DCEFB3F/[/url][/quote] Hi there, I decided to use HTML in order to make an easy and quick chatbox now the problem I'm having is really inexperience as I've never used java before. HTML is fairly simple however I'm having trouble with java. Code here: [lua]function PANEL:AppendText(info) local lines = [[]]; META:GetPlugin("chatbox").Chatbox.History[#META:GetPlugin("chatbox").Chatbox.History+1] = "["..info.typ.."]".." "..info.name..": ".."<font face = 'Old Press' color = '#0099FF' size = '24'>"..info.text.."</font>"; for i = 1, (#META:GetPlugin("chatbox").Chatbox.History) do lines = lines.."<p style = color:#FFFFFF>"..META:GetPlugin("chatbox").Chatbox.History[i].."</p>"; end self.HTML:SetHTML([[ <!DOCTYPE html> <html> <body> ]].. lines ..[[ </body> </html> ]]); end[/lua] How can I perform this more efficiently and how can I also make the scrollbar snap to the bottom of the page once it's activated?
[QUOTE=Sm63;46452769]are you sure there isnt a bigger log? Tends to be a lot bigger[/QUOTE] i figured it out and fixed it, its all good now thanks guys now i have another issue. -snip nvm fixed it myself-
So for some reason my looping wav files doesn't loop? Here's the code, wav file with looping enabled (using the method described on the Valve Wiki). You can even see in the top right of the video that it's got the sound listed as looping but for some reason just cuts out. [code] local drillSounds = CreateSound( self, "npigamers/drill.wav" ) drillSounds:Play() [/code] [img]http://i.imgur.com/tXgqHw4.png[/img] [video=youtube;C6Mt6done5I]http://www.youtube.com/watch?v=C6Mt6done5I[/video] Anyone have any idea at all?
When I do looping sounds, I manually Stop / Play under certain circumstances ( such as entity about to leave PVS, stop sound... entity entering PVS, start sound ). You may have another issue, but without seeing the wav file, and the code where you create the sound ( exactly where and how it is done instead of just 2 lines ) then we may not be able to help unless someone sees something I'm not seeing.
[QUOTE=Adzter;46463032]So for some reason my looping wav files doesn't loop? Here's the code, wav file with looping enabled (using the method described on the Valve Wiki). You can even see in the top right of the video that it's got the sound listed as looping but for some reason just cuts out. [code] local drillSounds = CreateSound( self, "npigamers/drill.wav" ) drillSounds:Play() [/code] [IMG]http://i.imgur.com/tXgqHw4.png[/IMG] [video=youtube;C6Mt6done5I]http://www.youtube.com/watch?v=C6Mt6done5I[/video] Anyone have any idea at all?[/QUOTE] Select the area that must loop in Wavosaur and press L. That's it. Oh and save the file. And don't listen to Acecool up there. [editline]11th November 2014[/editline] Here's example of a looping sound: [t]http://i.imgur.com/PrzrFGK.png[/t]
I'm trying to make a levelling HUD similar to this [img]http://oi42.tinypic.com/2ytwuqh.jpg[/img] Mine looks like this at the moment (yes, it's nowhere near finished) [img]http://puu.sh/cMJcI/e17583531e.jpg[/img] But I'm not quite sure how to add the cuts in the rectangle without using materials. Is someone able to give me a hand on how to do this? Thanks.
[I][~Deleted~][/I]
[QUOTE=mib999;46464759]I'm trying to make a levelling HUD similar to this But I'm not quite sure how to add the cuts in the rectangle without using materials. Is someone able to give me a hand on how to do this? Thanks.[/QUOTE] [lua] local function drawrestxp(pos, xp) draw.RoundedBox(0, x + pos + spacing left, y, totallength/10 - spacing left - spacing right, totallength/10 - spacing left - spacing right, 20, SH.ColorLib["Black"]) draw.RoundedBox(0, x + pos + spacing left, y, xp, totallength/10 - spacing left - spacing right, 20, SH.ColorLib["blue"]) end singlelenght = (totallength / 10) spaced = singlelength - spacing left - spacing right for i=1, 10 do startpos[i] = (i - 1) * singlelenght or 0 [/lua] something something simmilar. but i got stuck too currently
Never messed with weapons before but I'm looking to create a pointshop item which would modify that player's bullets to explode on impact, but unsure where to start. I've looked around and I'm unable to find anything that helps. Any ideas?
[QUOTE=serfma;46465529]Never messed with weapons before but I'm looking to create a pointshop item which would modify that player's bullets to explode on impact, but unsure where to start. I've looked around and I'm unable to find anything that helps. Any ideas?[/QUOTE] Whenever the player equips a new weapon, override that weapon's PrimaryAttack function. Probably a shitty way to do it, but that's how I'd do it.
In the next update ( I think ) you can use this hook: [url]http://wiki.garrysmod.com/page/GM/EntityFireBullets[/url] [editline]12th November 2014[/editline] [QUOTE=serfma;46465529]Never messed with weapons before but I'm looking to create a pointshop item which would modify that player's bullets to explode on impact, but unsure where to start. I've looked around and I'm unable to find anything that helps. Any ideas?[/QUOTE]
Well ok. I tried using :SetRunSpeed(), :SetWalkSpeed(), and so on, to slow down the player while they ADS, and restore their speed when they stop. Well, this caused a nice glitch where occasionally the player would run around REALLY fast for a split second. Is there a better way to slow down / restore the player's movement speed?
[QUOTE=WalkingZombie;46466490]Well ok. I tried using :SetRunSpeed(), :SetWalkSpeed(), and so on, to slow down the player while they ADS, and restore their speed when they stop. Well, this caused a nice glitch where occasionally the player would run around REALLY fast for a split second. Is there a better way to slow down / restore the player's movement speed?[/QUOTE] Those commands won't cause them to run really fast unless you give it high numbers. One can only assume it's a bug in your code.
[QUOTE=mib999;46464759]I'm trying to make a levelling HUD similar to this [IMG]http://oi42.tinypic.com/2ytwuqh.jpg[/IMG] Mine looks like this at the moment (yes, it's nowhere near finished)[/quote] [code]function DrawChunkyBar( x, y, w, h, bcolor, fcolor, percent, chunks, padding ) local s, t, u, v, k u = x v = y s = ( w - padding * ( chunks - 1 ) ) / chunks k = 0 for k = 0, 1, 1 / chunks do surface.SetDrawColor( bcolor ) surface.DrawRect( u, v, s, h ) surface.SetDrawColor( fcolor ) if k < percent and k + 1 / chunks <= percent then surface.DrawRect( u, v, s, h ) elseif k < percent and k + 1 / chunks > percent surface.DrawRect( u, v, s * ( ( percent - k ) / ( 1 / chunks ) ), h - 2 ) end u = u + s + padding end end[/code] Completely untested. A material would be a simpler solution because then you could just either draw a four-point poly / or use [URL="http://wiki.garrysmod.com/page/surface/DrawTexturedRectUV"]surface.DrawTexturedRectUV[/URL]. I prefer surface.DrawPoly because I feel it is more powerful and the u, v parameters make more sense in their ordering. [code]local m = Material( "your/chunky/texture.png", "smooth noclamp" ) local poly = { { x = 0, y = 0, u = 0, v = 0 }, { x = 0, y = 0, u = 1, v = 0 }, { x = 0, y = 0, u = 1, v = 1 }, { x = 0, y = 0, u = 0, v = 1 }, } function DrawChunkyBar( x, y, w, h, bcolor, fcolor, percent, chunks ) surface.SetMaterial( m ) surface.SetDrawColor( bcolor ) poly[ 1 ].x = x poly[ 1 ].y = y poly[ 2 ].x = x + w poly[ 2 ].y = y poly[ 2 ].u = chunks poly[ 3 ].x = x + w poly[ 3 ].y = y + h poly[ 3 ].u = chunks poly[ 4 ].x = x poly[ 4 ].y = y + h surface.DrawPoly( poly ) surface.SetDrawColor( fcolor ) poly[ 2 ].u = chunks * percent poly[ 3 ].u = chunks * percent surface.DrawPoly( poly ) end[/code] In both samples, chunks would be a whole number ( 10 in the example picture ), and percent would be a float between 0 and 1 that would represent xp / needed xp.
[QUOTE=Kogitsune;46466528]-snip-[/QUOTE] Thanks a bunch, I got another question tho. I have 10 chunks but it has 11 (as seen here) [img]http://puu.sh/cN3Xy/731df9f8e8.jpg[/img] Code is as followed: [lua]DrawChunkyBar(ScrW() / 3, 45, ScrW() / 3, 10, Color(20,20,20,255), Color(55,95,165,210), 0.5, 10, 10)[/lua]
Sorry, you need to Log In to post a reply to this thread.