Difference between revisions of "0ADC"

From GTAMods Wiki
Jump to navigation Jump to search
(Created page with "{{OpCode | games = {{Icon|t}} (with CLEO) | description = Tests the cheat | syntax1 = 0ADC:   test_cheat "[''string'']" | p1t = [''string''] | p1d...")
 
m
 
(2 intermediate revisions by the same user not shown)
Line 10: Line 10:
  
 
== Example ==
 
== Example ==
The following example pops up different notifications when you type "CHEAT".
+
The following example is from the [http://www.gtagarage.com/mods/show.php?id=28328 Jump and Fly] mod for GTA III. It allows you to continue jumping while airborne, effectively allowing you to travel through the air. Type "JUMPANDFLY" to toggle this effect on or off.
 
{{Pre|class=sb-code|1=
 
{{Pre|class=sb-code|1=
 
<span class="c1">// set constants</span>
 
<span class="c1">// set constants</span>
 
<span class="k">const</span>
 
<span class="k">const</span>
IS_ACTIVE = <span class="nv">0@</span>
+
IS_ENABLED = <span class="nv">0@</span>
 +
PLAYER_STRUCT = <span class="nv">1@</span>
 
<span class="k">end</span>
 
<span class="k">end</span>
  
 
<span class="c1">// initialise</span>
 
<span class="c1">// initialise</span>
IS_ACTIVE = <span class="m">0</span>
+
IS_ENABLED = <span class="m">0</span>
  
 
<span class="k">while</span> <span class="k">true</span>
 
<span class="k">while</span> <span class="k">true</span>
 
     <span class="k">wait</span> <span class="m">10</span>
 
     <span class="k">wait</span> <span class="m">10</span>
 
     <span class="k">if</span>
 
     <span class="k">if</span>
         0ADC:  test_cheat <span class="s2">"CHEAT"</span>
+
         0ADC:  test_cheat <span class="s2">"JUMPANDFLY"</span>
 
     <span class="k">then</span>
 
     <span class="k">then</span>
 
         <span class="k">if</span>
 
         <span class="k">if</span>
             IS_ACTIVE == <span class="m">0</span>
+
             IS_ENABLED == <span class="m">0</span>
 
         <span class="k">then</span>
 
         <span class="k">then</span>
             IS_ACTIVE = <span class="m">1</span>
+
             [[0ACA]]: show_text_box <span class="s2">"Cheat activated"</span>
             0ACA: show_text_box <span class="s2">"Cheat activated"</span>
+
             IS_ENABLED = <span class="m">1</span>
 
         <span class="k">else</span>
 
         <span class="k">else</span>
             IS_ACTIVE = <span class="m">0</span>
+
             [[0ACA]]: show_text_box <span class="s2">"Cheat deactivated"</span>
             0ACA: show_text_box <span class="s2">"Cheat deactivated"</span>
+
             IS_ENABLED = <span class="m">0</span>
 
         <span class="k">end</span>
 
         <span class="k">end</span>
 +
    <span class="k">end</span>
 +
    <span class="k">if</span> <span class="k">and</span>
 +
        IS_ENABLED == <span class="m">1</span>
 +
        [[00E1]]:  player <span class="m">0</span> pressed_button <span class="m">14</span>  <span class="c1">// jump key</span>
 +
    <span class="k">then</span>
 +
        0A8D: PLAYER_STRUCT = read_memory <span class="m">0x9412F0</span> size <span class="m">4</span> virtual_protect <span class="m">0</span>
 +
        [[0AA6]]: call_method <span class="m">0x4D73D0</span> struct PLAYER_STRUCT num_params <span class="m">0</span> pop <span class="m">0</span>  <span class="c1">// CPed::SetJump</span>
 
     <span class="k">end</span>
 
     <span class="k">end</span>
 
<span class="k">end</span>
 
<span class="k">end</span>

Latest revision as of 00:13, 9 February 2017

GTA III Vice City San Andreas (with CLEO)


Description
Tests the cheat
Syntax
0ADC:   test_cheat "[string]"
Parameter
[string]
Input cheat, maximum 30 characters

This conditional CLEO opcode returns true if the specified string of letters has been typed on the keyboard as though you are inputting a cheat code. Any lower case letters (a-z) are converted to upper case by CLEO during run-time.

Example

The following example is from the Jump and Fly mod for GTA III. It allows you to continue jumping while airborne, effectively allowing you to travel through the air. Type "JUMPANDFLY" to toggle this effect on or off.

// set constants
const
IS_ENABLED = 0@
PLAYER_STRUCT = 1@
end

// initialise
IS_ENABLED = 0

while true
    wait 10
    if
        0ADC:   test_cheat "JUMPANDFLY"
    then
        if
            IS_ENABLED == 0
        then
            0ACA: show_text_box "Cheat activated"
            IS_ENABLED = 1
        else
            0ACA: show_text_box "Cheat deactivated"
            IS_ENABLED = 0
        end
    end
    if and
        IS_ENABLED == 1
        00E1:   player 0 pressed_button 14  // jump key
    then
        0A8D: PLAYER_STRUCT = read_memory 0x9412F0 size 4 virtual_protect 0
        0AA6: call_method 0x4D73D0 struct PLAYER_STRUCT num_params 0 pop 0  // CPed::SetJump
    end
end

Keywords

test, cheat