Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Usage:
- -- Bind teleport to a key of your choice with 'On hotkey' as the activation type.
- -- Hold down the key to 'charge' your teleport.
- -- After the teleport has been charged, release the key to teleport.
- -- Because of how Double tap is coded, you need to shoot once after teleporting
- -- before you can 'charge' a new teleport.
- local rage_other_doubletap = ui.reference('RAGE', 'Other', 'Double tap')
- local aa_fakelag_enabled, aa_fakelag_hotkey = ui.reference('AA', 'Fake lag', 'Enabled')
- local aa_fakelag_triggers = ui.reference('AA', 'Fake lag', 'Triggers')
- local aa_fakelag_amount = ui.reference('AA', 'Fake lag', 'Amount')
- local aa_fakelag_variance = ui.reference('AA', 'Fake lag', 'Variance')
- local aa_fakelag_limit = ui.reference('AA', 'Fake lag', 'Limit')
- local aa_other_teleport = ui.new_hotkey('AA', 'Other', 'Teleport')
- local keystate = false -- The last known keystate for the teleport hotkey.
- local settings_cache = {} -- Used for storing and restoring fake lag settings.
- -- Look at the 'run_command' callback before reading the helper functions so you know how they are used.
- -- @Helper function
- --- Stores the user's relevant fake lag settings.
- local function cache_fakelag_settings()
- settings_cache[aa_fakelag_enabled] = ui.get(aa_fakelag_enabled)
- -- Cannot store the fake lag hotkey activation type, so it can't be restored.
- settings_cache[aa_fakelag_triggers] = ui.get(aa_fakelag_triggers)
- settings_cache[aa_fakelag_amount] = ui.get(aa_fakelag_amount)
- settings_cache[aa_fakelag_variance] = ui.get(aa_fakelag_variance)
- settings_cache[aa_fakelag_limit] = ui.get(aa_fakelag_limit)
- end
- -- @Helper function
- --- Restores the user's normal fake lag settings settings.
- local function restore_fakelag_settings()
- ui.set(aa_fakelag_enabled, settings_cache[aa_fakelag_enabled])
- ui.set(aa_fakelag_triggers, settings_cache[aa_fakelag_triggers])
- ui.set(aa_fakelag_amount, settings_cache[aa_fakelag_amount])
- ui.set(aa_fakelag_variance, settings_cache[aa_fakelag_variance])
- ui.set(aa_fakelag_limit, settings_cache[aa_fakelag_limit])
- end
- -- @Helper function
- --- Disables fake lag and sets the limit to 14. This gives you the maximum teleport distance.
- --- The other settings are just to ensure the teleport is consistent.
- local function change_fakelag_settings()
- ui.set(aa_fakelag_enabled, false)
- ui.set(aa_fakelag_hotkey, 'Always on')
- ui.set(aa_fakelag_triggers, {'While moving'})
- ui.set(aa_fakelag_amount, 'Maximum')
- ui.set(aa_fakelag_variance, 0)
- ui.set(aa_fakelag_limit, 14)
- end
- -- @Helper function
- --- Enables double tap to queue commands, or "charges" the teleport. Once it is charged 15
- --- ticks later, it disables double tap.
- local function charge_teleport(first_pass)
- if first_pass then
- ui.set(rage_other_doubletap, 'Off hotkey')
- client.delay_call(globals.tickinterval() * 15, charge_teleport, false)
- else
- ui.set(rage_other_doubletap, 'On hotkey')
- end
- end
- -- @Helper function
- --- Sets the fake lag limit to 14 and then enables fake lag. This will force the queued
- --- commands to be fired. You will move however many ticks you have queued in the direction
- --- you were traveling when the hotkey was released, instantly.
- local function teleport()
- ui.set(aa_fakelag_limit, 14) -- Just to be sure it hasn't changed.
- ui.set(aa_fakelag_enabled, true)
- end
- --- 'run_command' is a custom event which fires every tick.
- client.set_event_callback('run_command', function()
- if ui.get(aa_other_teleport) ~= keystate then
- keystate = ui.get(aa_other_teleport)
- else return end
- -- If the keystate has changed since the last tick, we will be here.
- if ui.get(aa_other_teleport) then -- If key is being held down:
- cache_fakelag_settings()
- change_fakelag_settings()
- charge_teleport(true)
- else -- If key is not being held down (a.k.a. we want to teleport right now):
- teleport()
- -- We wait 15 ticks to restore fake lag settings so they don't interfere with the teleport.
- client.delay_call(globals.tickinterval() * 15, restore_fakelag_settings)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement