• Attempt to call global 'DrawMotionBlur' (a nil value) on hook.
    12 replies, posted
Heya! I've been trying to make a hook that gives the player motion blur for a few seconds but I keep getting [ERROR] addons/trade_deal_alpha/gamemodes/tradedeal/gamemode/shared.lua:61: attempt to call global 'DrawMotionBlur' (a nil value)   1. RenderScreenspaceEffects - addons/trade_deal_alpha/gamemodes/tradedeal/gamemode/shared.lua:61    2. unknown - addons/trade_deal_alpha/gamemodes/tradedeal/gamemode/shared.lua:60 And I dont know how to fix this, I tried all kinds of stuff including trying to run to run it on the client using if CLIENT then but it does not seem to work, well It does not give me an error anymore but the motion blur just doesn't appear. Code: hook.Add( "OnDamagedByExplosion", "GrenadeFunctions", function(ply, dmginfo) ply:EmitSound(("tradedealalpha/player/ear_ringing2.wav"), 75, 100, 0.1, CHAN_AUTO ) timer.Create("ExplosionBlur", 0, 7, function() DrawMotionBlur( 0.2, 0.99, 0.01 ) end ) return true end
You need to do the DrawMotionBlur in a 2d render hook. like HUDPaint. you run it in a ondamagebyexplosion hook, which does nothing with drawmotion blur. inside the ondamagedbyexplosion hook make a hudpaint hook with the drawmotion blur. you should remove it quick tho otherwise it will make the drawmotion blur alot of times
Alright, thank you for the reply! Will try it now.
dont use a timer. also you CREATE a timer, but you never run it
The timer works fine. Again, I get the same error with the nil value.
Please stop. Issue is, you're using all of this serverside when the function DrawMotionBlur and the hook HUDPaint is clientsided. You need to network.
Thank you for the reply. I hope you don't mine me asking but could give me an example of that or is it too much for you? I'm kinda rusty with lua atm as you can see from those errors so
Do you not know how timers work? @BlackSnow you'd need to use the net library in the OnDamagedByExplosion hook to send it to the client, then in the net.Receive function, do your DrawMotionBlur
Ah, thats the stuff. Thanks a lot man! <3
Shouldn't DrawMotionBlur be called continuously in a 2d hook tho?
There's a hook intended to run screen effects http://wiki.garrysmod.com/page/GM/RenderScreenspaceEffects although you can run it in a 2D hook, HUDPaint is not intended to be used for that
See, I tried running this in my hook but it ended up not working, I dont remember since I tried doing it like 2 days ago, it was either the Nil Value error or just didnt work flatout. Either way, Im gonna try networking this stuff now. Unless somebody has any better ideas they would be highly appreaciated.
Yeah, i would recommend you to network the value to the client, then in client, you define local var (Not in a body) like local explosion = 0 net.Receive("ExplosionReceive", function() explosion = 30 end) hook.Add("RenderScreenspaceEffects","TESTOJA", function() if (explosion > 0) then DrawMotionBlur(1,1,1,2) //not sure the values explosion = explosion - FrameTime() * 2 end end)
Sorry, you need to Log In to post a reply to this thread.