• Problems That Don't Need Their Own Thread v3.0
    5,003 replies, posted
[QUOTE=MPan1;49817635]You could always just move them when they spawn, e.g. [CODE] hook.Add( 'PlayerSpawn', 'moveplayer', function( ply ) ply:SetPos( Vector( 0, 0, 0 ) ) end ) [/CODE] I think there was another way to do this though[/QUOTE] Never thought about this, I will try this out, thank you! Is there already any function to check whether a position is good to spawn (e.g. no blocking models etc)?
It keeps spamming server console. What does it mean? [QUOTE]KeyValues Error: RecursiveLoadFromBuffer: got } in key in file In AddonInfo, ,, (*:*), KeyValues Error: LoadFromBuffer: missing { in file In (*AddonInfo*), (*,*), (*:*), KeyValues Error: LoadFromBuffer: missing { in file In (*AddonInfo*), (*,*), (*:*), KeyValues Error: LoadFromBuffer: missing { in file In (*AddonInfo*), (*,*), (*:*), KeyValues Error: LoadFromBuffer: missing { in file In (*AddonInfo*), (*,*), (*:*), KeyValues Error: LoadFromBuffer: missing { in file In (*AddonInfo*), (*,*), (*:*), KeyValues Error: LoadFromBuffer: missing { in file In (*AddonInfo*), (*,*), (*:*),[/QUOTE]
[QUOTE=P4sca1;49817677]Never thought about this, I will try this out, thank you! Is there already any function to check whether a position is good to spawn (e.g. no blocking models etc)?[/QUOTE] Wait, so why do you want to stop the player from spawning where they were going to? Are there certain bad spawn points on the map or something that you don't want them to spawn at? Or, are all the existing spawn points bad and you want them to spawn somewhere good?
[QUOTE=P4sca1;49817677]Never thought about this, I will try this out, thank you! Is there already any function to check whether a position is good to spawn (e.g. no blocking models etc)?[/QUOTE] Perform a hull trace and check if it hits anything. [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/util/TraceHull]util.TraceHull[/url] [lua] function ValidSpawn( spawnPoint ) local tracedata = {} tracedata.start = spawnPoint -- the position of your custom spawn point tracedata.endpos = spawnPoint tracedata.mins = Vector( -16, -16, 0 ) -- default player hulls you might want to use OBSMin/Max instead if you have different sized player models tracedata.maxs = Vector( 16, 16, 64 ) local trace = util.TraceHull( tracedata ) if trace.Hit then return false end return true end [/lua]
[QUOTE=MPan1;49817698]Wait, so why do you want to stop the player from spawning where they were going to? Are there certain bad spawn points on the map or something that you don't want them to spawn at? Or, are all the existing spawn points bad and you want them to spawn somewhere good?[/QUOTE] No, I want to check whether another entity is blocking the spawn point currently and if it is, then I want to try spawning the player at a near position. EDIT: Thank you for the hints Lolle!
So uhh, I can't tell if I made my [url=https://facepunch.com/showthread.php?t=1507929]thread's[/url] title too stupid or misleading, or just that no one really know how to answer me.. But I'll post here anyway. I am trying to blend several renders together, with each render having an entity in a different position. Here is my code: [lua]if SERVER then print("SoftPoster must be run clientside!") return end // this is a goddamn client script! // Frame blending code copied from: motion_blur.lua local mat_MotionBlur = Material( "pp/motionblur" ) local mat_Screen = Material( "pp/fb" ) local tex_MotionBlur = render.GetMoBlurTex0() local function RenderWithAlpha(addalpha) render.UpdateScreenEffectTexture() mat_Screen:SetFloat( "$alpha", addalpha ) local oldRT = render.GetRenderTarget() render.SetRenderTarget(tex_MotionBlur) render.SetMaterial(mat_Screen) render.DrawScreenQuad() --render.Clear(255, 0, 0, 255, true, true) render.SetRenderTarget(oldRT) end function SoftPoster(radius, resmul, split) local callsleft = resmul * resmul + 1 -- + 800 -- number of calls of the render hook that need to be hooked, 1 extra called pre-poster local ent = LocalPlayer():GetEyeTrace().Entity local up = ent:GetAngles():Up() local right = ent:GetAngles():Right() local origin = ent:GetPos() print("Starting poster") --hook.Add("RenderScene", "SoftPoster", function() hook.Add("RenderScreenspaceEffects", "SoftPoster", function() mat_MotionBlur:SetFloat("$alpha", 1) mat_MotionBlur:SetTexture( "$basetexture", tex_MotionBlur ) -- Center: ent:SetPos(origin) RenderWithAlpha(1) -- Up Right: ent:SetPos(origin + (up * radius) + (right * radius)) RenderWithAlpha(1/2) -- Down Right: ent:SetPos(origin - (up * radius) + (right * radius)) RenderWithAlpha(1/3) -- Up Left: ent:SetPos(origin + (up * radius) - (right * radius)) RenderWithAlpha(1/4) -- Down Left: ent:SetPos(origin - (up * radius) - (right * radius)) RenderWithAlpha(1/5) -- return to normal: ent:SetPos(origin) -- This part WORKS, it writes whatever was rendered in RenderWithAlpha to screen: render.SetMaterial( mat_MotionBlur ) render.DrawScreenQuad() callsleft = callsleft - 1 if (callsleft == 0) then hook.Remove("RenderScreenspaceEffects","SoftPoster") print("Removing hook") end --return true end) RunConsoleCommand("poster", resmul, split) end[/lua] Doesn't work. If I uncomment the render.Clear line, I get a completely red screen + HUD (proving that SOMETHING is happening), but otherwise this really doesn't accomplish anything at all. I am very new to the render library so there's probably some key thing I'm missing.
I have a question. I noticed that players don't have their own [URL="http://wiki.garrysmod.com/page/ENTITY/UpdateTransmitState"]ENT:UpdateTransmitState()[/URL] hook, meaning we can't control if a player's state (position, angle, etc...) is transmitted to other players. Right now it defaults to TRANSMIT_PVS (Potential Visible Set) to prevent people from using wallhacks, but I'd like to be able to have players on the same team to have a halo around them and actually show where they are, even when they're outside of the local player's PVS. Any ideas?
[QUOTE=raubana;49819002]I have a question. I noticed that players don't have their own UpdateTransmitState hook, meaning we can't control if a player's state (position, angle, etc...) is transmitted to other players. Right now it defaults to TRANSMIT_PVS (Potential Visible Set) to prevent people from using wallhacks, but I'd like to be able to have players on the same team to have a halo around them and actually show where they are, even when they're outside of the local player's PVS. Any ideas?[/QUOTE] As a workaround you could [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/AddOriginToPVS]Global.AddOriginToPVS[/url] the teammates position
[QUOTE=MDave;49819021]As a workaround you could [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/AddOriginToPVS]Global.AddOriginToPVS[/url] the teammates position[/QUOTE] :v: That's surprisingly easy. Well... I feel silly now. Thank you.
[QUOTE=bobbleheadbob;49785808]Try Material("matpath", "alphatest")[/QUOTE] No beans: [thumb]http://i.imgur.com/I5QxBvL.jpg[/thumb]
[QUOTE=Neat-Nit;49818421]So uhh, I can't tell if I made my [url=https://facepunch.com/showthread.php?t=1507929]thread's[/url] title too stupid or misleading, or just that no one really know how to answer me.. But I'll post here anyway. I am trying to blend several renders together, with each render having an entity in a different position. Here is my code: [lua]if SERVER then print("SoftPoster must be run clientside!") return end // this is a goddamn client script! // Frame blending code copied from: motion_blur.lua local mat_MotionBlur = Material( "pp/motionblur" ) local mat_Screen = Material( "pp/fb" ) local tex_MotionBlur = render.GetMoBlurTex0() local function RenderWithAlpha(addalpha) render.UpdateScreenEffectTexture() mat_Screen:SetFloat( "$alpha", addalpha ) local oldRT = render.GetRenderTarget() render.SetRenderTarget(tex_MotionBlur) render.SetMaterial(mat_Screen) render.DrawScreenQuad() --render.Clear(255, 0, 0, 255, true, true) render.SetRenderTarget(oldRT) end function SoftPoster(radius, resmul, split) local callsleft = resmul * resmul + 1 -- + 800 -- number of calls of the render hook that need to be hooked, 1 extra called pre-poster local ent = LocalPlayer():GetEyeTrace().Entity local up = ent:GetAngles():Up() local right = ent:GetAngles():Right() local origin = ent:GetPos() print("Starting poster") --hook.Add("RenderScene", "SoftPoster", function() hook.Add("RenderScreenspaceEffects", "SoftPoster", function() mat_MotionBlur:SetFloat("$alpha", 1) mat_MotionBlur:SetTexture( "$basetexture", tex_MotionBlur ) -- Center: ent:SetPos(origin) RenderWithAlpha(1) -- Up Right: ent:SetPos(origin + (up * radius) + (right * radius)) RenderWithAlpha(1/2) -- Down Right: ent:SetPos(origin - (up * radius) + (right * radius)) RenderWithAlpha(1/3) -- Up Left: ent:SetPos(origin + (up * radius) - (right * radius)) RenderWithAlpha(1/4) -- Down Left: ent:SetPos(origin - (up * radius) - (right * radius)) RenderWithAlpha(1/5) -- return to normal: ent:SetPos(origin) -- This part WORKS, it writes whatever was rendered in RenderWithAlpha to screen: render.SetMaterial( mat_MotionBlur ) render.DrawScreenQuad() callsleft = callsleft - 1 if (callsleft == 0) then hook.Remove("RenderScreenspaceEffects","SoftPoster") print("Removing hook") end --return true end) RunConsoleCommand("poster", resmul, split) end[/lua] Doesn't work. If I uncomment the render.Clear line, I get a completely red screen + HUD (proving that SOMETHING is happening), but otherwise this really doesn't accomplish anything at all. I am very new to the render library so there's probably some key thing I'm missing.[/QUOTE] run Entity:SetupBones() after every SetPos call. you also need to draw the entity using Entity:DrawModel() otherwie the entity will never actually be drawn.
[QUOTE=Lexic;49819360]No beans: [thumb]http://i.imgur.com/I5QxBvL.jpg[/thumb][/QUOTE] Take a look at this page. https://developer.valvesoftware.com/wiki/$translucent
[QUOTE=bobbleheadbob;49820363]Take a look at this page. https://developer.valvesoftware.com/wiki/$translucent[/QUOTE] They're not my textures, they're just stuff from HL2's effects folder. I managed to come up with a fantastic hack that works with as far as I can tell no ill effects: [lua] local matCache = {}; function getSaneMaterial(str) local mat; mat = matCache[str] if mat then return mat; end mat = Material(str); matCache[str] = mat; if mat:IsError() then return mat; end -- Fun with rendermodes ¬_¬ if mat:GetInt("$spriterendermode") == 0 then mat:SetInt("$spriterendermode", 5); end mat:Recompute(); return mat end [/lua] The manual caching is because it only works after the client is fully initified so you can't do it in the entity registering phase.
[QUOTE=skullorz;49820145]run Entity:SetupBones() after every SetPos call. you also need to draw the entity using Entity:DrawModel() otherwie the entity will never actually be drawn.[/QUOTE] Thanks for replying. After adding this, not succeeding, and trying more things that make sense in my head, I have reached this code which seems to just [b]crash gmod without as much as an error[/b] (code at the bottom of the post). Clearly I am toying with forces [url=https://xkcd.com/419/]far greater than I suspected.[/url] Please note I changed the entity being moved to be the LocalPlayer, if that matters. Also, at some intermediate point in my editing, I got this weird result: [url]http://imgur.com/a/8SKTh[/url] It's some different versions of a weird glove texture. I have no idea where it came from or why it's haunting me. [lua]if SERVER then print("SoftPoster must be run clientside!") return end -- this is a goddamn client script! -- Frame blending code copied from: motion_blur.lua local mat_MotionBlur = Material( "pp/motionblur" ) local mat_Screen = Material( "pp/fb" ) local tex_render = render.GetMoBlurTex0() local tex_blender = render.GetMoBlurTex1() local view = {} local function RenderWithAlpha(addalpha) print("RenderWithAlpha(" .. addalpha .. ")") render.UpdateScreenEffectTexture() --mat_Screen:SetFloat( "$alpha", addalpha ) local oldRT = render.GetRenderTarget() render.SetRenderTarget(tex_render) render.RenderView(view) -- Draw normally to the whole texture --render.Clear(255,0,0,255,true,true) render.SetRenderTarget(oldRT) render.SetRenderTarget(tex_blender) mat_MotionBlur:SetTexture("$basetexture", tex_render) mat_MotionBlur:SetFloat("$alpha", addalpha) render.DrawScreenQuad() -- Draw the whole texture, with the correct alpha, into the belnded texture --render.Clear(255,0,0,255,true,true) -- this one works... render.SetRenderTarget(oldRT) end function SoftPoster(radius, resmul, split) local callsleft = resmul * resmul + 1 -- + 800 -- number of calls of the render hook that need to be hooked, 1 extra called pre-poster local ent = LocalPlayer()--:GetEyeTrace().Entity local up = ent:GetAngles():Up() local right = ent:GetAngles():Right() local origin = ent:GetPos() print("Starting poster") --hooks: "RenderScene", "RenderScreenspaceEffects" - don't forget hook.Remove at bottom and the return! hook.Add("RenderScreenspaceEffects", "SoftPoster", function(ViewOrigin, ViewAngles, ViewFOV) view.x = 0 view.y = 0 view.w = ScrW() view.h = ScrH() view.angles = ViewAngles view.origin = ViewOrigin -- Center: ent:SetPos(origin) ent:SetupBones() ent:DrawModel() RenderWithAlpha(1) -- Up Right: ent:SetPos(origin + (up * radius) + (right * radius)) ent:SetupBones() ent:DrawModel() RenderWithAlpha(1/2) -- Down Right: ent:SetPos(origin - (up * radius) + (right * radius)) ent:SetupBones() ent:DrawModel() RenderWithAlpha(1/3) -- Up Left: ent:SetPos(origin + (up * radius) - (right * radius)) ent:SetupBones() ent:DrawModel() RenderWithAlpha(1/4) -- Down Left: ent:SetPos(origin - (up * radius) - (right * radius)) ent:SetupBones() ent:DrawModel() RenderWithAlpha(1/5) -- return to normal: ent:SetPos(origin) -- Draw the finished scene to the Render Target: mat_MotionBlur:SetFloat("$alpha", 1) mat_MotionBlur:SetTexture( "$basetexture", tex_blender ) render.SetMaterial( mat_MotionBlur ) render.DrawScreenQuad() callsleft = callsleft - 1 if (callsleft == 0) then hook.Remove("RenderScreenspaceEffects","SoftPoster") print("Removing hook") end --return true end) RunConsoleCommand("poster", resmul, split) end[/lua] Any thoughts, ideas, musings, tips, or harsh criticism (combined with pointing out what I'm doing wrong) is hugely appreciated. Edit: oh, silly Lua. I forgot to use render.SetMaterial before DrawScreenQuad. But it's totally implied! The computer obviously was supposed to understand what I [i]meant[/i] rather than blindly following the instructions I gave it.
What's the current state of NWVars? When I was properly doing gmod ages ago they were evil and laggy and slow to update and unpredicted and didn't show up in demos etc. I vaguely recall that they were re-written, broke things, fixed things, became better than DTVars, stopped being better than DTVars and so on and so forth. I want to set some values on player, which I can't to my knowledge use SetupDataTables on. Should I be using manual calls to Set/GetDT*() or are NWVars now the solution to all suffering etc?
[QUOTE=Lexic;49824026]What's the current state of NWVars? When I was properly doing gmod ages ago they were evil and laggy and slow to update and unpredicted and didn't show up in demos etc. I vaguely recall that they were re-written, broke things, fixed things, became better than DTVars, stopped being better than DTVars and so on and so forth. I want to set some values on player, which I can't to my knowledge use SetupDataTables on. Should I be using manual calls to Set/GetDT*() or are NWVars now the solution to all suffering etc?[/QUOTE] The current state is that _Kilburn's replacement for Garry's vars ( aka NWVars1 ) is currently in the game under the name of "NWVars2", you can access the functions with setnw2float and etc. At some point they will replace both dtvars ( and network vars since they're just an accessor layer ) and garry's vars internally.
[QUOTE=Jvs;49824035]The current state is that _Kilburn's replacement for Garry's vars ( aka NWVars1 ) is currently in the game under the name of "NWVars2", you can access the functions with setnw2float and etc. At some point they will replace both dtvars ( and network vars since they're just an accessor layer ) and garry's vars internally.[/QUOTE] So I should use SetNW2Bool("uwotm8", true) etc? Are these documented anywhere/stable? They're not on the wiki.
[QUOTE=Lexic;49824056]So I should use SetNW2Bool("uwotm8", true) etc? Are these documented anywhere/stable? They're not on the wiki.[/QUOTE] No they're not documented currently as the plan was to have them replace everything in a transparent way as I stated above, but the function names are pretty much the same as the current SetNW* functions aside from the 2 in between. Also yes they accept the same arguments
[QUOTE=Jvs;49824063]No they're not documented currently as the plan was to have them replace everything in a transparent way as I stated above, but the function names are pretty much the same as the current SetNW* functions aside from the 2 in between. Also yes they accept the same arguments[/QUOTE] Cool. I'll go forth and live dangerously. Thanks for the info.
I wouldn't use FollowBone, just use SetParent ( with it's second parameter ) + SetLocalPos and SetLocalAngles.
How do I get the flashlight origin to move together with the player? My current result: [img]http://i.imgur.com/vVT0CYfl.jpg[/img] I need the shadow to move. My code (relevant part is the repetitive SetPos): [lua]if SERVER then print("SoftPoster must be run clientside!") return end -- this is a goddamn client script! local mat_renderholder = Material( "pp/motionblur" ) local tex_render = render.GetMoBlurTex0() local function RenderWithAlpha(addalpha) render.UpdateScreenEffectTexture() -- not even sure if I need this or what it does -- Render the scene normally to the whole texture (with inevitable 100% alpha) render.PushRenderTarget(tex_render) render.RenderView() render.PopRenderTarget() -- Paste the result onto the actual frame, with the correct alpha mat_renderholder:SetTexture("$basetexture", tex_render) -- do I need this every time? doesn't matter, works mat_renderholder:SetFloat("$alpha", addalpha) render.SetMaterial(mat_renderholder) -- Pro-tip: important, don't forget SetMaterial :D render.DrawScreenQuad() end function SoftPoster(radius, resmul, split) local callsleft = resmul * resmul + 1 -- number of calls of the render hook that need to be hooked, 1 extra called pre-poster local ply = LocalPlayer() local up = ply:GetAngles():Up() local right = ply:GetAngles():Right() local origin = ply:GetPos() print("Starting poster") hook.Add("RenderScene", "SoftPoster", function(ViewOrigin, ViewAngles, ViewFOV) -- Center: ply:SetPos(origin) RenderWithAlpha(1) -- Up Right: -- FACEPUNCH: This is where the player gets moved, and I need to somehow force the flashlight position to move with him: ply:SetPos(origin + (up * radius) + (right * radius)) RenderWithAlpha(1/2) -- Down Right: ply:SetPos(origin - (up * radius) + (right * radius)) RenderWithAlpha(1/3) -- Up Left: ply:SetPos(origin + (up * radius) - (right * radius)) RenderWithAlpha(1/4) -- Down Left: ply:SetPos(origin - (up * radius) - (right * radius)) RenderWithAlpha(1/5) -- return to normal (to avoid breaking anything): ply:SetPos(origin) callsleft = callsleft - 1 if (callsleft == 0) then hook.Remove("RenderScene","SoftPoster") print("Removing render hook") end return true end) RunConsoleCommand("poster", resmul, split) end[/lua]
Could someone tell me what hook to call to prevent the sound of switching weapons from playing?
I'm having a lot of issues with player classes, if anyone could give me some insight on them that would be great! I've been trying a lot of stuff, but I'm having problems such as the shared file not being able to find the classes I've made.. I'm really stumped and I've been trying my best to figure out what to do. Again, any help would be appreciated :smile:
[QUOTE=Shenesis;49825868]Not sure that's something I can do due to the number of different accessories using bones that aren't available as attachments/on some models. What's wrong with FollowBone?[/QUOTE] You could alternatively do the SetNoDraw( true ) DrawModel with SetPos/SetAngles trick, the DModelPanel way, it should work just fine and is especially good for ClientsideModels. FollowBone in my experience is not a good function at all, may be that we are not using it for what it was made for. FollowBone is a really weird function which internally calls selfEntity:SetParent( entityFromFirstArgument, boneId ) and selfEntity:AddEffects( EF_FOLLOWBONE ). That's all it does. [editline]28th February 2016[/editline] So basically, FollowBone is just a big hack that I'd recommend not using.
I get a funky defect when rendering meshes. Here I'm using the render.DrawQuadEasy example from the wiki. [t]http://i.imgur.com/DAEC8C7.jpg[/t] But it also happens when using the mesh library. It only happens with materials that have a $bumpmap. Removing that fixes the problem. What am I doing wrong?
That usually is a result of using wrong shader for models. You gotta use VertexLitGeneric materials for models.
I am using VertexLitGeneric. Here's the material I use in that screenshot: [code]"VertexLitGeneric" { "$baseTexture" "metal/bunker_metalwall01b" "$model" "1" "$bumpmap" "metal/bunker_metalwall01_normal" "$envmaptint" "[ .3 .3 .3 ]" "$envmap" "env_cubemap" //"$normalmapalphaenvmapmask" 1 "$envmapcontrast" .95 "$envmapsaturation" 1 //"$surfaceprop" "metal" }[/code] I also tried some other materials from the Materials tool - same problem.
How can I create a ConVar using C++ in a module? Obviously I can do [CODE]LUA->GetField(-1, "CreateConVar"); LUA->PushString("gmsv_restart_file"); LUA->PushString(""); /* code for enum table */ LUA->Call(3,0);[/CODE] To do [CODE]CreateConVar("gmsv_restart_file","", .. )[/CODE] But I need to find out how to a) Create a Lua table to store the FCVAR enumerations b) Actually get the values of the FCVAR enumerations So how can I go about doing this?
[QUOTE=JasonMan34;49809284]You might want to look in your console for errors, it's a really easy way to find out what you did wrong. self is defined as player.GetAll(), which is a table. However, you try to use the metafunction that is only defined for the "Player" metatable, PS_HasItemEquipped. Instead, loop through the player.GetAll() table (If you make "self" the value you won't have to change the code much)[/QUOTE] Sadly I am back after [B]many[/B] attempts U . U V I decided to edit the main function given just copying it when TTTBeginRound was called seemed off. [lua]timer.Simple(1, function() for k,self in pairs( player.GetAll() ) do if !IsValid(self) then return end if self:PS_HasItemEquipped(id) then end for item_id, item in pairs(self.PS_Items) do local ITEM = PS.Items[item_id] if item.Equipped then ITEM:OnEquip(self, item.Modifiers) end end end end)[/lua] This is the farthest I've gotten from the tips so far, although I am lost where to go from here as it seems to still be fairly distraught with me. I feel like I'm missing something [I]super[/I] obvious. I've tried v in the above code ^ to see if they would help since I saw it in the file aswell. Aswell as blank. [lua]self:PS_HasItemEquipped()[/lua] as both [lua]self:PS_HasItemEquipped(id)[/lua] and as [lua]self:PS_HasItemEquipped(item_id)[/lua]
[QUOTE=Nevec;49829707]I get a funky defect when rendering meshes. Here I'm using the render.DrawQuadEasy example from the wiki. [t]http://i.imgur.com/DAEC8C7.jpg[/t] But it also happens when using the mesh library. It only happens with materials that have a $bumpmap. Removing that fixes the problem. What am I doing wrong?[/QUOTE] Tried on a different GPU - same problem. The problem seems to go away when using IMesh together with the mesh library. Smells like a bug. I'll fiddle with it a bit more and then report it.
Sorry, you need to Log In to post a reply to this thread.