All pastes #462605 Raw Edit

Big race script

public text v1 · immutable
#462605 ·published 2007-04-28 12:10 UTC
rendered paste body
// made by weedarr, dont change the cords or use them please


// Grishracetemplate
// This is a template for making race modes in samp
//
// Alter the code marked with ***** to suit your mode
// all the code that needs altering is near the top of this script
// so you don't need to hunt around for what to change
//
// [DRuG]Grish
// 27/6/2006

#include <a_samp>

// *****
// Set the filename for storing best times here.
// Make sure you have got the \scriptfiles folder
// in your samp server folder.
// Make it unique to your mode.
#define RECORDFILE "grishracetemplatefile.txt"

// *****
// Set the numper of entries in the checkpoints array here.
// The number of race checkpoints will show up as 1 less than this number.
#define MAXCP 61

// *****
// Put your starting grid locations here.
// Format is {x,y,z,angle}
// Same amount as you have starting vehicles.
// Be sure to change the [8] to the number of grid locations you have.
new Float:racestart[10][4] = {
{2618.7129,-2173.6770,12.3784,270.3135},
{2618.9033,-2168.3037,12.3834,271.3705},
{2618.8250,-2163.0063,12.5009,271.1514},
{2618.4753,-2158.0627,12.3130,270.9193},
{2618.6897,-2152.5583,12.3655,270.1660},
{2607.4128,-2173.9089,12.8338,271.4445},
{2607.1807,-2168.3640,12.7772,270.1108},
{2606.7737,-2163.2891,12.9699,271.2032},
{2606.8157,-2158.0254,12.8108,270.4848},
{2606.7083,-2152.4568,12.8790,270.8311}
};

// *****
// Put your checkpoint locations here.
// Same amount as you defied MAXCP as.
// Format is {x,y,z}
// Make the final checkpoint {0.0,0.0,0.0} after the finish checkpoint.
new Float:checkpoints[MAXCP][3] = {
{2750.1736,-2150.6460,11.2877}, //start
{2840.3708,-2056.4160,11.2830},
{2849.0583,-1893.5400,11.2750},
{2824.3762,-1805.8409,11.2363},
{2891.8313,-1463.4266,11.3998},
{2845.2107,-1210.8149,23.9673},
{2849.5085,-786.4734,11.2508},
{2784.4197,-473.9468,11.1840},
{2799.0627,-234.8989,12.3039},
{2859.6050,24.5543,19.1661}, //10
{2811.5918,70.4040,20.1869},
{2759.0229,179.1408,21.9387},
{2393.0491,326.3921,33.0125},
{2315.0164,330.3429,33.0286},
{2341.6963,358.7257,26.7533},
{2336.6882,286.2094,26.7247},
{2261.0022,306.8058,33.0118},
{1934.0181,299.4375,32.4565},
{1735.9539,290.8596,18.4227},
{1788.6515,849.7659,11.0176}, //20
{1720.0208,853.3765,9.1443},
{1485.4655,845.7376,7.1586},
{1344.1625,833.6676,7.2321},
{717.1594,672.3751,10.4554},
{356.2871,785.8143,7.3318},
{212.6740,963.7289,28.5464},
{-267.1076,787.8145,16.6061},
{-399.6724,1005.0307,11.1566},
{-626.0544,1205.0853,11.6384},
{-837.2968,1401.6835,13.9555}, //30
{-932.8773,1718.1675,28.7488},
{-1183.2629,1795.1482,41.0950},
{-1528.3729,1853.0333,29.6986},
{-1727.3418,2161.4524,17.8504},
{-1969.5908,2531.7725,55.9360},
{-2732.0339,2486.1536,76.8560},
{-2747.5603,2357.9392,73.1604},
{-2762.1545,2323.4473,70.4567},
{-2687.7100,1758.5593,68.4363},
{-2669.7183,1194.6532,55.7785}, //40
{-2588.8176,1102.5488,55.9181},
{-2614.6687,1010.6256,78.5885},
{-2747.7083,987.9490,54.6624},
{-2753.7954,883.5251,66.5387},
{-2758.2888,814.7347,53.3313},
{-2843.2534,816.8430,40.9103},
{-2853.9050,425.0810,4.7153},
{-2809.5293,39.0474,7.3811},
{-2779.7451,-492.0653,7.5391},
{-2322.0142,-447.5599,80.1468}, //50
{-2625.4597,-494.7955,70.5643},
{-2420.0808,-610.9222,132.9145},
{-2346.4302,-785.1744,94.6075},
{-2209.6338,-755.8695,63.4379},
{-2164.5110,-1022.6089,33.7675},
{-1920.4697,-1357.5829,41.0329},
{-1899.1681,-1291.1439,39.8347},
{-1898.9772,-418.9127,38.5985},
{-1649.9694,552.2875,39.1227},
{-1104.2035,1143.6646,37.8929}, //finnish 60
{0.0,0.0,0.0}
};


