Advertisement
Guest User

gamesense teleport

a guest
Feb 21st, 2019
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. -- Usage:
  2. -- Bind teleport to a key of your choice with 'On hotkey' as the activation type.
  3. -- Hold down the key to 'charge' your teleport.
  4. -- After the teleport has been charged, release the key to teleport.
  5. -- Because of how Double tap is coded, you need to shoot once after teleporting
  6. -- before you can 'charge' a new teleport.
  7.  
  8. local rage_other_doubletap = ui.reference('RAGE', 'Other', 'Double tap')
  9. local aa_fakelag_enabled, aa_fakelag_hotkey = ui.reference('AA', 'Fake lag', 'Enabled')
  10. local aa_fakelag_triggers = ui.reference('AA', 'Fake lag', 'Triggers')
  11. local aa_fakelag_amount = ui.reference('AA', 'Fake lag', 'Amount')
  12. local aa_fakelag_variance = ui.reference('AA', 'Fake lag', 'Variance')
  13. local aa_fakelag_limit = ui.reference('AA', 'Fake lag', 'Limit')
  14. local aa_other_teleport = ui.new_hotkey('AA', 'Other', 'Teleport')
  15.  
  16. local keystate = false -- The last known keystate for the teleport hotkey.
  17. local settings_cache = {} -- Used for storing and restoring fake lag settings.
  18.  
  19. -- Look at the 'run_command' callback before reading the helper functions so you know how they are used.
  20.  
  21. -- @Helper function
  22. --- Stores the user's relevant fake lag settings.
  23. local function cache_fakelag_settings()
  24. settings_cache[aa_fakelag_enabled] = ui.get(aa_fakelag_enabled)
  25. -- Cannot store the fake lag hotkey activation type, so it can't be restored.
  26. settings_cache[aa_fakelag_triggers] = ui.get(aa_fakelag_triggers)
  27. settings_cache[aa_fakelag_amount] = ui.get(aa_fakelag_amount)
  28. settings_cache[aa_fakelag_variance] = ui.get(aa_fakelag_variance)
  29. settings_cache[aa_fakelag_limit] = ui.get(aa_fakelag_limit)
  30. end
  31.  
  32.  
  33. -- @Helper function
  34. --- Restores the user's normal fake lag settings settings.
  35. local function restore_fakelag_settings()
  36. ui.set(aa_fakelag_enabled, settings_cache[aa_fakelag_enabled])
  37. ui.set(aa_fakelag_triggers, settings_cache[aa_fakelag_triggers])
  38. ui.set(aa_fakelag_amount, settings_cache[aa_fakelag_amount])
  39. ui.set(aa_fakelag_variance, settings_cache[aa_fakelag_variance])
  40. ui.set(aa_fakelag_limit, settings_cache[aa_fakelag_limit])
  41. end
  42.  
  43.  
  44. -- @Helper function
  45. --- Disables fake lag and sets the limit to 14. This gives you the maximum teleport distance.
  46. --- The other settings are just to ensure the teleport is consistent.
  47. local function change_fakelag_settings()
  48. ui.set(aa_fakelag_enabled, false)
  49. ui.set(aa_fakelag_hotkey, 'Always on')
  50. ui.set(aa_fakelag_triggers, {'While moving'})
  51. ui.set(aa_fakelag_amount, 'Maximum')
  52. ui.set(aa_fakelag_variance, 0)
  53. ui.set(aa_fakelag_limit, 14)
  54. end
  55.  
  56.  
  57. -- @Helper function
  58. --- Enables double tap to queue commands, or "charges" the teleport. Once it is charged 15
  59. --- ticks later, it disables double tap.
  60. local function charge_teleport(first_pass)
  61. if first_pass then
  62. ui.set(rage_other_doubletap, 'Off hotkey')
  63. client.delay_call(globals.tickinterval() * 15, charge_teleport, false)
  64. else
  65. ui.set(rage_other_doubletap, 'On hotkey')
  66. end
  67. end
  68.  
  69.  
  70. -- @Helper function
  71. --- Sets the fake lag limit to 14 and then enables fake lag. This will force the queued
  72. --- commands to be fired. You will move however many ticks you have queued in the direction
  73. --- you were traveling when the hotkey was released, instantly.
  74. local function teleport()
  75. ui.set(aa_fakelag_limit, 14) -- Just to be sure it hasn't changed.
  76. ui.set(aa_fakelag_enabled, true)
  77. end
  78.  
  79.  
  80. --- 'run_command' is a custom event which fires every tick.
  81. client.set_event_callback('run_command', function()
  82. if ui.get(aa_other_teleport) ~= keystate then
  83. keystate = ui.get(aa_other_teleport)
  84. else return end
  85.  
  86. -- If the keystate has changed since the last tick, we will be here.
  87. if ui.get(aa_other_teleport) then -- If key is being held down:
  88. cache_fakelag_settings()
  89. change_fakelag_settings()
  90. charge_teleport(true)
  91. else -- If key is not being held down (a.k.a. we want to teleport right now):
  92. teleport()
  93. -- We wait 15 ticks to restore fake lag settings so they don't interfere with the teleport.
  94. client.delay_call(globals.tickinterval() * 15, restore_fakelag_settings)
  95. end
  96. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement