Advertisement
Guest User

Fixed Bot Stay

a guest
Mar 23rd, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. local players = entities.FindByClass( "CCSPlayer" )
  2. local isBot = false
  3.  
  4. --AW Gui--
  5. local Ref_BotCmd = gui.Reference( "MISC", "Part 1" );
  6. local Checkbox_BotCmd = gui.Checkbox( Ref_BotCmd, "msc_holdpos_active", "Auto Hold Position", 0 );
  7.  
  8. --Timer--
  9. local timer = timer or {}
  10. local timers = {}
  11. ---------
  12.  
  13. local function checkBot() --Checking if there is a Bot in your team (*exept u)
  14. for i = 1, #players do
  15. local player = players[ i ];
  16.  
  17. botDificulty = entities.GetPlayerResources():GetPropInt("m_iBotDifficulty", player:GetIndex());
  18.  
  19. if player:GetTeamNumber() == entities.GetLocalPlayer():GetTeamNumber() then
  20. if botDificulty >= 0 then --Yup... I am to dumb and lazy to find a proper way
  21. isBot = true
  22. else
  23. isBot = false
  24. end
  25. else
  26. end
  27. end
  28. end
  29.  
  30. function holdPos(event) --Holdpos function
  31. if Checkbox_BotCmd:GetValue() then
  32. if event:GetName() == "round_freeze_end" then
  33. checkBot()
  34. if isBot then
  35. timer.Create("holdpos_delay", 1.0, 1, function()
  36. client.Command("holdpos", false)
  37. end)
  38. end
  39. end
  40. end
  41. end
  42. client.AllowListener("round_freeze_end")
  43. callbacks.Register( "FireGameEvent", "Hold BOT Pos", holdPos );
  44.  
  45.  
  46.  
  47.  
  48. function timer.Create(name, delay, times, func)
  49.  
  50. table.insert(timers, {["name"] = name, ["delay"] = delay, ["times"] = times, ["func"] = func, ["lastTime"] = globals.RealTime()})
  51.  
  52. end
  53.  
  54. function timer.Remove(name)
  55.  
  56. for k,v in pairs(timers or {}) do
  57.  
  58. if (name == v["name"]) then table.remove(timers, k) end
  59.  
  60. end
  61.  
  62. end
  63.  
  64. function timer.Tick()
  65.  
  66. for k,v in pairs(timers or {}) do
  67.  
  68. if (v["times"] <= 0) then table.remove(timers, k) end
  69.  
  70. if (v["lastTime"] + v["delay"] <= globals.RealTime()) then
  71. timers[k]["lastTime"] = globals.RealTime()
  72. timers[k]["times"] = timers[k]["times"] - 1
  73. v["func"]()
  74. end
  75.  
  76. end
  77.  
  78. end
  79.  
  80. callbacks.Register( "Draw", "timerTick", timer.Tick);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement