Custom Cheats without a Time Restriction

From GTA Connected
Revision as of 00:09, 8 February 2019 by Mex (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Description

This code allows scripters to easily add custom cheat phrases, without a required delay between key presses.

Code

Lua, Client-Side: -- initialization cheats = {} cheats.maxBufferLength = 100 cheats.buffer = cheats.hits = {}

-- events addEventHandler('onCharacter', function(event,text) cheats.addToBuffer(text) cheats.checkToTriggerCheat() end)

-- api function cheats.addToBuffer(text) cheats.buffer = (cheats.buffer:len() == cheats.maxBufferLength and cheats.buffer:sub(2) or cheats.buffer) .. text:lower() end

function cheats.checkToTriggerCheat() for i=1,cheats.buffer:len() do local text = cheats.buffer:sub(i) if cheats.hits[text] then cheats.hits[text]() cheats.buffer = break end end end

-- cheats function cheats.hits.maxhp() localPlayer.health = 100.0 end

function cheats.hits.die() localPlayer.health = 0.0 end