RU/Resource:Race

From Multi Theft Auto: Wiki
Revision as of 19:25, 19 May 2010 by Mekorea (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.

Installing maps

Installing maps in MTA:Race syntax

Adding MTA:Race maps to your DM server is easy. All you have to do is place the file in a folder and add a meta.xml. No conversion is necessary.

  • Go to the "resources" folder of your server installation (<SERVER>\mods\deathmatch\resources) and create a new folder. In order to keep with conventions, the folder name should be in the format "race-<mapname>", so if the map file is called "Dirtring.map" you might call the folder "race-dirtring".
  • Copy the .map file into the new folder
  • Create a meta.xml file in the new folder and paste the following text into it:
<meta>
    <info type="map" gamemodes="race" name="" />
    <race src=".map" />
</meta>
  • Enter the name of the map, for example "Dirtring", in the "name" attribute of the <info> node.
  • Enter the name of the .map file in the "src" attribute of the <race> node, for example "Dirtring.map".
  • Save the meta.xml.
  • Add more maps if you wish. When you're done, /refresh your server resources.

Installing maps in DM syntax

If you created the map yourself in the MTA:SA DM map editor, everything will be in place and you only need to /refresh. If you downloaded the map, place it in your server "resources" folder and /refresh.

Converting maps from Race syntax to DM syntax

The MTA:SA DM map editor can only edit maps in the DM syntax. If you want to edit maps that are in MTA:Race syntax, you need to convert them.

  • Make sure the map you want to convert is not in a zip file. If it is, create a folder with the same name as the zip file and extract the zip contents into it.
  • Make sure race is started. Either have a race map running, or do /start race.
  • Enter the command /convrace <map resource name>.
  • The conversion process should be very quick. Once conversion is complete a message will appear.

The map file is overwritten with the converted version. If you want to keep the original file, make sure you have a backup.

Map syntax

MTA:Race style syntax

<map mod="race">
    <meta>
        <author>Author name</author>
        <description>Map description</description>
        <version>Map version number</version>
    </meta>

    <options>
        <weather>Weather ID</weather>
        <respawn>timelimit|none</respawn>    <!-- Default = timelimit -->
        <duration>Maximum race time in seconds. Default is 30 minutes</duration>
        <time>hour:minute</time>        <!-- Time of day at which the race starts -->
        <vehicleweapons>true|false</vehicleweapons>    <!-- Vehicle weapon firing allowed or not. Default is false -->
        <ghostmode>true|false</ghostmode>    <!-- Disables vehicle collision. Default is false. -->
        <skins>cj|random|rangelist></skins>    <!-- Skins for the players. See explanation below for rangelist -->
        <!-- if respawn == timelimit -->
        <respawntime>Time from death to respawn in seconds. Default is 5.</respawntime>
    </options>

    <!-- One or more -->
    <spawnpoint>
        <position>X Y Z</position>
        <rotation>Angle in degrees. 0 = north, higher values go counter clockwise.</rotation>
        <vehicle>Vehicle number</vehicle>
        <!-- optional -->
        <paintjob>Paintjob ID, ranges from 0 to 3</paintjob>
        <upgrades>Space separated list of vehicle upgrade numbers</upgrades>
    </spawnpoint>

    <!-- Zero or more -->
    <checkpoint>
        <position>X Y Z</position>
        <size>Float. Higher values make the checkpoint marker bigger. Default is 2.25</size>
        <color>R G B</color>   <!-- R, G and B range from 0 to 255. Default color is 255 0 0 (red) -->
        <!-- optional -->
        <vehicle>Vehicle ID to change into when passing through this checkpoint</vehicle>
        <paintjob>Paintjob ID, ranges from 0 to 3</paintjob>
        <upgrades>Space separated list of vehicle upgrade numbers</upgrades>
    </checkpoint>

    <!-- Zero or more -->
    <object>
        <position>X Y Z</position>
        <rotation>rotX rotY rotZ</rotation>  <!-- Each rotation is in radians. Rotations for X and Z are switched. -->
        <model>Model ID</model>
    </object>

    <!-- Zero or more -->
    <pickup>
        <position>X Y Z</position>
        <type>repair|nitro|vehiclechange</type>
        <!-- if type == vehiclechange -->
        <vehicle>Vehicle ID to change into</vehicle>
        <!-- optional -->
        <paintjob>paintjob ID</paintjob>
        <upgrades>Space separated upgrade list</upgrades>
    </pickup>
</map>

The <skins> option can be "cj" (players are CJ in random clothes), "random" (players have random ped skins), or a range list. A range list is a space separated list of single numbers and ranges of numbers expressed as "start-end". For example:

18 40-50 65-68 72 200

The skin of each player will be chosen at random from this list.

MTA:SA DM style syntax

.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.

Events

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.