From GTAMods Wiki
Jump to navigation Jump to search


Gets the state of the button
00E2: get_player [int1] key [int2] state_to [var]
Joypad (usually 0)
Joypad button
Variable to store the state, an integer value

This opcode gets the state of the button. It returns a value between 0 and 255, 255 meaning the button is completely pressed down. For left and right analogue sticks (buttons 0 to 3), it returns a value between -128 and 128, -128 meaning the stick is completely pressed in one direction and 128 meaning the stick is completely pressed in the other direction. This opcode was never called in the original script of GTA III.

For Vice City

This opcode does not exist in Vice City but it is possible to retrieve the state of the button in the same manner as GTA III. The following example, using Sanny Builder with CLEO for Vice City in an external script (not the main one) and tested on US v1.0, should work similarly to this opcode.

// [email protected] - input param (joypad)
// [email protected] - input param (joypad button)
05E2: call_function 0x4AB060 num_params 1 pop 1 [email protected] store_to [email protected]  // CPad::GetPad
[email protected] *= 2  // size of each button
005A: [email protected] += [email protected]  // add to base address for pad
05E0: [email protected] = read_memory [email protected] size 2 virtual_protect 0  // read state of button
    [email protected] > 32767  // state of button is stored as signed short
    [email protected] -= 65536
05F6: ret 1 [email protected]

Use this line as a substitute for opcode 00E2. This can be placed anywhere within the external script:

05F5: call_scm_func @opcode_00E2 inputs 2 pad [int1] button [int2] result [var]


get, button, key, press, pressed, keypress

See also

  • GTA III Vice City San Andreas 00E1, checks if the button is pressed
  • GTA III Vice City San Andreas 0494, an alternative to getting state of the stick (buttons 0 to 3)