<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.gtaconnected.com/wiki/index.php?action=history&amp;feed=atom&amp;title=ScriptingExamples%2FCustomCheatsWithoutTimeRestriction</id>
	<title>ScriptingExamples/CustomCheatsWithoutTimeRestriction - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.gtaconnected.com/wiki/index.php?action=history&amp;feed=atom&amp;title=ScriptingExamples%2FCustomCheatsWithoutTimeRestriction"/>
	<link rel="alternate" type="text/html" href="https://wiki.gtaconnected.com/wiki/index.php?title=ScriptingExamples/CustomCheatsWithoutTimeRestriction&amp;action=history"/>
	<updated>2026-04-29T00:46:08Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.15</generator>
	<entry>
		<id>https://wiki.gtaconnected.com/wiki/index.php?title=ScriptingExamples/CustomCheatsWithoutTimeRestriction&amp;diff=4817&amp;oldid=prev</id>
		<title>Mex at 00:09, 8 February 2019</title>
		<link rel="alternate" type="text/html" href="https://wiki.gtaconnected.com/wiki/index.php?title=ScriptingExamples/CustomCheatsWithoutTimeRestriction&amp;diff=4817&amp;oldid=prev"/>
		<updated>2019-02-08T00:09:37Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{DISPLAYTITLE:Custom Cheats without a Time Restriction}}&lt;br /&gt;
== Description ==&lt;br /&gt;
This code allows scripters to easily add custom cheat phrases, without a required delay between key presses.&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Lua, Client-Side:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
{{LuaCode|1=-- initialization&lt;br /&gt;
cheats = {}&lt;br /&gt;
cheats.maxBufferLength = 100&lt;br /&gt;
cheats.buffer = &amp;#039;&amp;#039;&lt;br /&gt;
cheats.hits = {}&lt;br /&gt;
&lt;br /&gt;
-- events&lt;br /&gt;
addEventHandler(&amp;#039;onCharacter&amp;#039;, function(event,text)&lt;br /&gt;
	cheats.addToBuffer(text)&lt;br /&gt;
	cheats.checkToTriggerCheat()&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
-- api&lt;br /&gt;
function cheats.addToBuffer(text)&lt;br /&gt;
	cheats.buffer = (cheats.buffer:len() == cheats.maxBufferLength and cheats.buffer:sub(2) or cheats.buffer) .. text:lower()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function cheats.checkToTriggerCheat()&lt;br /&gt;
	for i=1,cheats.buffer:len() do&lt;br /&gt;
		local text = cheats.buffer:sub(i)&lt;br /&gt;
		if cheats.hits[text] then&lt;br /&gt;
			cheats.hits[text]()&lt;br /&gt;
			cheats.buffer = &amp;#039;&amp;#039;&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- cheats&lt;br /&gt;
function cheats.hits.maxhp()&lt;br /&gt;
	localPlayer.health = 100.0&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function cheats.hits.die()&lt;br /&gt;
	localPlayer.health = 0.0&lt;br /&gt;
end}}&lt;/div&gt;</summary>
		<author><name>Mex</name></author>
	</entry>
</feed>