new playercp[MAXCP];
new msg[250];
new playerdriving[100]; 
new playerinrace[100]; 
new playercheck[100]; 
new playerposition[100]; 
new timestart[100]; 
new timeend[100]; 
new Float:timetotal[100]; 
new minutes[100]; 
new seconds[100]; 
new mseconds[100]; 
new ready = 0; 
new rcount = 0; 
new raceon = 0; 
new trig = 0; 
new trigg = 0;
new triggg = 0;
new racers = 0; 
new finished = 0; 
new File:fileh; 

main()
{
	// *****
	// Change this to the name of your mode.
	print("\n----------------------------------");
	print("  Grishracetemplate");
	print("----------------------------------\n");
}



public OnGameModeInit()
{
	// *****
	// Change this to the name of your mode.
	SetGameModeText("grishracetemplate");

	// *****
	// Put the player spawn location here.
	// Make sure it's near the vehicle spawns.
	AddPlayerClass(102,1379.4668,-2240.8201,13.5469,93.5405,0,0,0,0,0,0); // newspawn
	AddPlayerClass(19,1379.4668,-2240.8201,13.5469,93.5405,0,0,0,0,0,0); // newspawn
	AddPlayerClass(29,1379.4668,-2240.8201,13.5469,93.5405,0,0,0,0,0,0); // newspawn
	AddPlayerClass(250,1379.4668,-2240.8201,13.5469,93.5405,0,0,0,0,0,0); // newspawn
	AddPlayerClass(55,1379.4668,-2240.8201,13.5469,93.5405,0,0,0,0,0,0); // newspawn
	AddPlayerClass(56,1379.4668,-2240.8201,13.5469,93.5405,0,0,0,0,0,0); // newspawn
	AddPlayerClass(41,1379.4668,-2240.8201,13.5469,93.5405,0,0,0,0,0,0); // newspawn
	AddPlayerClass(195,1379.4668,-2240.8201,13.5469,93.5405,0,0,0,0,0,0); // newspawn

	// *****
	// Put the race vehicles here.
	// Same amount as the grid locations.
	AddStaticVehicle(402,1415.0199,-2225.3936,13.3785,359.7146,98,98); // buffalo1
	AddStaticVehicle(402,1411.3474,-2225.2778,13.3786,1.7413,10,10); // bufflao2
	AddStaticVehicle(411,1407.9636,-2225.4978,13.2740,1.3077,112,1); // infernus1
	AddStaticVehicle(411,1404.6479,-2225.3301,13.2740,359.8503,80,1); // infernus2
	AddStaticVehicle(415,1384.9316,-2224.9238,13.3193,359.3041,40,1); // cheetah1
	AddStaticVehicle(415,1388.3165,-2224.9673,13.3167,1.1632,75,1); // cheetah2
	AddStaticVehicle(434,1391.7125,-2224.7644,13.5095,0.9281,6,6); // hotknife1
	AddStaticVehicle(434,1394.9598,-2224.7380,13.5136,0.9476,46,46); // hotknife2
	AddStaticVehicle(429,1398.1976,-2224.9031,13.2266,357.7217,1,2); // banshee1
	AddStaticVehicle(429,1401.3424,-2224.9548,13.2266,2.2270,1,3); // banshee1
	AddStaticVehicle(451,1414.8445,-2242.0146,13.2532,359.7733,16,16); // turismo1
	AddStaticVehicle(451,1411.3418,-2242.1326,13.2531,359.1657,46,46); // turismo
	AddStaticVehicle(480,1408.0812,-2242.0713,13.3201,359.7544,6,6); // comet1
	AddStaticVehicle(480,1404.6919,-2242.3188,13.3195,359.7714,46,46); // comet2
	AddStaticVehicle(494,1401.5448,-2241.6602,13.4419,0.1591,42,33); // hotring1
	AddStaticVehicle(494,1398.1494,-2241.5461,13.4419,359.9095,75,79); // hotring2
	AddStaticVehicle(495,1391.5691,-2242.5576,13.9004,0.3258,114,108); // sandking1
	AddStaticVehicle(495,1394.9644,-2242.3745,13.8970,0.7447,88,99); // sandking2
	AddStaticVehicle(506,1388.0690,-2241.8496,13.2514,1.2594,52,52); // supergt1
	AddStaticVehicle(506,1384.7319,-2241.4978,13.2512,1.4574,3,3); // supergt2
	AddStaticVehicle(568,1384.3376,-2261.8076,13.4114,359.3993,37,0); // bandito1
	AddStaticVehicle(568,1387.5829,-2262.0310,13.4130,357.6626,21,1); // bandito2
	AddStaticVehicle(555,1390.8564,-2261.8789,13.2306,0.5906,13,1); // windsor1
	AddStaticVehicle(555,1394.1025,-2261.8213,13.2308,359.7811,68,1); // windsor2
	AddStaticVehicle(545,1403.9362,-2261.5869,13.3580,359.6716,30,1); // hustler1
	AddStaticVehicle(545,1407.1473,-2261.4299,13.3580,0.0277,40,96); // hustler2
	AddStaticVehicle(541,1410.4386,-2261.7649,13.1717,0.1377,13,8); // bullet1
	AddStaticVehicle(541,1413.8853,-2261.8875,13.1719,359.4632,68,8); // bullet2
	AddStaticVehicle(589,1397.3033,-2261.7695,13.2050,1.8957,22,22); // club1
	AddStaticVehicle(589,1400.4305,-2261.6660,13.2049,0.2458,124,124); // club2
	AddStaticVehicle(533,1365.4465,-2256.5596,13.2560,269.7929,84,1); // feltzer1
	AddStaticVehicle(533,1365.6301,-2253.1379,13.2560,269.3158,73,1); // feltzer2
	AddStaticVehicle(534,1364.6439,-2249.5718,13.2723,269.4564,15,15); // remmington1
	AddStaticVehicle(534,1364.4620,-2246.0535,13.2725,270.2062,42,42); // remmington12
	AddStaticVehicle(535,1365.0370,-2242.5583,13.3098,269.7873,97,1); // slamvan1
	AddStaticVehicle(535,1365.0498,-2238.9968,13.3099,269.0838,118,1); // slamvan2
	AddStaticVehicle(536,1365.1353,-2235.5452,13.2844,268.7007,37,1); // blade1
	AddStaticVehicle(536,1365.0752,-2231.9656,13.2846,270.2497,71,96); // balde2
	AddStaticVehicle(573,1363.9419,-2226.6602,14.1973,269.6443,91,38); // duneride1
	AddStaticVehicle(573,1364.0952,-2221.5403,14.1975,269.8822,79,18); // dune2
	AddStaticVehicle(444,1364.2838,-2216.2314,13.9182,269.0210,32,32); // monster1
	AddStaticVehicle(444,1364.1136,-2210.2534,13.9181,270.8846,32,42); // monster2
	AddStaticVehicle(488,1375.6411,-2276.1865,13.7186,359.9999,2,29); // heli1
	
	for (new i=0; i<MAXCP; i++)
    {
    playercp[i] = 999;
    }

	SetTimer("BeginRace",1000,1);
	SetTimer("IsRaceEmpty",1100,1);
	print("GameModeInit()");
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	printf("OnPlayerRequestClass(%d, %d)", playerid, classid);
	SetPlayerFacingAngle(playerid,23.1364);
	SetPlayerPos(playerid,1787.8250,-1898.4103,13.3950);
	SetPlayerCameraPos(playerid,1785.5365,-1895.8412,13.3919);
	SetPlayerCameraLookAt(playerid,1787.8250,-1898.4103,13.3950);
	return 1;
}

