Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. callbacks.Register("CreateMove", function(cmd)
  2.  
  3. -- define localplayer and bomb entity
  4. local local_player = entities.GetLocalPlayer();
  5. local bomb = entities.FindByClass("CPlantedC4")[1];
  6.  
  7. -- proceed if localplayer exists and bomb is planted
  8. if (local_player == nil or bomb == nil) then
  9. return
  10. end
  11.  
  12. -- make sure we're CT
  13. if (local_player:GetTeamNumber() ~= 3) then
  14. return
  15. end
  16.  
  17. -- further checks to make sure bomb is still ticking
  18. if not (bomb:GetProp("m_bBombTicking") and bomb:GetProp("m_bBombDefused") == 0 and globals.CurTime() < bomb:GetProp("m_flC4Blow")) then
  19. return
  20. end
  21.  
  22. -- if we don't have enough time to defuse, don't do it
  23. if bomb:GetProp("m_flDefuseCountDown") > bomb:GetProp("m_flC4Blow") then
  24. return
  25. end
  26.  
  27. -- calculate distance from localplayer to the bomb
  28. local distance = vector.Distance( {bomb:GetAbsOrigin()}, {local_player:GetAbsOrigin()} )
  29.  
  30. -- if we're close enough to the bomb
  31. if(distance <= 75) then
  32. -- defuse
  33. cmd:SetButtons(cmd:GetButtons() | (1 << 5))
  34. end
  35.  
  36. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement