GTA2 scripting

This page contains some advanced GTA2 scripting advice. If you are a beginner then I suggest checking Project Cerbera for GTA2 scripting tutorials.

Check the forum for more scripts.

GTA2 scripting problems
You can solve some compiler crashing problems by deleting the *.tmp and *.### files in the compiler folder and in the script folder. The compiler can crash if there are too many files in the same folder as the compiler, so it’s best not to install the compiler into the GTA2 data folder. Shops will crash the GTA2 compiler if they don’t have a Z coordinate.

You should never initially spawn a player on top of a weapon pickup. The player should start at least one cube away. Respawn locations can be above weapon pickups.

GTA2 will usually crash if you try to use a command on a player, character, object or vehicle that doesn’t exist.

The GIVE_WEAPON command will crash if you try to give a weapon to a player that doesn’t exist. If you want to use that command in a multiplayer script then you must check if the player exists by using the CHECK_CHARACTER_HEALTH command.

Example:

IF ( CHECK_CHARACTER_HEALTH ( P1 , 0 ) )
GIVE_WEAPON ( P1 , ROCKET_LAUNCHER )
ENDIF

This checks to see if a player’s health is more than zero before giving them a weapon. Player’s that haven’t joined the game will always have zero health. Player’s that quit will randomly respawn as peds, so this can’t be used to detect if a player has quit. You can use CHECK_SCORE_GREATER to detect if a player quit since peds can’t carry cash (not even muggers).

Code that can only be used in multplayer with the latest update
WARP_FROM_CAR_TO_POINT, SET_ALL_CONTROLS_STATUS, SET_ENTER_CONTROL_STATUS, DECLARE_POLICELEVEL (6) and ROAD_BLOCK_TANK_MAN used to make the game go out of sync but thanks to Vike, they all work with latest patch.

Code that shouldn’t be used in multiplayer
These commands will instantly make the game go out of sync. If you know of others (I haven’t tested every command in multiplayer) then leave a comment.

START_BONUS_CHECK and most kill frenzy related code isn’t synced but some are safe to use as long as there are no shops or anyway to spend money.

Do not spawn a car on top of a player unless you want weird results to happen and the game to go unstable.

3 thoughts on “GTA2 scripting”

Leave a Reply

Your email address will not be published. Required fields are marked *