public OnGameModeExit()
{
	print("GameModeExit()");
	return 1;
}

public OnPlayerConnect(playerid)
{
	SendClientMessage(playerid,0x00FF00FF,"type /joinrace once you have a car");
	SendClientMessage(playerid,0x00FF00FF,"type /winner to see who's winning");
	printf("OnPlayerConnect(%d)", playerid);
	return 1;
}

public OnPlayerDisconnect(playerid)
{
    playerinrace[playerid] = 0;
    playerposition[playerid] = 999;
	printf("OnPlayerDisconnect(%d)", playerid);
	return 1;
}

public OnPlayerSpawn(playerid)
{
	SetPlayerInterior(playerid,0);
	ResetPlayerMoney(playerid);
	GivePlayerMoney(playerid,100000);
	playerdriving[playerid] = 0;
	playerinrace[playerid] = 0;
	playercheck[playerid] = 0;
	playerposition[playerid] = 999;
	printf("OnPlayerSpawn(%d)", playerid);
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    playerinrace[playerid] = 0;
    playerposition[playerid] = 999;
	printf("OnPlayerDeath(%d, %d, %d)", playerid, killerid, reason);
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	printf("OnVehicleSpawn(%d)", vehicleid);
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	printf("OnVehicleDeath(%d, %d)", vehicleid, killerid);
	return 1;
}

