Difference between revisions of "User:Erorr404/My Resources/Street Race Documentation"

From Multi Theft Auto: Wiki
(New page: The loadRace function loads a race and is the first function called when setting up a race. A race cannot be unloaded, but a new race can be loaded in place of the old one by calling the f...)
 
(No difference)

Latest revision as of 08:47, 19 December 2008

The loadRace function loads a race and is the first function called when setting up a race. A race cannot be unloaded, but a new race can be loaded in place of the old one by calling the function a second time. It accepts an array of 3-D coordinates, representing the race checkpoints and in the checkpoint order. It is of the following form: { {float checkpointOneX, float checkpointOneY, float checkpointOneZ}, {float checkpointTwoX, float checkpointTwoY, float checkpointTwoZ}, etc. }. When a race is loaded, the race participants are shown the first checkpoint, but cannot yet hit it.

The startRace function allows players to perform the race by allowing them to hit the checkpoints. A race can only be started when a race map is loaded, and not when there is already a race in progress. A race in progress can be ended with the endRace() function.

addRacer adds a player to the race. A player can only be added to the race while a race is loaded, and before it is started.

removeRacer can remove a racer while the race is loaded (can be used before or after a race is started).

bool loadRace ( table orderedCheckpointCoordinates )
bool isRaceLoaded ()
bool startRace ()
bool endRace ()
bool isRaceStarted ()
bool addRacer ( player theRacer )
bool removeRacer ( player theRacer )

There is also a function that generates a random race and returns a table of ordered coordinates that can be passed to the loadRace function. It accepts the root node of an xml file with a set of child nodes of the following form: <node id="6" posx="-1966.7542724609" posy="1176.3934326172" posz="44.296875" neighbors="5,7,153" region="San Fierro" /> where the id is an integer that uniquely identifies the node. The neighbors indicate the neighboring nodes (i.e. checkpoints that can follow the current checkpoint).

startID indicates the first checkpoint of the race, and raceLength is the total number of checkpoints to be generated.

table generateCheckpointTable(xmlNode rootNode, int startID, [int raceLength = 25])