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.
Tip by [DAFE]: The game automatically gets rid of wrecked cars declared with PARKED_CAR_DATA but not cars declared with CAR_DATA.
GTA2 scripting problems
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.
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 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 contact me.
START_BONUS_CHECK and most kill frenzy related code isn't synced but if you only use them to display messages to players and don't give any weapons or allow them to use cash to purchase items then it should be safe to use.
WARP_FROM_CAR_TO_POINT, SET_ALL_CONTROLS_STATUS, SET_ENTER_CONTROL_STATUS DECLARE_POLICELEVEL (6) and ROAD_BLOCK_TANK_MAN are safe to use with GTA2 v11.40.
Do not spawn a car on top of a player unless you want weird results to happen and the game to go unstable.








February 14th, 2010 - 22:18
cool you
April 30th, 2010 - 15:30
Too cool for you!