public OnPlayerText(playerid)
{
	printf("OnPlayerText(%d)", playerid);
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp(cmdtext, "/help", true)==0)
	{
	SendClientMessage(playerid,0x00FF00FF,"type /joinrace once you have a car");
	SendClientMessage(playerid,0x00FF00FF,"type /winner to see who's winning");
	SendClientMessage(playerid,0x00FF00FF,"admin command /resetrace for emergency race reset");
	return 1;
	}
	
	if (strcmp(cmdtext, "/joinrace", true)==0)
	{
	if (playerdriving[playerid] == 1 && raceon == 0 && playerinrace[playerid] == 0)
	    {
	    new vid = GetPlayerVehicleID(playerid);
    	SetPlayerInterior(playerid,0);
	    SetVehiclePos(vid,racestart[racers][0],racestart[racers][1],racestart[racers][2]);
	    SetVehicleZAngle(vid,racestart[racers][3]);
	    racers = racers + 1;
	    SetCameraBehindPlayer(playerid);
	    TogglePlayerControllable(playerid,0);
	    SendClientMessage(playerid,0x00FF00FF,"You are in the starting grid");
	    playerinrace[playerid] = 1;
	    playerposition[playerid] = 999;
		if (trig == 0)
		{
		trig = 1;
		GameTextForAll("Race will begin in 20 seconds",3000,3);
		SendClientMessageToAll(0x00FF00FF,"you have 20 seconds to get a car");
		SendClientMessageToAll(0x00FF00FF,"and type /joinrace");
		SetTimer("WaitBeforeRace",20000,0);
		}
	    }
	if (playerdriving[playerid] == 1 && raceon == 1)
	    {
	    GameTextForPlayer(playerid,"Race is in progress, please wait",3000,3);
	    }
	return 1;
	}

	if (strcmp(cmdtext, "/resetrace", true)==0)
	{
    if (IsPlayerAdmin(playerid) == 1)
	    {
		raceon = 0;
		racers = 0;
		}
	return 1;
	}

	if (strcmp(cmdtext, "/winner", true)==0)
	{
	new j = 999;
	if (raceon == 1)
	{
	for(new i=1; i<MAXCP; i++)
	    {
	    if (playercp[i] == 999)
	        {
	        break;
	        }
	    j=playercp[i];
	    }
    if (j != 999)
        {
	    new pname[MAX_PLAYER_NAME];
	    GetPlayerName(j,pname,MAX_PLAYER_NAME);
	    format(msg,sizeof(msg),"%s is winning with %d cps to go",pname,MAXCP-1-playercheck[j]);
	    SendClientMessageToAll(0x00FF00FF,msg);
        }
	}
	return 1;
	}

	return 0;
}

