Daz_ShadowFox

Proper CurTime() in Move w/ GLua.

Apr 5th, 2015
630
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. --[[
  2. example of how to get CurTime properly
  3. this code is untested, therefore im not sure if it will work
  4. if its not working properly you might have to use an IsFirstTimePredicted() call
  5. this was on nanocats pastebin but he deleted it, so i recreated it without actually testing it, all credits to him
  6. ]]
  7.  
  8. local ProperCurTime = 0;
  9.  
  10. function ProperCurtime()
  11.     if IsFirstTimePredicted() then //thanks to clot for telling me i was being a dumbfuq and forgetting this
  12.         ProperCurTime = CurTime()
  13.     end
  14. end
  15. hook.Add("Move", "getcorrectcurtime", ProperCurtime)
  16.  
  17. function CreateMove(cmd)
  18.     local w = LocalPlayer():GetActiveWeapon()
  19.     if w:GetNextPrimaryFire() < ProperCurTime then //again, thx clot
  20.         cmd:SetButtons(bit.bor(cmd:GetButtons(), IN_ATTACK ))
  21.     else
  22.         print("next attack "..w:GetNextPrimaryFire() .. " curtime: " ..ProperCurTime)
  23.     end
  24. end
  25. hook.Add("CreateMove", "propershoot", CreateMove)
Advertisement
Add Comment
Please, Sign In to add comment