YSI:Races

From SA-MP Wiki

Jump to: navigation, search

Contents

Race system

Introduction

The race system is very simple to use, it has many functions and works nice.

Today we going to make a race in a filter script. It is not difficult to make it.

We going start by explaining every function of the race system.

All functions detailed

Functions:

  • Race_OnPlayerEnterRaceCP() - Not explained yet
  • Race_OnPlayerStateChange() - Not explained yet
  • Race_OnPlayerDisconnect() - Not explained yet
  • Race_Create()
  • Race_AddCheckpoint()
  • Race_AddStart()
  • Race_SetFixedWin()
  • Race_SetArial()
  • Race_PlayerLeave() - Not explained yet
  • Race_SetCountdown()
  • Race_SetInterior()
  • Race_SetWorld()
  • Race_SetPrize()
  • Race_SetExitTime()
  • Race_IsActive()
  • Race_SetLaps()
  • Race_SetEntry()
  • Race_GetPlayerExitedTime() - Not explained yet
  • Race_PlayerJoin()
  • Race_Start()
  • Race_GetPlayerRaceTime() - Not explained yet
  • Race_GetPlayerPosition() - Not explained yet
  • Race_GetPlayerRace() - Not explained yet

Race_Create()

The working of this function, it's really simple:

// You can do:
new Race = Race_Create();

But that's not what he only gots:

Race_Create(laps = 0, entry = 0, countdown = 3, bool:arial = 0, bool:fixedPrize = 1, exitTime = 0, interior = 0, world = 0, bool:restart = 0);

You can set this all in one. Also you can use function's for it, they are explained.

How to use it, if you only will set the laps, exitTime, and restart you can do that:

Race_Create(laps = 3, .exitTime = 1000, .restart = false);

REMEMBER an bool is true or false

why there is a dot before exitTime and restart and not for laps. Simple, laps begins in the function, if you don't want to setup the laps, you can do it this way:

Race_Create(.exitTime = 1000, .restart = false);

Simple :)

Race_AddStart

This functions let the race system know that there is a race started. So the users can join them.

Race_AddStart(raceid, xpos, ypos, zpos, angle);

You can set the start this way. It's not so difficult :)

Race_AddCheckpoint

This function is really simple, the use is allmost the same as Race_AddStart.

Race_AddCheckpoint(raceid, xpos, ypos, zpos);

No angle, the angle is not needed for checkpoints.

Options functions

This are allot of functions, you can do this in Create_Race or do it just in these functions.

I do not explain much, it's how i type it it's a nave to work with it.

Race_SetFixedWin(raceid, set);
Race_SetArial(raceid, set);
Race_SetCountdown(raceid, set);
Race_SetInterior(raceid, intitrior);
Race_SetWorld(raceid, worldid);
Race_SetPrize(racid, place, ammount);
Race_SetExitTime(racid, time);
Race_SetLaps(racid, laps);
Race_SetEntry(racid, ammount);

This are the options, explained.

Race_IsActive

This function checks of the race is active or not.

Race_IsActive(raceid);

How to use:

if(Race_IsActive(raceid))
{
  //race is active
  return 1;
}
 
// race is not active
return 0;

Race_Start

This function starts the race.

Race_Start(raceid);

Race_PlayerJoin

This function add a player to the race.

This should be used before Race_Start or you're going to have a very boring race with no-one taking part.

Usage:

Race_PlayerJoin(playerid, raceid)

Creating a race in a filter script

pawno code replace

Open pawno and start a new file.

Because we don't use the whole system, we can delete something out of it, delete all of your new code and put the next code in:

 
Personal tools
Navigation
Toolbox