• Quick timer question
    3 replies, posted
Hey there, quick question about timers(clearly from the title :|) how can I call timers without having to need a function, the reason I ask is because I made a hitmarker but it gets removed at different times because the timer is at a different time everytime it's called. Here's what I have; [lua] function GM:EntityTakeDamage( ent, inflictor, attacker, amount, dmginfo ) if attacker:IsPlayer() then umsg.Start("attack",attacker) umsg.Long(amount) umsg.End() end [/lua] that's the serverside file [lua] local hitm = 0 local hita = 0 usermessage.Hook("attack",function(um) hitm = 1 hita = um:ReadLong() end) timer.Create("endattack",1,0,function() if hitm == 1 then hitm = 0 hita = 0 end end) --HUD Part now; draw.SimpleText("X","BPS",ScrW() / 2-5,ScrH() / 2-8,Color(255,0,0,hitm*255)) -- Yes, I know, that's lazy :V [/lua]
Please explain; do you mean you want to set hitm to 0 one second after the usermessage is received?
Yeah.
[lua] timer.Simple(1, function() hitm = 0 end) [/lua] Single use timer. usage timer.Simple(seconds, function, args)
Sorry, you need to Log In to post a reply to this thread.