All of these addresses are relative to zero, you will need to subtract the base address value to get an address that you can use use in livesplit. For gta2script and any language that uses ReadProcessMemory, you don't need to subtract the base address.
gta2.exe v11.44 base address: 0x3F0000
gta2.exe v9.6f (free classics version) base address: 0x400000
GTA2 v11.44 is required for all of the GTA2 script examples in this topic. v9.6f doesn’t have the memory writing/reading commands, the addresses should still work on v9.6f but you’ll need to write to them using an external program.
To get player 1 ped address (ped):
In gta2script, you can just do ADD_SCORE (p1,p1)
In a language that supports ReadProcessMemory:
0x5EB4FC = ptr + 0x4 = p1playerptr + 0xC4 = p1
ped+16c=pointer to the ped's current car. It will be 0 if they are on foot.
ped+1AC=camera x coordinate (coordinates are 0 to 255 multiplied by 16384)
ped+1B0=camera y coordinate
ped+1B4=camera z coordinate
ped+216h=health
ped+200h=identification number
ped=240h=occupation
ped+244h=remap
0x673E2C (6766124) = 0 if singleplayer, 1 network mode
invisibilty, electrofingers on fire and more
I haven't figured all of these out yet. It's a bitmask.
it's a dword at p1+21Ch
invis is 2000000h, something else is 4000000h
[mis]COUNTER in
COUNTER out = 33554433 // this is invis/transparency (you need to get in and out of a car to make yourself transparent on your screen but you will already be invisible on other player's screens)
//COUNTER out = 67108865 // electrofingers
SET in = (p1+540)
CHANGE_GANG_CHAR_RESPECT (in, out, 114)[/mis]
Invulnerability
p1+520 (0x208)
Set to 9999 for untimed invulnerability (same as SET_CHAR_INVINCIBLE). Set to a lower number for a timer invulnerability.
OBJECT postion and rotation:
object + 4 = object pointer
object pointer + 0 = angle (0 to 359) * 4
object pointer + 20 = footy x coord
object pointer + 24 = footy y coord
object coords pointer + 28 = footy z coord
Pointer to information about all players
0x5EB4FC
dword[this+4] = array 0-5 of player pointers
dword[this+1Ch] = my player pointer
byte[this+23h] = number of players
byte[this+24h] = which player i spriteam
dword[this+38h] = my player pointer
byte[player+2Fh] = are all their controls disabled?
byte[player+30h] = are their enter controls disabled?
dword[player+CCh] = camera locked to player
dword[player+128h] = game camera x,y,z
dword[player+1E4h] = view camera x,y,z
dword[player+2A0h] = aux camera x,y,z
dword[player+2C4h] = player Ped pointer?
dword [ped+15Ch] = player pointer
dword [ped+168h] = sprite pointer?
dword [ped+16Ch] = car pointer
dword [ped+1ACh] = x,y,z
word [sprite pointer + 40h] = angle in degrees * 4 (angle_conversion_factor_unk_664E00)
Playercount/number of players in the game
byte [ 23h + dword [5EB4FC]]
so peek the dword at 5EB4FC, add 23h to it, then use that to peek a byte
Example code:
COUNTER static = 6206716
SET in = (static+0)
CHANGE_GANG_CHAR_RESPECT (in,out,104)
SET in = (out+35)
CHANGE_GANG_CHAR_RESPECT (in,out,101)
character/ped/player angle/x,y,z coordinates/speed
pedsprite + 57 = walk/run speed. Speed 1 to 3 walk, 4 and above run. Any faster than 12 and you will outrun the camera.
Pedsprite = peek dword [p1 + 168h] 360
anglepointer = peek dword [pedprite + 80h] 128
peek word [anglepointer]
peek word [anglepointer] + 20 = x
peek word [anglepointer] + 24 = y
peek word [anglepointer] + 28 = z
Example code:
SET in = (p1+360)
CHANGE_GANG_CHAR_RESPECT (in,out,104)
SET in = (out+128)
CHANGE_GANG_CHAR_RESPECT (in,out,104)
SET in = (out+20) //read x
CHANGE_GANG_CHAR_RESPECT (in,out,104)
vehicle coords
p1car + 88 = car pointer + 48 = car X
p1car + 88 = car pointer + 52 = car Y
p1car + 88 = car pointer + 88 = car angle
p1car + 88 = car pointer + 108 = car Z // if you want Z adjust immediately then it must increase by 8192
p1car + 88 = car pointer + 64 = car X speed
p1car + 88 = car pointer + 68 = car Y speed
camera/zoom
SET in = (p+428)
CHANGE_GANG_CHAR_RESPECT (in,out,104)
SET x = (out+0)
SET in = (p+432)
CHANGE_GANG_CHAR_RESPECT (in,out,104)
SET y = (out+0)
SET in = (p+436)
CHANGE_GANG_CHAR_RESPECT (in,out,104)
SET z = (out+0) //zoooooooooooooom
read input/keyboard
Code: Select all
PLAYER_PED p = (99.0, 148.3, 255.0) 12 45
COUNTER loop = 1
COUNTER in
COUNTER out
LEVELSTART
WHILE_EXEC ( loop = 1 )
SET in = (p+348) // player+384 contains a pointer to GTA2 controls
CHANGE_GANG_CHAR_RESPECT (in,out,104) // save that pointer to the out counter (104 means read 4 bytes)
SET in = (out+129) // add 129 to those 4 bytes because I know that 129 = the horn/furp key
CHANGE_GANG_CHAR_RESPECT (in,out,101) // read the horn/furp key into the in counter (101 means read 1 byte)
IF (out=1) // explode the player when they fart
ADD_SCORE (p,out) //EXPLODE (p)
ENDIF
ENDWHILE
LEVELEND
SET in = (p+348)
CHANGE_GANG_CHAR_RESPECT (in,out,104)
SET in = (out+129)
CHANGE_GANG_CHAR_RESPECT (in,out,101)
IF (out=1)
EXPLODE (p)
ENDIF
ppp = player ped pointer
SET in=(out+112) // Up numpad (only in debug mode)
SET in=(out+113) // Down numpad (only in debug mode)
SET in=(out+114) // Left numpad (only in debug mode)
SET in=(out+115) // Right numpad (only in debug mode)
SET in=(out+116) // Home numpad (only in debug mode)
SET in=(out+117) // PageUp numpad (only in debug mode)
SET in=(out+118) // PageDown (only in debug mode)
SET in=(out+119) // PageUp (only in debug mode)
SET in=(out+120) //[ppp+78h] up pressed
SET in=(out+121) //[ppp+79h] down pressed
SET in=(out+122) //[ppp+7Ah] left pressed
SET in=(out+123) //[ppp+7Bh] right pressed
SET in=(out+124) //[ppp+7Ch] shoot pressed
SET in=(out+125) //[ppp+7Dh] bool: "hop in car" is pressed
SET in=(out+126) //[ppp+7Eh] brake/jump
SET in=(out+127) //[ppp+7Fh] "prev weapon" pressed
SET in=(out+128) //[ppp+80h] "next weapon" pressed
SET in=(out+129) //[ppp+81h] bool: special is pressed
SET in=(out+130) //[ppp+82h] bool: special 2 is pressed
SET in=(out+131) //[ppp+84h] bool: special has changed state
SET in=(out+133) // special (horn/furp)
SET in=(out+134) // right shift
SET in=(out+135) // next weapon
SET in=(out+136) // prev weapon
SET in=(out+137) //[ppp+89h]bool: "hop in car" has changed state
SET in=(out+138) // brake/jump
SET in=(out+139) // up
SET in=(out+140) // down
SET in=(out+141) // fire
This byte allows instant gang to get in parked cars/stored cars/mission cars. Normally they only get in dummy traffic cars.
p1car+152 // set to 3 to allow instant gang in your car and peds in your taxi, STORE_CAR_CHARACTER_IS_IN sets p1car+152 to 2.
[mis]
CAR_DATA p1car
COUNTER in
COUNTER cargangflag=3
IF (IS_CHARACTER_IN_ANY_CAR(p1))
STORE_CAR_CHARACTER_IS_IN (p1,p1car)
GIVE_WEAPON (p1car,CAR_MACHINE_GUN)
SET in=(p1car+152)
CHANGE_GANG_CHAR_RESPECT (in,cargangflag,111) // writes the value 3 to the IN memory address, 111 just means write 1 byte
ENDIF
[/mis]
You can enable do_show_ids by changing byte at 0x5EADA1 to 1. GTA2 will save that setting to registry.
[mis]
LEVELSTART
//showpedid
COUNTER showpedid = 6204833
COUNTER one = 1
CHANGE_GANG_CHAR_RESPECT (showpedid, one, 111)
[/mis]
PLAYER_PED p1 = (117.0,133.5,255.0) 10 270 // Red
PLAYER_PED p2 = (118.0,133.5,255.0) 09 090 // Orange
PLAYER_PED p3 = (117.5,132.5,255.0) 07 180 // Yellow
PLAYER_PED p4 = (117.5,134.5,255.0) 11 000 // Green
PLAYER_PED p5 = (117.0,132.5,255.0) 13 225 // Blue
PLAYER_PED p6 = (118.0,134.5,255.0) 08 045 // Black
Armour/Armor
[mis]
LEVELSTART
COUNTER loop = 1
COUNTER player_ptr
COUNTER player_addr
COUNTER armour_ptr
COUNTER armour_addr = 10
WHILE_EXEC (loop = 1)
ALTER_WANTED_LEVEL_NO_DROP (p1,6)
SET player_ptr = (p1+348)
CHANGE_GANG_CHAR_RESPECT (player_ptr,player_addr,104)
SET armour_ptr = (player_addr+1786)
CHANGE_GANG_CHAR_RESPECT (armour_ptr,armour_addr,111)
ENDWHILE
LEVELEND
[/mis]
0x5EC470 byte (menu) start in player area 0, 1 , 2
0x5EC471 byte (menu) bonus stage
0x5EC473 byte (menu) player profile