public OnPlayerInfoChange(playerid)
{
	printf("OnPlayerInfoChange(%d)");
	return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	printf("OnPlayerEnterVehicle(%d, %d, %d)", playerid, vehicleid, ispassenger);
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	printf("OnPlayerExitVehicle(%d, %d)", playerid, vehicleid);
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if (newstate == PLAYER_STATE_DRIVER)
	    {
	    playerdriving[playerid] = 1;
	    }
	if (newstate == PLAYER_STATE_ONFOOT)
	    {
	    playerdriving[playerid] = 0;
	    DisablePlayerCheckpoint(playerid);
	    if (playerinrace[playerid] == 1)
	        {
	        playerinrace[playerid] = 0;
	        playerposition[playerid] = 999;
	        GameTextForPlayer(playerid,"you are out of the race",3000,3);
	        }
	    }
	printf("OnPlayerStateChange(%d, %d, %d)", playerid, newstate, oldstate);
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
		playercheck[playerid] = playercheck[playerid] + 1;
	if (playercheck[playerid] >= 1 && playercheck[playerid] <=MAXCP-2)
	    {
	    DisablePlayerCheckpoint(playerid);
	    SetPlayerCheckpoint(playerid,checkpoints[playercheck[playerid]][0],checkpoints[playercheck[playerid]][1],checkpoints[playercheck[playerid]][2],7.0);
	    PlayerPlaySound(playerid,1053,checkpoints[playercheck[playerid]][0],checkpoints[playercheck[playerid]][1],checkpoints[playercheck[playerid]][2]);
		format(msg,sizeof(msg),"cp %d of %d",playercheck[playerid],MAXCP-1);
		GameTextForPlayer(playerid,msg,2000,6);
		if (playercp[playercheck[playerid]] == 999)
		    {
			playercp[playercheck[playerid]] = playerid;
		    }
	    }
	if (playercheck[playerid] == MAXCP-1)
	    {
	    DisablePlayerCheckpoint(playerid);
		timeend[playerid] = tickcount();
		timetotal[playerid] = timeend[playerid] - timestart[playerid];
		timeconvert(playerid);
		PlayerPlaySound(playerid,1132,checkpoints[playercheck[playerid]][0],checkpoints[playercheck[playerid]][1],checkpoints[playercheck[playerid]][2]);
		finished = finished + 1;
        playerposition[playerid] = finished;
   		new pname[MAX_PLAYER_NAME];
		GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
		new pos[] = "th";
		if (playerposition[playerid] == 1 || playerposition[playerid] == 21 || playerposition[playerid] == 31 || playerposition[playerid] == 41 || playerposition[playerid] == 51 || playerposition[playerid] == 61 || playerposition[playerid] == 71 || playerposition[playerid] == 81 || playerposition[playerid] == 91)
			{
			pos = "st";
			}
		if (playerposition[playerid] == 2 || playerposition[playerid] == 22 || playerposition[playerid] == 32 || playerposition[playerid] == 42 || playerposition[playerid] == 52 || playerposition[playerid] == 62 || playerposition[playerid] == 72 || playerposition[playerid] == 82 || playerposition[playerid] == 92)
			{
			pos = "nd";
			}
		if (playerposition[playerid] == 3 || playerposition[playerid] == 23 || playerposition[playerid] == 33 || playerposition[playerid] == 43 || playerposition[playerid] == 53 || playerposition[playerid] == 63 || playerposition[playerid] == 73 || playerposition[playerid] == 83 || playerposition[playerid] == 93)
			{
			pos = "rd";
			}
		format(msg,sizeof(msg),"you finished %d%s in %dmin %d.%dsec",playerposition[playerid],pos,minutes[playerid],seconds[playerid],mseconds[playerid]);
		GameTextForPlayer(playerid,msg,3000,3);
		format(msg,sizeof(msg),"%s finished %d%s in %dmin %d.%dsec",pname,playerposition[playerid],pos,minutes[playerid],seconds[playerid],mseconds[playerid]);
		SendClientMessageToAll(0x00FF00FF,msg);
		if (fexist(RECORDFILE))
		    {
	        new dataname[50];
	        new dataminutes[10];
	        new dataseconds[10];
	        new datamseconds[10];
	   		fileh = fopen(RECORDFILE);
	   		new filedata[100];
	   		new n[] = " ";
	   		new j;
	   		new k;
			fread(fileh,filedata,100);
				for (new i=0; i<100; i++)
				    {
				    j=i;
				    if (filedata[i] == n[0])
				    {
				    break;
				    }
				    dataname[i] = filedata[i];
				    }
				k=j+1;
				for (new i=k; i<100; i++)
				    {
				    j=i;
				    if (filedata[i] == n[0])
				    {
				    break;
				    }
				    dataminutes[i-k] = filedata[i];
				    }
				k=j+1;
				for (new i=k; i<100; i++)
				    {
				    j=i;
				    if (filedata[i] == n[0])
				    {
				    break;
				    }
				    dataseconds[i-k] = filedata[i];
				    }
				k=j+1;
				for (new i=k; i<100; i++)
				    {
				    j=i;
				    if (filedata[i] == n[0])
				    {
				    break;
				    }
				    datamseconds[i-k] = filedata[i];
				    }
			fclose(fileh);
			new old = 1;
			if (minutes[playerid] < strval(dataminutes))
			    {
			    old = 0;
			    }
			else if (minutes[playerid] == strval(dataminutes) && seconds[playerid] < strval(dataseconds))
			    {
			    old = 0;
			    }
			else if (minutes[playerid] == strval(dataminutes) && seconds[playerid] == strval(dataseconds) && mseconds[playerid] < strval(datamseconds))
			    {
			    old = 0;
			    }
			if (old == 0)
			    {
	   			fileh = fopen(RECORDFILE);
				format(msg,sizeof(msg),"%s %d %d %d ",pname,minutes[playerid],seconds[playerid],mseconds[playerid]);
				fwrite(fileh,msg);
				fclose(fileh);
				format(msg,sizeof(msg),"new best time");
				SendClientMessageToAll(0x00FF00FF,msg);
			    }
			else if (old == 1)
			    {
				format(msg,sizeof(msg),"%s holds the best time of %smin and %s:%ssec ",dataname,dataminutes,dataseconds,datamseconds);
				SendClientMessageToAll(0x00FF00FF,msg);
			    }
		    }
  		else
  		    {
    		fileh = fopen(RECORDFILE);
			format(msg,sizeof(msg),"%s %d %d %d ",pname,minutes[playerid],seconds[playerid],mseconds[playerid]);
			fwrite(fileh,msg);
			fclose(fileh);
			format(msg,sizeof(msg),"new best time");
			SendClientMessageToAll(0x00FF00FF,msg);
  		    }
		playerinrace[playerid] = 0;
		if (trigg == 0)
		{
		trigg = 1;
//		GameTextForAll("Race will begin in 20 seconds",3000,3);
//		SendClientMessageToAll(0x00FF00FF,"you have 20 seconds to get a car");
//		SendClientMessageToAll(0x00FF00FF,"and type /joinrace");
		SetTimer("WaitBeforeRaceEnd",20000,0);
		}
//		raceon = 0;
//		racers = 0;
//		rcount = 0;
	    }
	printf("OnPlayerEnterCheckpoint(%d)", playerid);
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	printf("OnPlayerLeaveCheckpoint(%d)", playerid);
	return 1;
}

