==== Racing Script Example ====
First you'll want some way to initiate a race.. Sometimes you might want that to be a special command for admins, or you could do something automatic like this example:
Event( "OnTheHour", "" )
{
$courseNum = 1
*raceinit $courseNum
*announce The hourly race is about to begin. Click the 'Sign Up' button to join!
*soundeffect 26
*eao ShowRaceJoinNotification $courseNum
}
This example initiates a race every hour. The line ''*eao ..'' triggers a custom event for all players currently online (EAO is short for EventAllOnline) with the course number as a parameter. This custom event is used to trigger a popup on the screen of all players currently connected.. e.g
Event( "Custom", "ShowRaceJoinNotification" )
{
$courseNum = $gParam[1]
osdcreate( OSDNOTIFICATION2, "RaceOSD", "Race", 29 )
osdminheight( 80 )
osdadd(TEXT, 50, 10, 0, 0, "", "New Race starting.." )
osdaddat(EXITBUTTON, 40, 40, 180, 30, "Join:$courseNum", "Sign up" )
osdactivate()
}
If the player clicks the 'Sign Up' button, they'd trigger the RaceOSD join event which we might script like this:
Event( "OSDSelect", "RaceOSD:Join" )
{
*setvehicle %PLAYER% 12
*racejoin %PLAYER% $gParam[1]
}
Finally we need some way to start the race (using the *racestart command). Lets do a simple version using a timer.. Modify the original "OnTheHour" event so to include the line:
sysSetTimer( 30, "raceStartTimer", "$courseNum" )
which triggers the timer event 30 seconds after the 'OnTheHour'.
This event would look like:
Event( "Timer", "raceStartTimer" )
{
$courseNum = $gParam[1]
*racestart $courseNum
}
and off they go! \\