Resource:Race

From Multi Theft Auto: Wiki
Revision as of 00:49, 7 August 2009 by Arc (talk | contribs)
Jump to navigation Jump to search

The "race" gamemode organizes sprint or freeroam races for one or more players. It supports both maps from MTA:Race and maps in the MTA:SA DM map syntax that were created in the map editor.

Ingame

Playing race is quite straightforward. If there are checkpoints, drive from checkpoint to checkpoint and be the first to reach the finish line within the time. If there are no checkpoints, just drive around and have fun.

In races you may encounter three types of pickups which will have an effect on your vehicle:

  • Repair pickups: this pickup looks like a wrench. If you drive over it, your vehicle will be restored to full health.
  • Nitrous oxide pickups: a red NOS bottle. After you drive over one you can press the fire button (by default the left mouse button) to get a temporary speed boost.
  • Vehicle change pickups: these display the name of a vehicle above them. As soon as you drive over a pickup your vehicle will be changed.

Lastly, if you get stuck during a race, you can enter the /kill command in the chatbox to kill yourself and respawn at the previous checkpoint.

Converting MTA:Race maps

Use the batch converter to convert all your MTA:Race maps into MTA:SA maps in one go.

Map syntax

You can create race maps using the new MTA:SA map editor. The map syntax is given here for reference.

.map file

<map mod="deathmatch">
    <!-- One or more -->
    <spawnpoint posX="X" posY="Y" posZ="Z" rotation="Rotation in degrees" vehicle="Vehicle ID" id="spawnpointID" [ paintjob="paintjob ID" upgrades="comma-separated list of upgrades" ] />

    <!-- Zero or more -->
    <checkpoint posX="X" posY="Y" posZ="Z" color="#FF0000" id="textual or numeric checkpoint ID" nextid="ID of checkpoint after this one" [ size="checkpoint size" vehicle="vehicle ID to change into" paintjob="paintjob ID" upgrades="comma-separated list of upgrades" ] />

    <!-- Zero or more -->
    <object posX="X" posY="Y" posZ="Z" rotX="in degrees" rotY="in degrees" rotZ="in degrees" model="model ID" id="objectID" />

    <!-- Zero or more -->
    <pickup posX="X" posY="Y" posZ="Z" type="repair|nitro|vehiclechange" id="pickupID" [ vehicle="vehicle ID" paintjob="paintjob ID" upgrades="comma-separated list of upgrades" ] />
</map>

meta.xml

<meta>
   <info type="map" gamemodes="race" name="Map name" author="Author name" description="Map description" version="Map version number"/>
   <race src="Map file.map"/>
   <settings>
      <setting name="#optionName" value="optionValue"/>
      ...
   </settings>
</meta>

The <setting>s correspond to options in MTA:Race syntax. For example, in MTA:Race syntax would correspond to <setting name="#time" value="4:0"/> in DM syntax.

Addons

A Race 'addon' is no different from any other script resource, except that is has addon="race" in the <info> section of it's meta.xml file. This is simply to allow Race to identify it and put it in the /config menu for you. Addons communicate with Race via events. The current list of Race events and what they do are here:

Events for version 0.8.3

Server

onPlayerReachCheckpoint

onPlayerPickUpRacePickup

onMapStarting

onPlayerFinish

onPostFinish

onPollStarting

Client

onClientMapStarting

onClientPlayerFinish

onClientPlayerOutOfTime

onClientMapStopping

onClientScreenFadedOut

onClientScreenFadedIn

Events for version 0.8.3 in detail

onPlayerReachCheckpoint

Parameters

int checkpoint
  • checkpoint: the number of the checkpoint the player went through. The first checkpoint has number 1.

Source

The source is the player that reached the checkpoint.

onPlayerPickUpRacePickup

Parameters

int/string pickupID
  • pickupID: the number of the pickup in case of MTA:Race syntax (starting at 1), or the "id" attribute of the pickup in case of DM syntax.

Source

The source is the player that picked up the pickup.

Element data

These element data are set on each player:

  • Race rank: the current position of the player in the race. 1 = first, 2 = second etc. Updated on a 1 second interval.
  • race.checkpoint: the number of the checkpoint the player is heading for. When the player spawns this number is 1, after he passed the first checkpoint it's 2, etc.
  • race.finished: true if the player has finished, false if he's still racing.