public WaitBeforeRace()
{
ready = 1;
return 1;
}

public WaitBeforeRaceEnd()
{
raceon = 0;
rcount = 0;
SendClientMessageToAll(0x00FF00FF,"you may now start a new race");
SendClientMessageToAll(0x00FF00FF,"by typing /joinrace");
return 1;
}

public BeginRace()
{
	if (ready == 1)
	    {
	    for (new i=0; i<100; i++)
	        {
	        if (playerinrace[i] == 1 && rcount == 0)
		        {
		        GameTextForPlayer(i,"race will begin in",1000,3);
       	 		}
	        if (playerinrace[i] == 1 && rcount == 1)
		        {
		        GameTextForPlayer(i,"3",1000,3);
       	 		}
	        if (playerinrace[i] == 1 && rcount == 2)
		        {
		        GameTextForPlayer(i,"2",1000,3);
       	 		}
	        if (playerinrace[i] == 1 && rcount == 3)
		        {
		        GameTextForPlayer(i,"1",1000,3);
       	 		}
	        if (playerinrace[i] == 1 && rcount == 4)
		        {
		        GameTextForAll("The race has started",1000,3);
		        TogglePlayerControllable(i,1);
		        timestart[i] = tickcount();
		        SetPlayerCheckpoint(i,checkpoints[0][0],checkpoints[0][1],checkpoints[0][2],7.0);
		        ready = 0;
		        trig = 0;
		        trigg = 0;
		        triggg = 0;
		        raceon = 1;
		        racers = 0;
		        finished = 0;
		        playercheck[i] = 0;
       	 		}
	        }
	        rcount = rcount + 1;
		    for (new i=0; i<MAXCP; i++)
		        {
		        playercp[i] = 999;
		        }
	    }
	return 1;
}

public IsRaceEmpty()
{
	new test = 0;
	for (new i=0; i<100; i++)
	{
	if (playerinrace[i] == 1)
	    {
	    test = 1;
	    }
	}
	if (test == 0 && triggg == 0)
	    {
	    triggg = 1;
	    raceon = 0;
	    rcount = 0;
		SendClientMessageToAll(0x00FF00FF,"you may now start a new race");
		SendClientMessageToAll(0x00FF00FF,"by typing /joinrace");
	    }
return 1;
}

// code from Dabombber
timeconvert(playerid)
{
	timetotal[playerid] = floatdiv(timetotal[playerid], 60000);
    minutes[playerid] = floatround(timetotal[playerid], floatround_tozero);
    seconds[playerid] = floatround(floatmul(timetotal[playerid] - minutes[playerid], 60), floatround_tozero);
    mseconds[playerid] = floatround(floatmul(floatmul(timetotal[playerid] - minutes[playerid], 60) - seconds[playerid], 1000), floatround_tozero);
}