Little problem..
#5

The script :

Код:
/* Made by DutchDominator AKA H4rdc0r3.
#  Do not claim this as your own, if you use it, don't forget the credits.
#  Yes, you may change this script and republish it, but keep credits to me.*/


#include <a_samp>

#define FILTERSCRIPT

//These are the coordinates your player will spawn at if they are still alive at the end of a minigame:

#define spawnX 1310.000000
#define spawnY -1370.199951
#define spawnZ 13.500000

new Text:HClock;
new Text:HClock2;
new Text:HClock3;
new TimeTimer;

new playerinminigame[MAX_PLAYERS];

new bloodring[15],derbyon,derbyplaying,playercarid[MAX_PLAYERS],playerinderby[MAX_PLAYERS],derbyrank,reward,bloodringfull[15],playerinbloodring[MAX_PLAYERS];

new tdmon,tdmplaying,playerintdm[MAX_PLAYERS],tdmrank,redplayers,blueplayers,tdmcolor,oldplayercolor[MAX_PLAYERS];

new dmon,dmplaying,playerindm[MAX_PLAYERS],dmrank;

new qbloodring[15],qbloodringfull[15],playerinqderby[MAX_PLAYERS],playerinqbloodring[MAX_PLAYERS],qderbyrank,qderbyon,qderbyplaying;

new boxon,boxplaying,playerinbox[MAX_PLAYERS],boxrank;

new sdon,sdplaying,playerinsd[MAX_PLAYERS],sdrank,sdfirst;

new karts[15],kartfull[15],karton,kartplaying,playerinkartrace[MAX_PLAYERS],kartrank,playerinkart[MAX_PLAYERS],currentcheckpoint[MAX_PLAYERS],krtfirst;

new nrg[15],nrgfull[15],sron,srplaying,playerinsr[MAX_PLAYERS],srrank,playerinnrg[MAX_PLAYERS],currentracecheckpoint[MAX_PLAYERS],srfirst;

new startvar[8];

//Timers:

new dtimer,dmtimer,tdmtimer,qdtimer,boxtimer,sdtimer,krttimer,srtimer;

forward TimeUpdate();

forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
forward load();

forward Spawnbloodrings();// Derby
forward Destroybloodrings();
forward Respawnbloodrings();
forward StartDerby();

forward Starttdm();// TeamDM

forward Startdm();// LVDM

forward Spawnqbloodrings();// Quarry Derby
forward Destroyqbloodrings();
forward Respawnqbloodrings();
forward StartqDerby();
forward OnPlayerPrivmsg(playerid, recieverid, text[]);
forward OnPlayerInfoChange(playerid);

forward StartBox();// Boxing Fight

forward StartSd();// Skydive
forward EndSd();
forward SdFinish(playerid);

forward SpawnKarts();// KartRace
forward DestroyKarts();
forward RespawnKarts();
forward StartKart();
forward KrtFinish();

forward SpawnNrgs();// Stadium Race
forward DestroyNrgs();
forward RespawnNrgs();
forward StartSr();
forward SrFinish();

forward RewardCalc(playerid,min,max);// General reward calc.


// Derby cars:
new Float:derbycars[15][4] = {
{-1362.9799,932.8219,1036.0580,9.0890}, // 0
{-1346.4526,935.4996,1036.0889,13.6811}, // 1
{-1335.6995,938.2600,1036.1177,16.8043}, // 2
{-1320.8756,944.9904,1036.2062,27.0307}, // 3
{-1306.8385,953.5919,1036.3212,37.8366}, // 4
{-1353.9670,934.0486,1036.2421,11.5836}, // 5
{-1328.6377,941.0197,1036.3208,18.9670}, // 6
{-1313.9012,948.6513,1036.4198,29.5596}, // 7
{-1501.0956,960.3203,1036.9474,313.0457}, // 8
{-1506.8105,968.1082,1037.0840,304.3027}, // 9
{-1513.0317,976.8713,1037.2457,301.9500}, // 10
{-1516.0858,988.2343,1037.4362,274.5044}, // 11
{-1517.6569,995.6628,1037.5626,272.2782}, // 12
{-1515.1127,1004.8807,1037.6969,262.3869}, // 13
{-1510.7020,1014.6202,1037.8568,249.1825} // 14
};


// LVDM Spawn places:
new Float:lvdmspawns[15][3] = {
{2297.5220,2484.1804,3.2734}, // 0
{2271.5120,2474.2268,3.2734}, // 1
{2244.7441,2467.5762,3.2734}, // 2
{2248.0867,2448.3484,3.2734}, // 3
{2267.7366,2439.3997,3.2734}, // 4
{2286.3911,2434.0715,3.2734}, // 5
{2302.9141,2441.9189,3.2734}, // 6
{2265.5151,2494.8433,-0.3329}, // 7
{2300.1218,2483.3733,-7.4531}, // 8
{2281.1760,2480.1216,-7.4531}, // 9
{2251.8474,2473.7490,-7.4531}, // 10
{2227.2383,2460.1196,-7.4531}, // 11
{2250.4229,2440.2544,-7.4531}, // 12
{2293.2231,2438.4878,-7.4531}, // 13
{2301.3645,2452.4045,-7.4531} // 14
};

// Quarry derby cars:
new Float:qderbycars[15][4] = {
{605.7057,815.2199,-43.1692,350.9785}, // 0
{609.4918,814.6188,-43.1692,350.9785}, // 1
{613.3760,814.0021,-43.1692,350.9785}, // 2
{616.5115,813.5043,-43.1692,350.9785}, // 3
{619.8624,812.9723,-43.1691,350.9785}, // 4
{622.9971,812.4746,-43.1691,350.9785}, // 5
{678.2766,922.8008,-41.0451,115.3092}, // 6
{680.1019,918.9395,-41.0066,115.3092}, // 7
{681.3400,916.3724,-40.6739,115.2029}, // 8
{682.7889,913.2912,-40.3585,115.2062}, // 9
{491.2690,912.7574,-30.6622,248.8228}, // 10
{489.9630,909.3635,-30.6003,248.8228}, // 11
{488.5172,905.6060,-30.5318,248.8228}, // 12
{488.1009,902.4600,-30.4778,262.3300}, // 13
{487.7645,899.9181,-30.4341,262.3300} // 14
};

// Karts:
new Float:kartspawns[15][4] = {
{-1366.1909,906.8451,1040.5919,280.3004}, // 0
{-1366.4854,908.3992,1040.2843,280.3004}, // 1
{-1366.8508,910.3288,1039.9022,280.3004}, // 2
{-1367.2168,912.2613,1039.5195,280.3004}, // 3
{-1367.7562,915.1094,1038.9557,280.3004}, // 4
{-1368.4265,918.6667,1038.4503,280.3231}, // 5
{-1368.8036,920.6827,1038.1428,280.3231}, // 6
{-1369.1410,922.4866,1037.8677,280.3231}, // 7
{-1372.5338,921.9490,1037.9705,277.8816}, // 8
{-1372.2379,919.8677,1038.2872,277.8816}, // 9
{-1371.9086,917.5515,1038.6396,277.8816}, // 10
{-1371.6196,915.5192,1038.9486,277.8816}, // 11
{-1371.2595,912.9866,1039.3340,277.8816}, // 12
{-1371.0453,911.4792,1039.5632,277.8816}, // 13
{-1370.6086,908.9531,1040.1785,275.7079} // 14
};

new Float:nrgspawns[15][4] = {
{-1436.5146,-595.6609,1055.5591,86.0952},
{-1436.4534,-594.7911,1055.4529,86.1336},
{-1436.3988,-594.0178,1055.3585,86.1336},
{-1436.3256,-592.9784,1055.2316,86.1336},
{-1436.2520,-591.9318,1055.1398,86.1124},
{-1436.1643,-590.6272,1055.0952,86.1436},
{-1436.1060,-589.7750,1055.0508,86.1436},
{-1436.0160,-588.4620,1054.9822,86.1436},
{-1435.9694,-587.7808,1054.9465,86.1436},
{-1435.9060,-586.8561,1054.8982,86.1436},
{-1435.8304,-586.0049,1054.8535,85.9079},
{-1435.7190,-584.4737,1054.7749,85.9079},
{-1435.6482,-583.4991,1054.7249,85.9079},
{-1435.5737,-582.4772,1054.6724,85.9079},
{-1435.4778,-581.1537,1054.5422,85.8982}
};

// Kartrace checkpoints:
new Float:kcps[5][3] = {
{-1262.4230,1028.3113,1039.6948},
{-1433.8792,1083.7178,1039.0344},
{-1540.4967,1004.6923,1039.1409},
{-1392.7269,914.2321,1039.8306},
{-1392.7269,914.2321,1039.8306}
};

new Float:srcps[10][3] = {
{-1515.0345,-646.2552,1049.8767},
{-1379.9943,-743.5076,1051.6895},
{-1373.9252,-665.4581,1055.8362},
{-1477.3721,-616.7951,1053.4919},
{-1437.9470,-669.4881,1053.0645},
{-1382.3152,-722.2056,1055.6273},
{-1335.7629,-637.1422,1054.2230},
{-1386.6233,-589.4922,1056.3871},
{-1421.6000,-588.1021,1055.8623},
{-1421.6000,-588.1021,1055.8623}
};


#if defined FILTERSCRIPT

public OnFilterScriptInit()
{

    TimeTimer = SetTimer("TimeUpdate",1000,1);

    HClock = TextDrawCreate(547, 40, "--:--");
    TextDrawLetterSize(HClock, 0.5, 1.5);
    TextDrawFont(HClock, 2);
    TextDrawSetShadow(HClock, 2);
    TextDrawSetOutline(HClock,2);

    HClock2 = TextDrawCreate(607, 40, "--");
    TextDrawLetterSize(HClock2, 0.4, 1.1);
    TextDrawFont(HClock2, 2);
    TextDrawSetShadow(HClock2, 2);
    TextDrawSetOutline(HClock2,2);

    HClock3 = TextDrawCreate(520, 105, "--/--/----");
    TextDrawLetterSize(HClock3, 0.4, 1.1);
    TextDrawFont(HClock3, 2);
    TextDrawSetShadow(HClock3, 2);
    TextDrawSetOutline(HClock3,2);
    
	SetTimer("load",2000,0);
	return 1;
}

public OnFilterScriptExit()
{
    KillTimer(TimeTimer);
    TextDrawDestroy(HClock);
    TextDrawDestroy(HClock2);
    TextDrawDestroy(HClock3);
    Destroybloodrings();
    Destroyqbloodrings();
    DestroyKarts();
    DestroyNrgs();
	return 1;
}

#endif

public OnGameModeInit()
{
	SetTimer("load",2000,0);
	return 1;
}

public OnGameModeExit()
{
    Destroybloodrings();
    Destroyqbloodrings();
    DestroyKarts();
    DestroyNrgs();
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	return 1;
}

public OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnPlayerConnect(playerid)
{
	playerinminigame[playerid] = 0; // Checks if a player is in a minigame
	playercarid[playerid] = -1; // Car that player currently is in, used to check whether the player is in a derby/race car

	playerinderby[playerid] = 0; // Derby
	playerinbloodring[playerid] = -1;

	playerintdm[playerid] = 0; // TeamDM

	playerindm[playerid] = 0; // LVDM

	playerinqderby[playerid] = 0; // Quarry Derby
	playerinqbloodring[playerid] = -1;

	playerinbox[playerid] = 0; // Boxing Fight

	playerinkartrace[playerid] = 0; // Kart Race
	playerinkart[playerid] = -1;
	currentcheckpoint[playerid] = 0;
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new string[256];
	if(playerinderby[playerid] == 1)
	{
	    new DerbyPlayerName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, DerbyPlayerName, sizeof(DerbyPlayerName));
		format(string, sizeof(string), "%s беше изхвърлен от дерби, ранк: %d", DerbyPlayerName, derbyrank);
		SendClientMessageToAll(0x33AA33AA, string);
		playerinderby[playerid] = 0;
		playerinminigame[playerid] = 0;
		bloodringfull[playerinbloodring[playerid]] = 0;
		playerinbloodring[playerid] = -1;
		if(derbyrank <= 2)
		{
			for(new i=0; i<MAX_PLAYERS; i++)
			{
				if (IsPlayerConnected(i) && playerinderby[i] == 1)
				{
				    new winnername[256];
					GetPlayerName(i,winnername, sizeof(winnername));
					RewardCalc(i,10000,100000);
					format(string, sizeof(string), "%s спечели дерби с $%d", winnername, reward);
					SendClientMessageToAll(0x33AA33AA, string);
					GivePlayerMoney(i,reward);
					playerinderby[i] = 0;
					playerinminigame[i] = 0;
					SetPlayerVirtualWorld(i,0);
					SetPlayerInterior(playerid, 0);
					SetPlayerPos(i, spawnX, spawnY, spawnZ);
				}
			}
		    derbyplaying = 0;
		    derbyrank = 0;
		    derbyon = 0;
		    KillTimer(dtimer);
	    	Respawnbloodrings();
	    	return 1;
		}
		derbyrank--;
	} else if(playerintdm[playerid] == 1) {
	    new tdmPlayerName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, tdmPlayerName, sizeof(tdmPlayerName));
	    if(GetPlayerColor(playerid) == 0x0000BBAA)
	    {
			format(string, sizeof(string), "%s беше изхвърлен от Team-DM, отбор син.", tdmPlayerName);
			blueplayers = blueplayers-1;
		} else {
		    format(string, sizeof(string), "%s беше изхвърлен от Team-DM, отбор червен.", tdmPlayerName);
		    redplayers = redplayers-1;
  		}
		SendClientMessageToAll(0x33AA33AA, string);
		playerintdm[playerid] = 0;
		playerinminigame[playerid] = 0;
		if(tdmrank == 0)
		{
		    tdmplaying = 0;
		    tdmrank = 0;
		    tdmon = 0;
		    KillTimer(tdmtimer);
		    return 1;
		}
		if((blueplayers == 0 || redplayers == 0) && tdmplaying == 1)
		{
		    if(blueplayers == 0)
		    {
		    	format(string, sizeof(string), "Червения отбор спечелиха Team-DM.");
	   		} else if(redplayers == 0)
	   		{
	   		    format(string, sizeof(string), "Синия отбор спечелиха Team-DM.");
	   		}
			SendClientMessageToAll(0x33AA33AA, string);
			for(new i=0; i<MAX_PLAYERS; i++)
			{
				if (IsPlayerConnected(i) && playerintdm[i] == 1)
				{
					playerintdm[i] = 0;
					playerinminigame[i] = 0;
					SetPlayerVirtualWorld(i,0);
					SetPlayerInterior(playerid, 0);
					SetPlayerColor(i,oldplayercolor[i]);
					SetPlayerPos(i, spawnX, spawnY, spawnZ);
				}
			}
		    tdmplaying = 0;
		    tdmrank = 0;
		    tdmon = 0;
		    KillTimer(tdmtimer);
		    return 1;
		}
		tdmrank--;
	} else if(playerindm[playerid] == 1) {
	    new dmPlayerName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, dmPlayerName, sizeof(dmPlayerName));
		format(string, sizeof(string), "%s беше изхвърлен от LVDM, ранк: %d", dmPlayerName, dmrank);
		SendClientMessageToAll(0x33AA33AA, string);
		playerindm[playerid] = 0;
		playerinminigame[playerid] = 0;
		if(dmrank <= 2)
		{
			for(new i=0; i<MAX_PLAYERS; i++)
			{
				if (IsPlayerConnected(i) && playerindm[i] == 1)
				{
				    new dmwinnername[256];
					GetPlayerName(i,dmwinnername, sizeof(dmwinnername));
					RewardCalc(i,10000,100000);
					format(string, sizeof(string), "%s спечели LVDM за $%d", dmwinnername, reward);
					SendClientMessageToAll(0x33AA33AA, string);
					GivePlayerMoney(i,reward);
					playerindm[i] = 0;
					playerinminigame[i] = 0;
					SetPlayerVirtualWorld(i,0);
					SetPlayerInterior(playerid, 0);
					SetPlayerPos(i, spawnX, spawnY, spawnZ);
				}
			}
		    dmplaying = 0;
		    dmrank = 0;
		    dmon = 0;
		    KillTimer(dmtimer);
		    return 1;
		}
		dmrank--;
	} else if(playerinqderby[playerid] == 1)	{
	    new DerbyPlayerName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, DerbyPlayerName, sizeof(DerbyPlayerName));
		format(string, sizeof(string), "%s беше изхвърлен от кариерното дерби, ранк: %d", DerbyPlayerName, qderbyrank);
		SendClientMessageToAll(0x33AA33AA, string);
		playerinqderby[playerid] = 0;
		playerinminigame[playerid] = 0;
		qbloodringfull[playerinqbloodring[playerid]] = 0;
		playerinqbloodring[playerid] = -1;
		if(qderbyrank <= 2)
		{
			for(new i=0; i<MAX_PLAYERS; i++)
			{
				if (IsPlayerConnected(i) && playerinqderby[i] == 1)
				{
				    new winnername[256];
					GetPlayerName(i,winnername, sizeof(winnername));
					RewardCalc(i,10000,100000);
					format(string, sizeof(string), "%s спечели кариерното дерби за $%d", winnername, reward);
					SendClientMessageToAll(0x33AA33AA, string);
					GivePlayerMoney(i,reward);
					playerinqderby[i] = 0;
					playerinminigame[i] = 0;
					SetPlayerVirtualWorld(i,0);
					SetPlayerInterior(playerid, 0);
					SetPlayerPos(i, spawnX, spawnY, spawnZ);
				}
			}
		    qderbyplaying = 0;
		    qderbyrank = 0;
		    qderbyon = 0;
		    KillTimer(qdtimer);
	    	Respawnqbloodrings();
	    	return 1;
		}
		qderbyrank--;
	} else if(playerinbox[playerid] == 1) {
	    new boxPlayerName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, boxPlayerName, sizeof(boxPlayerName));
		format(string, sizeof(string), "%s беше изхвърлен от бокс битката, ранк: %d", boxPlayerName, boxrank);
		SendClientMessageToAll(0x33AA33AA, string);
		playerinbox[playerid] = 0;
		playerinminigame[playerid] = 0;
		if(boxrank <= 2)
		{
			for(new i=0; i<MAX_PLAYERS; i++)
			{
				if (IsPlayerConnected(i) && playerinbox[i] == 1)
				{
				    new boxwinnername[256];
					GetPlayerName(i,boxwinnername, sizeof(boxwinnername));
					RewardCalc(i,10000,100000);
					format(string, sizeof(string), "%s спечели бокс битката за $%d", boxwinnername, reward);
					SendClientMessageToAll(0x33AA33AA, string);
					GivePlayerMoney(i,reward);
					playerinbox[i] = 0;
					playerinminigame[i] = 0;
					SetPlayerVirtualWorld(i,0);
					SetPlayerInterior(playerid, 0);
					SetPlayerPos(i, spawnX, spawnY, spawnZ);
				}
			}
		    boxplaying = 0;
		    boxrank = 0;
		    boxon = 0;
		    KillTimer(boxtimer);
		    return 1;
		}
		boxrank--;
	} else if(playerinsd[playerid] == 1) {
	    new SkydivePlayerName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, SkydivePlayerName, sizeof(SkydivePlayerName));
		format(string, sizeof(string), "%s беше изхвърлен от летенето с парашути.", SkydivePlayerName);
		SendClientMessageToAll(0x33AA33AA, string);
		playerinsd[playerid] = 0;
		playerinminigame[playerid] = 0;
		if(sdrank <= 1)
		{
			for(new i=0; i<MAX_PLAYERS; i++)
			{
				if (IsPlayerConnected(i) && playerinsd[i] == 1)
				{
					playerinsd[i] = 0;
					playerinminigame[i] = 0;
					SetPlayerVirtualWorld(i,0);
					SetPlayerInterior(playerid, 0);
					SetPlayerPos(i, spawnX, spawnY, spawnZ);
				}
			}
		    sdplaying = 0;
		    sdrank = 0;
		    sdon = 0;
		    sdfirst = 0;
		    KillTimer(sdtimer);
	    	return 1;
		}
		sdrank--;
	} else if(playerinkartrace[playerid] == 1) {
	    new KartPlayerName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, KartPlayerName, sizeof(KartPlayerName));
		format(string, sizeof(string), "%s беше изхвърлен от съзтезанието със карт.", KartPlayerName);
		SendClientMessageToAll(0x33AA33AA, string);
		playerinkartrace[playerid] = 0;
		playerinminigame[playerid] = 0;
		kartfull[playerinkart[playerid]] = 0;
		playerinkart[playerid] = -1;
		if(kartrank <= 1)
		{
			for(new i=0; i<MAX_PLAYERS; i++)
			{
				if (IsPlayerConnected(i) && playerinkartrace[i] == 1)
				{
					playerinkartrace[i] = 0;
					playerinminigame[i] = 0;
					SetPlayerVirtualWorld(i,0);
					SetPlayerInterior(playerid, 0);
					SetPlayerPos(i, spawnX, spawnY, spawnZ);
				}
			}
		    kartplaying = 0;
		    kartrank = 0;
		    karton = 0;
		    KillTimer(krttimer);
	    	RespawnKarts();
	    	return 1;
		}
		kartrank--;
	} else if(playerinsr[playerid] == 1) {
	    new SrPlayerName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, SrPlayerName, sizeof(SrPlayerName));
		format(string, sizeof(string), "%s беше изхвърлен от стадиона за съзтезание.", SrPlayerName);
		SendClientMessageToAll(0x33AA33AA, string);
		playerinsr[playerid] = 0;
		playerinminigame[playerid] = 0;
		nrgfull[playerinnrg[playerid]] = 0;
		playerinnrg[playerid] = -1;
		if(kartrank <= 1)
		{
			for(new i=0; i<MAX_PLAYERS; i++)
			{
				if (IsPlayerConnected(i) && playerinsr[i] == 1)
				{
					playerinsr[i] = 0;
					playerinminigame[i] = 0;
					SetPlayerVirtualWorld(i,0);
					SetPlayerInterior(playerid, 0);
					SetPlayerPos(i, spawnX, spawnY, spawnZ);
				}
			}
		    kartplaying = 0;
		    kartrank = 0;
		    karton = 0;
		    KillTimer(srtimer);
	    	RespawnNrgs();
	    	return 1;
		}
		srrank--;
	}
	return 1;
}

public OnPlayerSpawn(playerid)
{
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    new string[256];
	if(playerinderby[playerid] == 1)
	{
	    new DerbyPlayerName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, DerbyPlayerName, sizeof(DerbyPlayerName));
		format(string, sizeof(string), "%s беше изхвърлен от дерби, ранк: %d", DerbyPlayerName, derbyrank);
		SendClientMessageToAll(0x33AA33AA, string);
		playerinderby[playerid] = 0;
		playerinminigame[playerid] = 0;
		bloodringfull[playerinbloodring[playerid]] = 0;
		playerinbloodring[playerid] = -1;
		if(derbyrank <= 2)
		{
			for(new i=0; i<MAX_PLAYERS; i++)
			{
				if (IsPlayerConnected(i) && playerinderby[i] == 1)
				{
				    new winnername[256];
					GetPlayerName(i,winnername, sizeof(winnername));
					RewardCalc(i,10000,100000);
					format(string, sizeof(string), "%s спечели дерби за $%d", winnername, reward);
					SendClientMessageToAll(0x33AA33AA, string);
					GivePlayerMoney(i,reward);
					playerinderby[i] = 0;
					playerinminigame[i] = 0;
					SetPlayerVirtualWorld(i,0);
					SetPlayerInterior(playerid, 0);
					SetPlayerPos(i, spawnX, spawnY, spawnZ);
				}
			}
		    derbyplaying = 0;
		    derbyrank = 0;
		    derbyon = 0;
		    KillTimer(dtimer);
	    	Respawnbloodrings();
	    	return 1;
		}
		derbyrank--;
	} else if(playerintdm[playerid] == 1) {
	    new tdmPlayerName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, tdmPlayerName, sizeof(tdmPlayerName));
	    if(GetPlayerColor(playerid) == 0x0000BBAA)
	    {
			format(string, sizeof(string), "%s беше изхвърлен от team DM, отбор син", tdmPlayerName);
			blueplayers = blueplayers-1;
		} else {
		    format(string, sizeof(string), "%s беше изхвърлен от team DM, отбор червен", tdmPlayerName);
		    redplayers = redplayers-1;
  		}
		SendClientMessageToAll(0x33AA33AA, string);
		playerintdm[playerid] = 0;
		playerinminigame[playerid] = 0;
		if(tdmrank == 0)
		{
		    tdmplaying = 0;
		    tdmrank = 0;
		    tdmon = 0;
		    KillTimer(tdmtimer);
		    return 1;
		}
		if((blueplayers == 0 || redplayers == 0) && tdmplaying == 1)
		{
		    if(blueplayers == 0)
		    {
		    	format(string, sizeof(string), "Червения отбор спечели team DM");
	   		} else if(redplayers == 0)
	   		{
	   		    format(string, sizeof(string), "Синия отбор спечели team DM");
	   		}
			SendClientMessageToAll(0x33AA33AA, string);
			for(new i=0; i<MAX_PLAYERS; i++)
			{
				if (IsPlayerConnected(i) && playerintdm[i] == 1)
				{
					playerintdm[i] = 0;
					playerinminigame[i] = 0;
					SetPlayerVirtualWorld(i,0);
					SetPlayerInterior(playerid, 0);
					SetPlayerColor(i,oldplayercolor[i]);
					SetPlayerPos(i, spawnX, spawnY, spawnZ);
				}
			}
		    tdmplaying = 0;
		    tdmrank = 0;
		    tdmon = 0;
		    KillTimer(tdmtimer);
		    return 1;
		}
		tdmrank--;
	} else if(playerindm[playerid] == 1) {
	    new dmPlayerName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, dmPlayerName, sizeof(dmPlayerName));
		format(string, sizeof(string), "%s беше изхвърлен от LVDM, ранк: %d", dmPlayerName, dmrank);
		SendClientMessageToAll(0x33AA33AA, string);
		playerindm[playerid] = 0;
		playerinminigame[playerid] = 0;
		if(dmrank <= 2)
		{
			for(new i=0; i<MAX_PLAYERS; i++)
			{
				if (IsPlayerConnected(i) && playerindm[i] == 1)
				{
				    new dmwinnername[256];
					GetPlayerName(i,dmwinnername, sizeof(dmwinnername));
					RewardCalc(i,10000,100000);
					format(string, sizeof(string), "%s спечели LVDM за $%d", dmwinnername, reward);
					SendClientMessageToAll(0x33AA33AA, string);
					GivePlayerMoney(i,reward);
					playerindm[i] = 0;
					playerinminigame[i] = 0;
					SetPlayerVirtualWorld(i,0);
					SetPlayerInterior(playerid, 0);
					SetPlayerPos(i, spawnX, spawnY, spawnZ);
				}
			}
		    dmplaying = 0;
		    dmrank = 0;
		    dmon = 0;
		    KillTimer(dmtimer);
		    return 1;
		}
		dmrank--;
	} else if(playerinqderby[playerid] == 1)	{
	    new DerbyPlayerName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, DerbyPlayerName, sizeof(DerbyPlayerName));
		format(string, sizeof(string), "%s беше изхвърлен от кариерното дерби, ранк: %d", DerbyPlayerName, qderbyrank);
		SendClientMessageToAll(0x33AA33AA, string);
		playerinqderby[playerid] = 0;
		playerinminigame[playerid] = 0;
		qbloodringfull[playerinqbloodring[playerid]] = 0;
		playerinqbloodring[playerid] = -1;
		if(qderbyrank <= 2)
		{
			for(new i=0; i<MAX_PLAYERS; i++)
			{
				if (IsPlayerConnected(i) && playerinqderby[i] == 1)
				{
				    new winnername[256];
					GetPlayerName(i,winnername, sizeof(winnername));
					RewardCalc(i,10000,100000);
					format(string, sizeof(string), "%s спечели кариерното дерби за $%d", winnername, reward);
					SendClientMessageToAll(0x33AA33AA, string);
					GivePlayerMoney(i,reward);
					playerinqderby[i] = 0;
					playerinminigame[i] = 0;
					SetPlayerVirtualWorld(i,0);
					SetPlayerInterior(playerid, 0);
					SetPlayerPos(i, spawnX, spawnY, spawnZ);
				}
			}
		    qderbyplaying = 0;
		    qderbyrank = 0;
		    qderbyon = 0;
		    KillTimer(qdtimer);
	    	Respawnqbloodrings();
	    	return 1;
		}
		qderbyrank--;
	} else if(playerinbox[playerid] == 1) {
	    new boxPlayerName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, boxPlayerName, sizeof(boxPlayerName));
		format(string, sizeof(string), "%s беше изхвърлен от бокс битката, ранк: %d", boxPlayerName, boxrank);
		SendClientMessageToAll(0x33AA33AA, string);
		playerinbox[playerid] = 0;
		playerinminigame[playerid] = 0;
		if(boxrank <= 2)
		{
			for(new i=0; i<MAX_PLAYERS; i++)
			{
				if (IsPlayerConnected(i) && playerinbox[i] == 1)
				{
				    new boxwinnername[256];
					GetPlayerName(i,boxwinnername, sizeof(boxwinnername));
					RewardCalc(i,10000,100000);
					format(string, sizeof(string), "%s спечели бокс битката за $%d", boxwinnername, reward);
					SendClientMessageToAll(0x33AA33AA, string);
					GivePlayerMoney(i,reward);
					playerinbox[i] = 0;
					playerinminigame[i] = 0;
					SetPlayerVirtualWorld(i,0);
					SetPlayerInterior(playerid, 0);
					SetPlayerPos(i, spawnX, spawnY, spawnZ);
				}
			}
		    boxplaying = 0;
		    boxrank = 0;
		    boxon = 0;
		    KillTimer(boxtimer);
		    return 1;
		}
		boxrank--;
	} else if(playerinsd[playerid] == 1) {
	    new SkydivePlayerName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, SkydivePlayerName, sizeof(SkydivePlayerName));
		format(string, sizeof(string), "%s беше изхвърлен от съзтезанието с парашути", SkydivePlayerName);
		SendClientMessageToAll(0x33AA33AA, string);
		playerinsd[playerid] = 0;
		playerinminigame[playerid] = 0;
		if(sdrank <= 1)
		{
			for(new i=0; i<MAX_PLAYERS; i++)
			{
				if (IsPlayerConnected(i) && playerinsd[i] == 1)
				{
					playerinsd[i] = 0;
					playerinminigame[i] = 0;
					SetPlayerVirtualWorld(i,0);
					SetPlayerInterior(playerid, 0);
					SetPlayerPos(i, spawnX, spawnY, spawnZ);
				}
			}
		    sdplaying = 0;
		    sdrank = 0;
		    sdon = 0;
		    sdfirst = 0;
		    KillTimer(sdtimer);
	    	return 1;
		}
		sdrank--;
	} else if(playerinkartrace[playerid] == 1) {
	    new KartPlayerName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, KartPlayerName, sizeof(KartPlayerName));
		format(string, sizeof(string), "%s беше изхвърлен от съзтезанието с карт", KartPlayerName);
		SendClientMessageToAll(0x33AA33AA, string);
		playerinkartrace[playerid] = 0;
		playerinminigame[playerid] = 0;
		kartfull[playerinkart[playerid]] = 0;
		playerinkart[playerid] = -1;
		if(kartrank <= 1)
		{
			for(new i=0; i<MAX_PLAYERS; i++)
			{
				if (IsPlayerConnected(i) && playerinkartrace[i] == 1)
				{
					playerinkartrace[i] = 0;
					playerinminigame[i] = 0;
					SetPlayerVirtualWorld(i,0);
					SetPlayerInterior(playerid, 0);
					SetPlayerPos(i, spawnX, spawnY, spawnZ);
				}
			}
		    kartplaying = 0;
		    kartrank = 0;
		    karton = 0;
		    KillTimer(krttimer);
	    	RespawnKarts();
	    	return 1;
		}
		kartrank--;
	} else if(playerinsr[playerid] == 1) {
	    new SrPlayerName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid, SrPlayerName, sizeof(SrPlayerName));
		format(string, sizeof(string), "%s беше изхвърлен от съзтезанието на стадиона", SrPlayerName);
		SendClientMessageToAll(0x33AA33AA, string);
		playerinsr[playerid] = 0;
		playerinminigame[playerid] = 0;
		nrgfull[playerinnrg[playerid]] = 0;
		playerinnrg[playerid] = -1;
		if(kartrank <= 1)
		{
			for(new i=0; i<MAX_PLAYERS; i++)
			{
				if (IsPlayerConnected(i) && playerinsr[i] == 1)
				{
					playerinsr[i] = 0;
					playerinminigame[i] = 0;
					SetPlayerVirtualWorld(i,0);
					SetPlayerInterior(playerid, 0);
					SetPlayerPos(i, spawnX, spawnY, spawnZ);
				}
			}
		    srplaying = 0;
		    srrank = 0;
		    sron = 0;
		    KillTimer(srtimer);
	    	RespawnNrgs();
	    	return 1;
		}
		srrank--;
	}
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerPrivmsg(playerid, recieverid, text[])
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	new cmd[256];
	new idx;
	new string[256];
	new tmp[256];
	cmd = strtok(cmdtext, idx);

	if(strcmp(cmd, "/mark", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}

	if(strcmp(cmd, "/gotomark", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}

	if(strcmp(cmd, "/jetpack", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}

	if(strcmp(cmd, "/setcarpj", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}

	if(strcmp(cmd, "/nos", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}

	if(strcmp(cmd, "/hyd", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}

	if(strcmp(cmd, "/flip", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}

	if(strcmp(cmd, "/invisible", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}

	if(strcmp(cmd, "/ramping", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/dive", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/spec", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/freeze", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/unfreeze", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/fartbomb", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/blowup", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/slap", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/gotoid", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/akill", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/destroycar", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/respawncars", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/gethere", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/setworld", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/goto", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/intmenu", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/editorcmd", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/killall", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}
	
	if(strcmp(cmd, "/getall", true) == 0)
	{
	    if(playerinminigame[playerid])
	    {
	    	SendClientMessage(playerid, 0x33AA33AA, "Не можеш да използваш тази команда когато си в игра!");
		    return 1;
	    }
	}

	if(strcmp(cmd, "/minigames", true) == 0)
	{
	    SendClientMessage(playerid, 0x33AA33AA, "______________________________________________________________________________");
	    SendClientMessage(playerid, 0xFF0000FF, "/derby /teamdm /lvdm /qderby /boxing /sdive /kartrace /srace");
	    SendClientMessage(playerid, 0xFF0000FF, "Type /info for more information about seperate minigames.");
	    SendClientMessage(playerid, 0x33AA33AA, "______________________________________________________________________________");
	    return 1;
	}

	if(strcmp(cmd, "/info", true) == 0)
	{
	    tmp = strtok(cmdtext, idx);
	    if(!strlen(tmp))
		{
		    SendClientMessage(playerid,0xFFFF00AA, "Usage: /info [minigame command]");
		    SendClientMessage(playerid,0xFFFF00AA, "Minigame commands: derby teamdm lvdm qderby boxing sdive kartrace srace");
		    return 1;
  		}

  		SendClientMessage(playerid, 0x33AA33AA, "______________________________________________________________________________");
	    SendClientMessage(playerid, 0xFF0000FF, " ");
  		if(strcmp(tmp, "derby", true) == 0){
			SendClientMessage(playerid, 0xFF0000FF, "Derby: Опустошително дерби в Bloodbowl.");
			SendClientMessage(playerid, 0xFF0000FF, "Целта ти е да унищожиш всичките си противници и да останеш с здрава кола.");
  		}else if(strcmp(tmp, "teamdm", true) == 0){
  			SendClientMessage(playerid, 0xFF0000FF, "TeamDM: Битка между два отбора (син и червен) в Area51.");
			SendClientMessage(playerid, 0xFF0000FF, "Целта ви е да победите всички от противниковия отбор.");
  		}else if(strcmp(tmp, "lvdm", true) == 0){
  			SendClientMessage(playerid, 0xFF0000FF, "Lvdm: Битка до LVPD.");
			SendClientMessage(playerid, 0xFF0000FF, "Целта ви е да победите всички играчи и да останете жив.");
  		}else if(strcmp(tmp, "qderby", true) == 0){
  			SendClientMessage(playerid, 0xFF0000FF, "QDerby: Опустошитено дерби с кариера.");
			SendClientMessage(playerid, 0xFF0000FF, "Целта ти е да унищожиш всичките си противници и да останеш с здрава кола.");
  		}else if(strcmp(tmp, "boxing", true) == 0){
  			SendClientMessage(playerid, 0xFF0000FF, "Boxing: Битка без оръжия,а само с ръце.");
			SendClientMessage(playerid, 0xFF0000FF, "Целта ви е да победите всички играчи и да останете жив.");
  		}else if(strcmp(tmp, "sdive", true) == 0){
  			SendClientMessage(playerid, 0xFF0000FF, "SDive: Скачане с парашут.");
			SendClientMessage(playerid, 0xFF0000FF, "Целта ви е да скочите от голяма сграда и да паднете на червен маркер.");
  		}else if(strcmp(tmp, "kartrace", true) == 0){
  			SendClientMessage(playerid, 0xFF0000FF, "Kartrace: Съзтезание с картове около Bloodbowl.");
			SendClientMessage(playerid, 0xFF0000FF, "Целта ви е да изпреварите всички играчи за 2 обиколки и да завършите първи.");
  		}else if(strcmp(tmp, "srace", true) == 0){
  			SendClientMessage(playerid, 0xFF0000FF, "SRace: Съзтезание около Vice Stadium, със NRG's.");
			SendClientMessage(playerid, 0xFF0000FF, "Целта ви е да изпреварите всички играчи за 1 обиколка и да завършите първи.");
  		}
	    SendClientMessage(playerid, 0x33AA33AA, "______________________________________________________________________________");
	    return 1;
	}

	if(strcmp(cmd, "/derby", true) == 0)
	{
	    if(derbyplaying == 1)
	    {
	        SendClientMessage(playerid, 0xB4B5B7AA, "Дерби е стартирано");
	        return 1;
	    }
	    if(playerinminigame[playerid] == 1)
	    {
	        SendClientMessage(playerid, 0xB4B5B7AA, "Ти си в игра");
	        return 1;
	    }
		new pname[256];
		GetPlayerName(playerid, pname, 256);
	    if(derbyon == 0)
	    {
	        derbyon = 1;
	        playerinminigame[playerid] = 1;
	        playerinderby[playerid] = 1;
	        derbyrank = 1;
	        SetPlayerInterior(playerid,15);
	        SetPlayerVirtualWorld(playerid,7);
	        SetVehicleVirtualWorld(bloodring[0],7);
	        bloodringfull[0] = 1;
	        PutPlayerInVehicle(playerid, bloodring[0], 0);
	        playerinbloodring[playerid] = 0;
	        TogglePlayerControllable(playerid, 0);
	        startvar[0] = 1;
	        dtimer = SetTimer("StartDerby", 60000, 0);
         	format(string, sizeof(string), "%s стартира дерби,имаш 1 минута да използваш /derby и да влезеш", pname);//
			SendClientMessageToAll(0x33AA33AA,string);
			return 1;
	    } else if(derbyon == 1 && derbyrank < 15) {
	        playerinminigame[playerid] = 1;
	        playerinderby[playerid] = 1;
	        derbyrank++;
	        SetPlayerInterior(playerid,15);
	        for(new i=0; i<15; i++)
    		{
	    		if(bloodringfull[i] == 0)
	    		{
	    		    SetPlayerVirtualWorld(playerid,7);
	    		    SetVehicleVirtualWorld(bloodring[i],7);
	    		    bloodringfull[i] = 1;
	    		    PutPlayerInVehicle(playerid, bloodring[i], 0);
	    		    TogglePlayerControllable(playerid, 0);
	    		    playerinbloodring[playerid] = i;
	    		    format(string, sizeof(string), "%s влезе в дерби", pname);//
					SendClientMessageToAll(0x33AA33AA,string);
					return 1;
	    		}
			}
	    } else if(derbyon == 1 && derbyrank >= 15) {
		    format(string, sizeof(string), "Местата за дерби са заети,изчакайте следващия рунд", pname);//
		    SendClientMessage(playerid,0x33AA33AA,string);
		    return 1;
	    }
	}

	if(strcmp(cmd, "/teamdm", true) == 0)
	{
	    if(tdmplaying == 1)
	    {
	        SendClientMessage(playerid, 0xB4B5B7AA, "Team DM е стартирано");
	        return 1;
	    }
	    if(playerinminigame[playerid] == 1)
	    {
	        SendClientMessage(playerid, 0xB4B5B7AA, "Ти си в игра");
	        return 1;
	    }
		new pname[256];
		GetPlayerName(playerid, pname, 256);
	    if(tdmon == 0)
	    {
	        tdmon = 1;
	        playerintdm[playerid] = 1;
	        playerinminigame[playerid] = 1;
	        tdmrank = 1;
	        TogglePlayerControllable(playerid, 0);
	        SetPlayerInterior(playerid,0);
	        SetPlayerVirtualWorld(playerid,7);
	        SetPlayerPos(playerid,208.8376,1863.5388,13.1406);
	        ResetPlayerWeapons(playerid);
	        GivePlayerWeapon(playerid,26,500);
	        GivePlayerWeapon(playerid,31,500);
	        GivePlayerWeapon(playerid,32,500);
	        SetPlayerHealth(playerid,100);
	        SetPlayerArmour(playerid,100);
	        oldplayercolor[playerid] = GetPlayerColor(playerid);
	        SetPlayerColor(playerid,0x0000BBAA);// BLUE
	        blueplayers = 1;
	        redplayers = 0;
	        tdmcolor = 1;
	        startvar[1] = 1;
	        tdmtimer = SetTimer("Starttdm", 60000, 0);
         	format(string, sizeof(string), "%s стартира team DM,отбор син,имаш 1 минута да напишеш /teamdm и да влезеш", pname);//
			SendClientMessageToAll(0x33AA33AA,string);
			return 1;
	    } else if(tdmon == 1 && tdmcolor == 1) {
	        playerintdm[playerid] = 1;
	        playerinminigame[playerid] = 1;
	        tdmrank++;
	        TogglePlayerControllable(playerid, 0);
	        SetPlayerInterior(playerid,0);
	        SetPlayerVirtualWorld(playerid,7);
	        SetPlayerPos(playerid,268.6240,1882.8805,-30.0938);
	        ResetPlayerWeapons(playerid);
	        GivePlayerWeapon(playerid,26,500);
	        GivePlayerWeapon(playerid,31,500);
	        GivePlayerWeapon(playerid,32,500);
	        SetPlayerHealth(playerid,100);
	        SetPlayerArmour(playerid,100);
	        oldplayercolor[playerid] = GetPlayerColor(playerid);
	        SetPlayerColor(playerid,0xAA3333AA);// RED
	        redplayers++;
	        tdmcolor = 0;
	        format(string, sizeof(string), "%s влезе в team DM, отбор червен", pname);//
			SendClientMessageToAll(0x33AA33AA,string);
			return 1;
	    } else if(tdmon == 1 && tdmcolor == 0) {
	        playerintdm[playerid] = 1;
	        playerinminigame[playerid] = 1;
	        tdmrank++;
	        TogglePlayerControllable(playerid, 0);
	        SetPlayerInterior(playerid,0);
	        SetPlayerVirtualWorld(playerid,7);
	        SetPlayerPos(playerid,208.8376,1863.5388,13.1406);
	        ResetPlayerWeapons(playerid);
	        GivePlayerWeapon(playerid,26,500);
	        GivePlayerWeapon(playerid,31,500);
	        GivePlayerWeapon(playerid,32,500);
	        SetPlayerHealth(playerid,100);
	        SetPlayerArmour(playerid,100);
	        oldplayercolor[playerid] = GetPlayerColor(playerid);
	        SetPlayerColor(playerid,0x0000BBAA);// BLUE
	        blueplayers++;
	        tdmcolor = 1;
	        format(string, sizeof(string), "%s влезе в team DM, отбор син", pname);//
			SendClientMessageToAll(0x33AA33AA,string);
			return 1;
	    }
	}
	if(strcmp(cmd, "/lvdm", true) == 0)
	{
	    if(dmplaying == 1)
	    {
	        SendClientMessage(playerid, 0xB4B5B7AA, "LVDM е стартирано");
	        return 1;
	    }
	    if(playerinminigame[playerid] == 1)
	    {
	        SendClientMessage(playerid, 0xB4B5B7AA, "Ти си в игра");
	        return 1;
	    }
		new pname[256];
		GetPlayerName(playerid, pname, 256);
	    if(dmon == 0)
	    {
	        dmon = 1;
	        playerindm[playerid] = 1;
   	        playerinminigame[playerid] = 1;
	        dmrank = 1;
	        TogglePlayerControllable(playerid, 0);
	        SetPlayerInterior(playerid,0);
	        SetPlayerVirtualWorld(playerid,7);
	        SetPlayerPos(playerid,lvdmspawns[0][0],lvdmspawns[0][1],lvdmspawns[0][2]);
	        ResetPlayerWeapons(playerid);
	        GivePlayerWeapon(playerid,26,500);
	        GivePlayerWeapon(playerid,32,500);
	        GivePlayerWeapon(playerid,31,500);
	        SetPlayerHealth(playerid,100);
	        SetPlayerArmour(playerid,100);
	        startvar[2] = 1;
	        dmtimer = SetTimer("Startdm", 60000, 0);
         	format(string, sizeof(string), "%s стартира LVD,имаш една минута да използваш /lvdm и да влезеш", pname);//
			SendClientMessageToAll(0x33AA33AA,string);
			return 1;
	    } else if(dmon == 1 && dmrank <= 15) {
	        playerindm[playerid] = 1;
	        TogglePlayerControllable(playerid, 0);
	        SetPlayerInterior(playerid,0);
	        SetPlayerVirtualWorld(playerid,7);
         	SetPlayerPos(playerid,lvdmspawns[dmrank][0],lvdmspawns[dmrank][1],lvdmspawns[dmrank][2]);
         	dmrank++;
	        ResetPlayerWeapons(playerid);
	        GivePlayerWeapon(playerid,26,500);
	        GivePlayerWeapon(playerid,32,500);
	        GivePlayerWeapon(playerid,31,500);
	        SetPlayerHealth(playerid,100);
	        SetPlayerArmour(playerid,100);
	        format(string, sizeof(string), "%s has joined the LVDM", pname);//
			SendClientMessageToAll(0x33AA33AA,string);
			return 1;
	    } else if(dmon == 1 && dmrank == 16) {
	        format(string, sizeof(string), "Местата за LVDM са заети,изчакайте за следващото LVDM");//
			SendClientMessage(playerid,0x33AA33AA,string);
	    }
	}

	if(strcmp(cmd, "/qderby", true) == 0)
	{
	    if(qderbyplaying == 1)
	    {
	        SendClientMessage(playerid, 0xB4B5B7AA, "Кариерното дерби е стартирано");
	        return 1;
	    }
	    if(playerinminigame[playerid] == 1)
	    {
	        SendClientMessage(playerid, 0xB4B5B7AA, "Ти си в игра");
	        return 1;
	    }
		new pname[256];
		GetPlayerName(playerid, pname, 256);
	    if(qderbyon == 0)
	    {
	        Respawnqbloodrings();
	        qderbyon = 1;
	        playerinminigame[playerid] = 1;
	        playerinqderby[playerid] = 1;
	        qderbyrank = 1;
	        SetPlayerInterior(playerid,0);
	        SetPlayerVirtualWorld(playerid,7);
	        SetVehicleVirtualWorld(qbloodring[0],7);
	        qbloodringfull[0] = 1;
	        PutPlayerInVehicle(playerid, qbloodring[0], 0);
	        playerinqbloodring[playerid] = 0;
	        TogglePlayerControllable(playerid, 0);
	        startvar[3] = 1;
	        qdtimer = SetTimer("StartqDerby", 60000, 0);
         	format(string, sizeof(string), "%s стартира кариерното дерби,имаш 1 минута да използваш /qderby и да влезеш", pname);//
			SendClientMessageToAll(0x33AA33AA,string);
			return 1;
	    } else if(qderbyon == 1 && qderbyrank < 15) {
	        playerinminigame[playerid] = 1;
	        playerinqderby[playerid] = 1;
	        qderbyrank++;
	        SetPlayerInterior(playerid,0);
	        for(new i=0; i<15; i++)
    		{
	    		if(qbloodringfull[i] == 0)
	    		{
	    		    SetPlayerVirtualWorld(playerid,7);
	    		    SetVehicleVirtualWorld(qbloodring[i],7);
	        		qbloodringfull[i] = 1;
	    		    PutPlayerInVehicle(playerid, qbloodring[i], 0);
	    		    TogglePlayerControllable(playerid, 0);
	    		    playerinqbloodring[playerid] = i;
	    		    format(string, sizeof(string), "%s влезе в кариерното дерби", pname);//
					SendClientMessageToAll(0x33AA33AA,string);
					return 1;
	    		}
			}
	    } else if(qderbyon == 1 && qderbyrank >= 15) {
		    format(string, sizeof(string), "Местата за кариерното дерби са заети,изчакайте следващия рунд", pname);//
		    SendClientMessage(playerid,0x33AA33AA,string);
		    return 1;
	    }
	}

	if(strcmp(cmd, "/boxing", true) == 0)
	{
	    if(boxplaying == 1)
	    {
	        SendClientMessage(playerid, 0xB4B5B7AA, "Бокс битката е стартирана");
	        return 1;
	    }
	    if(playerinminigame[playerid] == 1)
	    {
	        SendClientMessage(playerid, 0xB4B5B7AA, "Ти си в игра");
	        return 1;
	    }
		new pname[256];
		GetPlayerName(playerid, pname, 256);
	    if(boxon == 0)
	    {
	        boxon = 1;
	        playerinbox[playerid] = 1;
   	        playerinminigame[playerid] = 1;
	        boxrank = 1;
	        TogglePlayerControllable(playerid, 0);
	        SetPlayerInterior(playerid,0);
	        SetPlayerVirtualWorld(playerid,7);
	        SetPlayerPos(playerid,2496.479,-1678.357,6997.348);
	        ResetPlayerWeapons(playerid);
	        SetPlayerHealth(playerid,50);
	        startvar[4] = 1;
	        boxtimer = SetTimer("StartBox", 60000, 0);
         	format(string, sizeof(string), "%s стартира бокс битката,имаш 1 минути да използваш /boxing и да влезеш", pname);//
			SendClientMessageToAll(0x33AA33AA,string);
			return 1;
	    } else if(boxon == 1) {
	        playerinbox[playerid] = 1;
	        TogglePlayerControllable(playerid, 0);
	        SetPlayerInterior(playerid,0);
	        SetPlayerVirtualWorld(playerid,7);
         	SetPlayerPos(playerid,2496.479,-1678.357,6997.348);
         	boxrank++;
	        ResetPlayerWeapons(playerid);
	        SetPlayerHealth(playerid,50);
	        format(string, sizeof(string), "%s влезе в бокс битката", pname);//
			SendClientMessageToAll(0x33AA33AA,string);
			return 1;
	    }
	}
	if(strcmp(cmd, "/sdive", true) == 0)
	{
	    if(sdplaying == 1)
	    {
	        SendClientMessage(playerid, 0xB4B5B7AA, "Съзтезанието с парашути е стартирано");
	        return 1;
	    }
	    if(playerinminigame[playerid] == 1)
	    {
	        SendClientMessage(playerid, 0xB4B5B7AA, "Ти си във игра");
	        return 1;
	    }
		new pname[256];
		GetPlayerName(playerid, pname, 256);
	    if(sdon == 0)
	    {
	        sdon = 1;
	        playerinsd[playerid] = 1;
   	        playerinminigame[playerid] = 1;
	        sdrank = 1;
	        sdfirst = 1;
	        TogglePlayerControllable(playerid, 0);
	        SetPlayerInterior(playerid,0);
	        SetPlayerVirtualWorld(playerid,7);
	        SetPlayerPos(playerid,-1753.7169,884.6819,1000.000);
	        GivePlayerWeapon(playerid,46,1);
	        startvar[5] = 1;
	        sdtimer = SetTimer("StartSd", 60000, 0);
	        SetPlayerRaceCheckpoint(playerid,0,-1753.7169,884.6819,295.8750,-1753.7169,884.6819,290.8750,1);
         	format(string, sizeof(string), "%s стартира съзтезанието с парашути имаш 1 минута да използваш /sdive и да влезеш", pname);//
			SendClientMessageToAll(0x33AA33AA,string);
			return 1;
	    } else if(sdon == 1) {
	        playerinsd[playerid] = 1;
	        TogglePlayerControllable(playerid, 0);
	        SetPlayerInterior(playerid,0);
	        SetPlayerVirtualWorld(playerid,7);
         	SetPlayerPos(playerid,-1753.7169,884.6819,1000.000);
         	sdrank++;
         	GivePlayerWeapon(playerid,46,1);
	        SetPlayerRaceCheckpoint(playerid,0,-1753.7169,884.6819,295.8750,-1753.7169,884.6819,290.8750,1);
	        format(string, sizeof(string), "%s влезе в съзтезанието с парашути", pname);//
			SendClientMessageToAll(0x33AA33AA,string);
			return 1;
	    }
	}

	if(strcmp(cmd, "/kartrace", true) == 0)
	{
	    if(kartplaying == 1)
	    {
	        SendClientMessage(playerid, 0xB4B5B7AA, "Съзтезанието с карт е стартирано.");
	        return 1;
	    }
	    if(playerinminigame[playerid] == 1)
	    {
	        SendClientMessage(playerid, 0xB4B5B7AA, "Вие сте на игра");
	        return 1;
	    }
		new pname[256];
		GetPlayerName(playerid, pname, 256);
	    if(karton == 0)
	    {
	        karton = 1;
	        playerinminigame[playerid] = 1;
	        playerinkartrace[playerid] = 1;
	        kartrank = 1;
	        krtfirst = 1;
	        currentcheckpoint[playerid] = 0;
	        SetPlayerInterior(playerid,15);
	        SetPlayerVirtualWorld(playerid,7);
	        SetVehicleVirtualWorld(karts[0],7);
	        kartfull[0] = 1;
	        PutPlayerInVehicle(playerid, karts[0], 0);
	        playerinkart[playerid] = 0;
	        TogglePlayerControllable(playerid, 0);
	        SetPlayerRaceCheckpoint(playerid,0,kcps[0][0],kcps[0][1],kcps[0][2],kcps[1][0],kcps[1][1],kcps[1][2],20);
	        startvar[6] = 1;
	        krttimer = SetTimer("StartKart", 60000, 0);
         	format(string, sizeof(string), "%s карт съзтезанието е стартирано имате 1 минута да използвате /kartrace и да влезете", pname);//
			SendClientMessageToAll(0x33AA33AA,string);
			return 1;
	    } else if(karton == 1 && kartrank < 15) {
	        playerinminigame[playerid] = 1;
	        playerinkartrace[playerid] = 1;
	        kartrank++;
	        currentcheckpoint[playerid] = 0;
	        SetPlayerInterior(playerid,15);
	        for(new i=0; i<15; i++)
    		{
	    		if(kartfull[i] == 0)
	    		{
	    		    SetPlayerVirtualWorld(playerid,7);
	    		    SetVehicleVirtualWorld(karts[i],7);
	    		    kartfull[i] = 1;
	    		    PutPlayerInVehicle(playerid, karts[i], 0);
	    		    TogglePlayerControllable(playerid, 0);
	    		    SetPlayerRaceCheckpoint(playerid,0,kcps[0][0],kcps[0][1],kcps[0][2],kcps[1][0],kcps[1][1],kcps[1][2],20);
	    		    playerinkart[playerid] = i;
	    		    format(string, sizeof(string), "%s has joined the kart race", pname);//
					SendClientMessageToAll(0x33AA33AA,string);
					return 1;
	    		}
			}
	    } else if(karton == 1 && kartrank >= 15) {
		    format(string, sizeof(string), "Местата за съзтезанието с карт са заети,изчакайте следващия рунд", pname);//
		    SendClientMessage(playerid,0x33AA33AA,string);
		    return 1;
	    }
	}

	if(strcmp(cmd, "/srace", true) == 0)
	{
	    if(srplaying == 1)
	    {
	        SendClientMessage(playerid, 0xB4B5B7AA, "Съзтезанието на стадиона е стартирано.");
	        return 1;
	    }
	    if(playerinminigame[playerid] == 1)
	    {
	        SendClientMessage(playerid, 0xB4B5B7AA, "Ти си на игра");
	        return 1;
	    }
		new pname[256];
		GetPlayerName(playerid, pname, 256);
	    if(sron == 0)
	    {
	        sron = 1;
	        playerinminigame[playerid] = 1;
	        playerinsr[playerid] = 1;
	        srrank = 1;
	        srfirst = 1;
	        currentracecheckpoint[playerid] = 0;
	        SetPlayerInterior(playerid,4);
	        SetPlayerVirtualWorld(playerid,7);
	        SetVehicleVirtualWorld(nrg[0],7);
	        nrgfull[0] = 1;
	        PutPlayerInVehicle(playerid, nrg[0], 0);
	        playerinnrg[playerid] = 0;
	        TogglePlayerControllable(playerid, 0);
	        SetPlayerRaceCheckpoint(playerid,0,srcps[0][0],srcps[0][1],srcps[0][2],srcps[1][0],srcps[1][1],srcps[1][2],10);
	        startvar[7] = 1;
	        srtimer = SetTimer("StartSr", 60000, 0);
         	format(string, sizeof(string), "%s стартирано е съзтезание на стадиона,имаш 1 минута да използваш /srace и влезеш", pname);//
			SendClientMessageToAll(0x33AA33AA,string);
			return 1;
	    } else if(sron == 1 && srrank < 15) {
	        playerinminigame[playerid] = 1;
	        playerinsr[playerid] = 1;
	        srrank++;
	        currentracecheckpoint[playerid] = 0;
	        SetPlayerInterior(playerid,4);
	        for(new i=0; i<15; i++)
    		{
	    		if(nrgfull[i] == 0)
	    		{
	    		    SetPlayerVirtualWorld(playerid,7);
	    		    SetVehicleVirtualWorld(nrg[i],7);
	    		    nrgfull[i] = 1;
	    		    PutPlayerInVehicle(playerid, nrg[i], 0);
	    		    TogglePlayerControllable(playerid, 0);
	    		    SetPlayerRaceCheckpoint(playerid,0,srcps[0][0],srcps[0][1],srcps[0][2],srcps[1][0],srcps[1][1],srcps[1][2],10);
	    		    playerinnrg[playerid] = i;
	    		    format(string, sizeof(string), "%s влезе в съзтезанието на стадиона", pname);//
					SendClientMessageToAll(0x33AA33AA,string);
					return 1;
	    		}
			}
	    } else if(sron == 1 && srrank >= 15) {
		    format(string, sizeof(string), "Местата на съзтезанието на стадиона са запълнени,изчакайте следващия рунд.", pname);//
		    SendClientMessage(playerid,0x33AA33AA,string);
		    return 1;
	    }
	}

	return 0;
}

public OnPlayerInfoChange(playerid)
{
	return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public TimeUpdate()
{
    new Hour, Min, Sec, Day, Month, Year;
    new TimeString[256], TimeString2[256], TimeString3[256];
    gettime(Hour, Min, Sec);
    getdate(Year, Month, Day);
    if(Min <= 9)
            {
                        format(TimeString,25,"%d:0%d",Hour, Min);
                }else{
                        format(TimeString,25,"%d:%d",Hour, Min);
                }
    if(Sec <= 9)
            {
                        format(TimeString2,25,"0%d", Sec);
                }else{
                        format(TimeString2,25,"%d", Sec);
                }
    if(Day <= 9)
                {
                        format(TimeString3,25,"0%d/%d/%d", Day, Month, Year);
                }else{
                        format(TimeString3,25,"%d/%d/%d", Day, Month, Year);
                }
    TextDrawSetString(HClock,TimeString);
    TextDrawShowForAll(HClock);
    TextDrawSetString(HClock2,TimeString2);
    TextDrawShowForAll(HClock2);
    TextDrawSetString(HClock3,TimeString3);
    TextDrawShowForAll(HClock3);
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == 2)
	{
		playercarid[playerid] = GetPlayerVehicleID(playerid);
	}
	if(oldstate == 2)
	{
		if(playerinderby[playerid] || playerinqderby[playerid] || playerinkartrace[playerid] || playerinsr[playerid])
		{
			PutPlayerInVehicle(playerid,playercarid[playerid],0);
		}
	}
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	if(playerinsd[playerid])
	{
		SetTimerEx("SdFinish",2000,0,"i",playerid);
	} else if(playerinkartrace[playerid]) {
        if(currentcheckpoint[playerid] <= 2)
	    {
			currentcheckpoint[playerid]++;
			DisablePlayerRaceCheckpoint(playerid);
			SetPlayerRaceCheckpoint(playerid,0,kcps[currentcheckpoint[playerid]][0],kcps[currentcheckpoint[playerid]][1],kcps[currentcheckpoint[playerid]][2],
			kcps[currentcheckpoint[playerid]+1][0],kcps[currentcheckpoint[playerid]+1][1],kcps[currentcheckpoint[playerid]+1][2],20);
		} else if(currentcheckpoint[playerid] >= 3 && currentcheckpoint[playerid] != 7) {
			currentcheckpoint[playerid]++;
			DisablePlayerRaceCheckpoint(playerid);
			SetPlayerRaceCheckpoint(playerid,0,kcps[currentcheckpoint[playerid]-4][0],kcps[currentcheckpoint[playerid]-4][1],
			kcps[currentcheckpoint[playerid]-4][2],kcps[currentcheckpoint[playerid]-3][0],kcps[currentcheckpoint[playerid]-3][1],
			kcps[currentcheckpoint[playerid]-3][2],20);
		} else if(currentcheckpoint[playerid] == 7) {
		    if(krtfirst == 1)
		    {
				DisablePlayerRaceCheckpoint(playerid);
			    new string[256];
			    krtfirst++;
			    kartrank--;
			    new winnername[256];
				GetPlayerName(playerid,winnername, sizeof(winnername));
                RewardCalc(playerid,10000,100000);
				format(string, sizeof(string), "%s спечели съзтезанието с карт за $%d", winnername, reward);
				SendClientMessageToAll(0x33AA33AA, string);
				GivePlayerMoney(playerid,reward);
				playerinkartrace[playerid] = 0;
				playerinminigame[playerid] = 0;
				currentcheckpoint[playerid] = 0;
				SetPlayerVirtualWorld(playerid,0);
			    SetPlayerInterior(playerid, 0);
				SetPlayerPos(playerid, spawnX, spawnY, spawnZ);
				if(kartrank == 0)
				{
				    KrtFinish();
    			} else {
					SetTimer("KrtFinish",60000,0);
				}
			} else {
			    DisablePlayerRaceCheckpoint(playerid);
		   		playerinkartrace[playerid] = 0;
				playerinminigame[playerid] = 0;
				currentcheckpoint[playerid] = 0;
				SetPlayerVirtualWorld(playerid,0);
				SetPlayerInterior(playerid, 0);
				SetPlayerPos(playerid, spawnX, spawnY, spawnZ);
				if(kartrank == 0)
				{
				    KrtFinish();
    			} else {
					SetTimer("KrtFinish",60000,0);
				}
	    	}
		}
	} else if(playerinsr[playerid]) {
        if(currentracecheckpoint[playerid] <= 7)
	    {
			currentracecheckpoint[playerid]++;
			DisablePlayerRaceCheckpoint(playerid);
			SetPlayerRaceCheckpoint(playerid,0,srcps[currentracecheckpoint[playerid]][0],srcps[currentracecheckpoint[playerid]][1],
			srcps[currentracecheckpoint[playerid]][2],srcps[currentracecheckpoint[playerid]+1][0],srcps[currentracecheckpoint[playerid]+1][1],
			srcps[currentracecheckpoint[playerid]+1][2],10);
		} else if(currentracecheckpoint[playerid] == 8) {
		    if(srfirst == 1)
		    {
				DisablePlayerRaceCheckpoint(playerid);
				new string[256];
			    srfirst++;
			    srrank--;
			    new winnername[256];
				GetPlayerName(playerid,winnername, sizeof(winnername));
				RewardCalc(playerid,10000,100000);
				format(string, sizeof(string), "%s спечели съзтезанието на стадиона за $%d", winnername, reward);
				SendClientMessageToAll(0x33AA33AA, string);
				GivePlayerMoney(playerid,reward);
				playerinsr[playerid] = 0;
				playerinminigame[playerid] = 0;
				currentracecheckpoint[playerid] = 0;
				SetPlayerVirtualWorld(playerid,0);
				SetPlayerInterior(playerid, 0);
				SetPlayerPos(playerid, spawnX, spawnY, spawnZ);
				if(srrank == 0)
				{
				    SrFinish();
    			} else {
					SetTimer("SrFinish",60000,0);
				}
			} else {
			    DisablePlayerRaceCheckpoint(playerid);
		   		playerinsr[playerid] = 0;
				playerinminigame[playerid] = 0;
				currentracecheckpoint[playerid] = 0;
				SetPlayerVirtualWorld(playerid,0);
				SetPlayerInterior(playerid, 0);
				SetPlayerPos(playerid, spawnX, spawnY, spawnZ);
				if(srrank == 0)
				{
				    SrFinish();
    			} else {
					SetTimer("SrFinish",60000,0);
				}
	    	}
		}
	}
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	return 1;
}

public OnRconCommand(cmd[])
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	return 1;
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

public Spawnbloodrings()
{
    for(new i=0; i<15; i++)
    {
		bloodring[i] = CreateVehicle(504,derbycars[i][0],derbycars[i][1],derbycars[i][2],derbycars[i][3],-1,-1,-1);
		LinkVehicleToInterior(bloodring[i],15);
		SetVehicleVirtualWorld(bloodring[i],1);
	    bloodringfull[i] = 0;
	}
	return 1;
}

public Destroybloodrings()
{
    for(new i=0; i<15; i++)
    {
    	DestroyVehicle(bloodring[i]);
    	bloodringfull[i] = 0;
    }
}

public Respawnbloodrings()
{
	for(new i=0; i<15; i++)
	{
	    SetVehicleToRespawn(bloodring[i]);
	    SetVehicleVirtualWorld(bloodring[i],1);
	    bloodringfull[i] = 0;
	}
}

public Spawnqbloodrings()
{
    for(new i=0; i<15; i++)
    {
		qbloodring[i] = CreateVehicle(504,qderbycars[i][0],qderbycars[i][1],qderbycars[i][2],qderbycars[i][3],-1,-1,-1);
		SetVehicleVirtualWorld(qbloodring[i],1);
	    qbloodringfull[i] = 0;
	}
	return 1;
}

public Destroyqbloodrings()
{
    for(new i=0; i<15; i++)
    {
    	DestroyVehicle(qbloodring[i]);
    	qbloodringfull[i] = 0;
    }
}

public Respawnqbloodrings()
{
	for(new i=0; i<15; i++)
	{
    	SetVehicleToRespawn(qbloodring[i]);
    	SetVehicleVirtualWorld(qbloodring[i],1);
    	qbloodringfull[i] = 0;
	}
}

public SpawnKarts()
{
    for(new i=0; i<15; i++)
    {
		karts[i] = CreateVehicle(571,kartspawns[i][0],kartspawns[i][1],kartspawns[i][2],kartspawns[i][3],-1,-1,-1);
		LinkVehicleToInterior(karts[i],15);
		SetVehicleVirtualWorld(karts[i],1);
	    kartfull[i] = 0;
	}
	return 1;
}

public DestroyKarts()
{
    for(new i=0; i<15; i++)
    {
    	DestroyVehicle(karts[i]);
    	kartfull[i] = 0;
    }
}

public RespawnKarts()
{
	for(new i=0; i<15; i++)
	{
    	SetVehicleToRespawn(karts[i]);
    	SetVehicleVirtualWorld(karts[i],1);
    	kartfull[i] = 0;
	}
}

public SpawnNrgs()
{
    for(new i=0; i<15; i++)
    {
		nrg[i] = CreateVehicle(522,nrgspawns[i][0],nrgspawns[i][1],nrgspawns[i][2],nrgspawns[i][3],-1,-1,-1);
		LinkVehicleToInterior(nrg[i],4);
		SetVehicleVirtualWorld(nrg[i],1);
	    nrgfull[i] = 0;
	}
	return 1;
}

public DestroyNrgs()
{
    for(new i=0; i<15; i++)
    {
    	DestroyVehicle(nrg[i]);
    	nrgfull[i] = 0;
    }
}

public RespawnNrgs()
{
	for(new i=0; i<15; i++)
	{
    	SetVehicleToRespawn(nrg[i]);
    	SetVehicleVirtualWorld(nrg[i],1);
    	nrgfull[i] = 0;
	}
}

strtok(const string[], &index)
{
	new length = strlen(string);
	while ((index < length) && (string[index] <= ' '))
	{
		index++;
	}

	new offset = index;
	new result[20];
	while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
	{
		result[index - offset] = string[index];
		index++;
	}
	result[index - offset] = EOS;
	return result;
}

public StartDerby()
{
	new delay = 1000;
	new string[32];
	if(startvar[0] == 1)
	{
		if( derbyrank <= 1 )
		{
		    SendClientMessageToAll(0x33AA33AA, "Дерби съзтезанието е отказано.Недостатъчно играчи. (минимум 2)");
		    derbyplaying = 0;
		    derbyrank = 0;
		    derbyon = 0;
		    startvar[0] = 0;
		    Respawnbloodrings();
	    	for(new i = 0; i <= MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
					if (playerinderby[i] == 1)
					{
					    playerinderby[i] = 0;
					    playerinminigame[i] = 0;
					    playerinbloodring[i] = -1;
						SetPlayerVirtualWorld(i,0);
						SetPlayerInterior(i, 0);
					    SetPlayerPos(i, spawnX, spawnY, spawnZ);
					    TogglePlayerControllable(i, 1);
					}
				}
			}
		    return 1;
	 	}
		format(string, sizeof(string), "~r~Ready");
		derbyplaying = 1;
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinderby[i] == 1)
				{
					GameTextForPlayer(i, string, delay, 6);
					PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
			}
		}
		startvar[0] = 2;
		SetTimer("StartDerby", delay, 0);
	} else if(startvar[0] == 2) {
		format(string, sizeof(string), "~r~Set");
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinderby[i] == 1)
				{
					GameTextForPlayer(i, string, delay, 6);
					PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
			}
		}
		startvar[0] = 3;
		SetTimer("StartDerby", delay, 0);
	} else if(startvar[0] == 3) {
		format(string, sizeof(string), "~g~RAM!");
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinderby[i] == 1)
				{
					GameTextForPlayer(i, string, delay, 6);
					PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
					TogglePlayerControllable(i, 1);
				}
			}
		}
		startvar[0] = 0;
	}
	return 1;
}

public Starttdm()
{
	new delay=1000;
	new string[32];
	if(startvar[1] == 1)
	{
		if( tdmrank <= 1 )
		{
		    SendClientMessageToAll(0x33AA33AA, "Team-DM е отказано.Недостатъчно играчи. (минимум 2)");
		    tdmplaying = 0;
		    tdmrank = 0;
		    tdmon = 0;
		    startvar[1] = 0;
	    	for(new i = 0; i <= MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
					if (playerintdm[i] == 1)
					{
					    playerintdm[i] = 0;
					    playerinminigame[i] = 0;
						SetPlayerVirtualWorld(i,0);
						SetPlayerInterior(i, 0);
					    SetPlayerPos(i, spawnX, spawnY, spawnZ);
					    TogglePlayerControllable(i, 1);
					}
				}
			}
			return 1;
	 	}
		format(string, sizeof(string), "~r~Ready");
		tdmplaying = 1;
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerintdm[i] == 1)
				{
					GameTextForPlayer(i, string, delay, 6);
					PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
			}
		}
		startvar[1] = 2;
		SetTimer("Starttdm", delay, 0);
	} else if(startvar[1] == 2) {
		format(string, sizeof(string), "~r~Set");
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerintdm[i] == 1)
				{
					GameTextForPlayer(i, string, delay, 6);
					PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
			}
		}
        startvar[1] = 3;
		SetTimer("Starttdm", delay, 0);
	} else if(startvar[1] == 3) {
		format(string, sizeof(string), "~g~FIGHT!");
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerintdm[i] == 1)
				{
					GameTextForPlayer(i, string, delay, 6);
					PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
					TogglePlayerControllable(i, 1);
				}
			}
		}
		startvar[1] = 0;
	}
	return 1;
}

public Startdm()
{
	if(startvar[2] == 1)
	{
		if( dmrank <= 1 )
		{
		    SendClientMessageToAll(0x33AA33AA, "LVDM е отказано.Недостатъчно играчи. (минимум 2)");
		    dmplaying = 0;
		    dmrank = 0;
		    dmon = 0;
		    startvar[2] = 0;
	    	for(new i = 0; i <= MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
					if (playerindm[i] == 1)
					{
					    playerindm[i] = 0;
					    playerinminigame[i] = 0;
						SetPlayerVirtualWorld(i,0);
						SetPlayerInterior(i, 0);
					    SetPlayerPos(i, spawnX, spawnY, spawnZ);
					    TogglePlayerControllable(i, 1);
					}
				}
			}
		    return 1;
	 	}
		new string[32];
		format(string, sizeof(string), "~r~Ready");
		new gdelay=1000;
		dmplaying = 1;
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerindm[i] == 1)
				{
					GameTextForPlayer(i, string, gdelay, 6);
					PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
			}
		}
		startvar[2] = 2;
		SetTimer("Startdm", gdelay, 0);
	} else if(startvar[2] == 2) {
		new string[32];
		format(string, sizeof(string), "~r~Set");
		new hdelay=1000;
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerindm[i] == 1)
				{
					GameTextForPlayer(i, string, hdelay, 6);
					PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
			}
		}
		startvar[2] = 3;
		SetTimer("Startdm", hdelay, 0);
	} else if(startvar[2] == 3) {
		new rdelay=1000;
		new string[32];
		format(string, sizeof(string), "~g~FIGHT!");
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerindm[i] == 1)
				{
					GameTextForPlayer(i, string, rdelay, 6);
					PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
					TogglePlayerControllable(i, 1);
				}
			}
		}
		startvar[2] = 0;
	}
	return 1;
}

public StartqDerby()
{
	if(startvar[3] == 1)
	{
		if( qderbyrank <= 1 )
		{
		    SendClientMessageToAll(0x33AA33AA, "Кариерното дерби е отказано.Недостатъчно играчи. (минимум 2)");
		    qderbyplaying = 0;
		    qderbyrank = 0;
		    qderbyon = 0;
		    startvar[3] = 0;
		    Respawnqbloodrings();
	    	for(new i = 0; i <= MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
					if (playerinqderby[i] == 1)
					{
					    playerinqderby[i] = 0;
					    playerinminigame[i] = 0;
					    playerinqbloodring[i] = -1;
						SetPlayerVirtualWorld(i,0);
						SetPlayerInterior(i, 0);
					    SetPlayerPos(i, spawnX, spawnY, spawnZ);
					    TogglePlayerControllable(i, 1);
					}
				}
			}
		    return 1;
	 	}
		new string[32];
		format(string, sizeof(string), "~r~Ready");
		new gdelay=1000;
		qderbyplaying = 1;
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinqderby[i] == 1)
				{
					GameTextForPlayer(i, string, gdelay, 6);
					PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
			}
		}
		startvar[3] = 2;
		SetTimer("StartqDerby", gdelay, 0);
	} else if(startvar[3] == 2) {
		new string[32];
		format(string, sizeof(string), "~r~Set");
		new hdelay=1000;
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinqderby[i] == 1)
				{
					GameTextForPlayer(i, string, hdelay, 6);
					PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
			}
		}
		startvar[3] = 3;
		SetTimer("StartqDerby", hdelay, 0);
	} else if(startvar[3] == 3) {
		new rdelay=1000;
		new string[32];
		format(string, sizeof(string), "~g~RAM!");
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinqderby[i] == 1)
				{
					GameTextForPlayer(i, string, rdelay, 6);
					PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
					TogglePlayerControllable(i, 1);
				}
			}
		}
		startvar[3] = 0;
	}
	return 1;
}

public StartBox()
{
	if(startvar[4] == 1)
	{
		if( boxrank <= 1 )
		{
		    SendClientMessageToAll(0x33AA33AA, "Бокс битката е отказана.Недостатъчно играчи. (минимум 2)");
		    boxplaying = 0;
		    boxrank = 0;
		    boxon = 0;
		    startvar[4] = 0;
	    	for(new i = 0; i <= MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
					if (playerinbox[i] == 1)
					{
					    playerinbox[i] = 0;
					    playerinminigame[i] = 0;
						SetPlayerVirtualWorld(i,0);
						SetPlayerInterior(i, 0);
					    SetPlayerPos(i, spawnX, spawnY, spawnZ);
					    TogglePlayerControllable(i, 1);
					}
				}
			}
		    return 1;
	 	}
		new string[32];
		format(string, sizeof(string), "~r~Ready");
		new gdelay=1000;
		boxplaying = 1;
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinbox[i] == 1)
				{
					GameTextForPlayer(i, string, gdelay, 6);
					PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
			}
		}
		startvar[4] = 2;
		SetTimer("StartBox", gdelay, 0);
	} else if(startvar[4] == 2) {
		new string[32];
		format(string, sizeof(string), "~r~Set");
		new hdelay=1000;
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinbox[i] == 1)
				{
					GameTextForPlayer(i, string, hdelay, 6);
					PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
			}
		}
		startvar[4] = 3;
		SetTimer("StartBox", hdelay, 0);
	} else if(startvar[4] == 3) {
		new rdelay=1000;
		new string[32];
		format(string, sizeof(string), "~g~FIGHT!");
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinbox[i] == 1)
				{
					GameTextForPlayer(i, string, rdelay, 6);
					PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
					TogglePlayerControllable(i, 1);
				}
			}
		}
		startvar[4] = 0;
	}
	return 1;
}

public StartSd()
{
	if(startvar[5] == 1)
	{
		if( sdrank <= 1 )
		{
		    SendClientMessageToAll(0x33AA33AA, "Летенето с парашути отказано.Недостатъчно играчи. (минимум 2)");
		    sdplaying = 0;
		    sdrank = 0;
		    sdon = 0;
		    startvar[5] = 0;
	    	for(new i = 0; i <= MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
					if (playerinsd[i] == 1)
					{
					    playerinsd[i] = 0;
					    playerinminigame[i] = 0;
						SetPlayerVirtualWorld(i,0);
						SetPlayerInterior(i, 0);
					    SetPlayerPos(i, spawnX, spawnY, spawnZ);
					    TogglePlayerControllable(i, 1);
					}
				}
			}
		    return 1;
	 	}
		new string[32];
		format(string, sizeof(string), "~r~Ready");
		new gdelay=1000;
		sdplaying = 1;
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinsd[i] == 1)
				{
					GameTextForPlayer(i, string, gdelay, 6);
					PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
			}
		}
		startvar[5] = 2;
		SetTimer("StartSd", gdelay, 0);
	} else if(startvar[5] == 2) {
		new string[32];
		format(string, sizeof(string), "~r~Set");
		new hdelay=1000;
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinsd[i] == 1)
				{
					GameTextForPlayer(i, string, hdelay, 6);
					PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
			}
		}
		startvar[5] = 3;
		SetTimer("StartSd", hdelay, 0);
	} else if(startvar[5] == 3) {
		new rdelay=1000;
		new string[32];
		format(string, sizeof(string), "~g~GO!");
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinsd[i] == 1)
				{
					GameTextForPlayer(i, string, rdelay, 6);
					PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
					TogglePlayerControllable(i, 1);
				}
			}
		}
		SetTimer("EndSd",180000,0);
		startvar[5] = 0;
	}
	return 1;
}

public EndSd()
{
	for(new i = 0; i <= MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if (playerinsd[i] == 1)
			{
   				playerinsd[i] = 0;
				playerinminigame[i] = 0;
				SetPlayerVirtualWorld(i,0);
				SetPlayerInterior(i, 0);
				SetPlayerPos(i, spawnX, spawnY, spawnZ);
			}
		}
	}
	sdplaying = 0;
	sdrank = 0;
	sdon = 0;
	startvar[5] = 0;
	SendClientMessageToAll(0x33AA33AA, "Летенето с парашути приключи.");
	return 1;
}

public StartKart()
{
	if(startvar[6] == 1) {
		if( kartrank <= 1 )
		{
		    SendClientMessageToAll(0x33AA33AA, "Съзтезанието с карт е отказано.Недостатъчно играчи. (минимум 2)");
		    kartplaying = 0;
		    kartrank = 0;
		    karton = 0;
		    startvar[6] = 0;
		    RespawnKarts();
	    	for(new i = 0; i <= MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
					if (playerinkartrace[i] == 1)
					{
					    playerinkartrace[i] = 0;
					    playerinminigame[i] = 0;
					    playerinkart[i] = -1;
						SetPlayerVirtualWorld(i,0);
						SetPlayerInterior(i, 0);
					    SetPlayerPos(i, spawnX, spawnY, spawnZ);
					    TogglePlayerControllable(i, 1);
					}
				}
			}
		    return 1;
	 	}
		new string[32];
		format(string, sizeof(string), "~r~Ready");
		new gdelay=1000;
		kartplaying = 1;
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinkartrace[i] == 1)
				{
					GameTextForPlayer(i, string, gdelay, 6);
					PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
			}
		}
		startvar[6] = 2;
		SetTimer("StartKart", gdelay, 0);
	} else if(startvar[6] == 2) {
		new string[32];
		format(string, sizeof(string), "~r~Set");
		new hdelay=1000;
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinkartrace[i] == 1)
				{
					GameTextForPlayer(i, string, hdelay, 6);
					PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
			}
		}
		startvar[6] = 3;
		SetTimer("StartKart", hdelay, 0);
	} else if(startvar[6] == 3) {
		new rdelay=1000;
		new string[32];
		format(string, sizeof(string), "~g~GO!");
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinkartrace[i] == 1)
				{
					GameTextForPlayer(i, string, rdelay, 6);
					PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
					TogglePlayerControllable(i, 1);
				}
			}
		}
		SetTimer("KrtFinish",300000,0);
		startvar[6] = 0;
	}
	return 1;
}

public StartSr()
{
	if(startvar[7] == 1)
	{
		if( srrank <= 1 )
		{
		    SendClientMessageToAll(0x33AA33AA, "Съзтезанието на стадиона е отказано.Недостатъчно играчи. (минимум 2)");
		    srplaying = 0;
		    srrank = 0;
		    sron = 0;
		    startvar[7] = 0;
		    RespawnNrgs();
	    	for(new i = 0; i <= MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
					if (playerinsr[i] == 1)
					{
					    playerinsr[i] = 0;
					    playerinminigame[i] = 0;
					    playerinnrg[i] = -1;
						SetPlayerVirtualWorld(i,0);
						SetPlayerInterior(i, 0);
					    SetPlayerPos(i, spawnX, spawnY, spawnZ);
					    TogglePlayerControllable(i, 1);
					}
				}
			}
		    return 1;
	 	}
		new string[32];
		format(string, sizeof(string), "~r~Ready");
		new gdelay=1000;
		kartplaying = 1;
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinsr[i] == 1)
				{
					GameTextForPlayer(i, string, gdelay, 6);
					PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
			}
		}
		startvar[7] = 2;
		SetTimer("StartSr", gdelay, 0);
	} else if(startvar[7] == 2) {
		new string[32];
		format(string, sizeof(string), "~r~Set");
		new hdelay=1000;
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinsr[i] == 1)
				{
					GameTextForPlayer(i, string, hdelay, 6);
					PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
			}
		}
		startvar[7] = 3;
		SetTimer("StartSr", hdelay, 0);
	} else if(startvar[7] == 3) {
		new rdelay=1000;
		new string[32];
		format(string, sizeof(string), "~g~GO!");
		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				if (playerinsr[i] == 1)
				{
					GameTextForPlayer(i, string, rdelay, 6);
					PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
					TogglePlayerControllable(i, 1);
				}
			}
		}
		SetTimer("SrFinish",300000,0);
		startvar[7] = 0;
	}
	return 1;
}

public RewardCalc(playerid,min,max)//Originally from PenLS
{
	reward = (min + (random(max-min)));
}

public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid))
	{
		new Float:oldposx, Float:oldposy, Float:oldposz;
		new Float:tempposx, Float:tempposy, Float:tempposz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		tempposx = (oldposx -x);
		tempposy = (oldposy -y);
		tempposz = (oldposz -z);
		if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
		{
			return 1;
		}
	}
	return 0;
}

public SdFinish(playerid)
{
	if(playerinsd[playerid] == 1 && PlayerToPoint(5,playerid,-1753.7169,884.6819,295.8750))
	{
	    if(sdfirst == 1)
	    {
		    DisablePlayerRaceCheckpoint(playerid);
	        new string[256];
	        sdfirst = 0;
	        new winnername[256];
			GetPlayerName(playerid,winnername, sizeof(winnername));
			RewardCalc(playerid,10000,100000);
			format(string, sizeof(string), "%s спечели летенето с парашути за $%d", winnername, reward);
			SendClientMessageToAll(0x33AA33AA, string);
			GivePlayerMoney(playerid,reward);
			playerinsd[playerid] = 0;
			playerinminigame[playerid] = 0;
			SetPlayerVirtualWorld(playerid,0);
			SetPlayerInterior(playerid, 0);
			SetPlayerPos(playerid, spawnX, spawnY, spawnZ);
			SetTimer("EndSd",60000,0);
	    } else {
	        DisablePlayerRaceCheckpoint(playerid);
   			playerinsd[playerid] = 0;
			playerinminigame[playerid] = 0;
			SetPlayerVirtualWorld(playerid,0);
			SetPlayerInterior(playerid, 0);
			SetPlayerPos(playerid, spawnX, spawnY, spawnZ);
	    }
	}
}

public load()
{
	Spawnbloodrings();
	Spawnqbloodrings();
	SpawnKarts();
	SpawnNrgs();

	CreateObject(975, 213.7231, 1875.3864, 13.8800, 0.0000, 0.0000, 180);// area 51 gate for TeamDM

	// LVDM zone:
	CreateObject(975,2237.232,2453.272,11.353,0.0,0.0,90.000);//Gates
	CreateObject(975,2293.831,2499.356,4.016,0.0,0.0,90.000);
	CreateObject(975,2335.095,2443.816,6.436,0.0,0.0,56.250);
	CreateObject(1225,2242.148,2481.337,2.679,0.0,0.0,0.0);//Explosive barrels
	CreateObject(1225,2249.003,2476.099,2.679,0.0,0.0,0.0);
	CreateObject(1225,2269.786,2485.744,2.679,0.0,0.0,0.0);
	CreateObject(1225,2309.837,2472.542,2.679,0.0,0.0,0.0);
	CreateObject(1225,2296.421,2456.946,2.679,0.0,0.0,0.0);
	CreateObject(1225,2276.625,2436.773,2.679,0.0,0.0,0.0);
	CreateObject(1225,2251.733,2443.828,2.679,0.0,0.0,0.0);
	CreateObject(1225,2335.119,2447.098,5.029,0.0,0.0,0.0);
	CreateObject(1225,2334.300,2446.371,4.971,0.0,0.0,0.0);
	CreateObject(1225,2332.263,2444.455,4.774,0.0,0.0,0.0);
	CreateObject(1225,2333.340,2443.961,5.007,0.0,0.0,0.0);
	CreateObject(1225,2332.409,2441.871,5.056,0.0,0.0,0.0);
	CreateObject(1225,2329.335,2443.138,4.298,0.0,0.0,0.0);
	CreateObject(1225,2328.618,2445.822,4.055,0.0,0.0,0.0);
	CreateObject(1225,2330.095,2446.103,4.320,0.0,0.0,0.0);
	CreateObject(1225,2329.184,2444.807,4.575,0.0,0.0,0.0);
	CreateObject(1556,2294.025,2494.454,3.789,0.0,0.0,-90.000);//Door
	CreateObject(16681,2494.841,-1676.981,7000.000,0.0,0.0,0.0);//Boxing Arena

}

public KrtFinish()
{
	for(new i = 0; i <= MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if (playerinkartrace[i] == 1)
			{
   				playerinkartrace[i] = 0;
				playerinminigame[i] = 0;
				SetPlayerVirtualWorld(i,0);
				SetPlayerInterior(i, 0);
				SetPlayerPos(i, spawnX, spawnY, spawnZ);
			}
		}
	}
	kartplaying = 0;
	kartrank = 0;
	karton = 0;
	RespawnKarts();
	SendClientMessageToAll(0x33AA33AA, "Съзтезанието с карт приключи.");
	return 1;
}

public SrFinish()
{
	for(new i = 0; i <= MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if (playerinsr[i] == 1)
			{
   				playerinsr[i] = 0;
				playerinminigame[i] = 0;
				SetPlayerVirtualWorld(i,0);
				SetPlayerInterior(i, 0);
				SetPlayerPos(i, spawnX, spawnY, spawnZ);
			}
		}
	}
	srplaying = 0;
	srrank = 0;
	sron = 0;
	RespawnNrgs();
	SendClientMessageToAll(0x33AA33AA, "Съзтезанието на стадиона приключи.");
	return 1;
}
Reply


Messages In This Thread
Little problem.. - by pblbms - 16.09.2012, 12:21
Re: Little problem.. - by ThomasCarter - 16.09.2012, 12:22
Re: Little problem.. - by Roko_foko - 16.09.2012, 12:26
Re: Little problem.. - by ThomasCarter - 16.09.2012, 12:33
Re: Little problem.. - by pblbms - 16.09.2012, 13:46
Re: Little problem.. - by pblbms - 16.09.2012, 14:23
Re: Little problem.. - by pblbms - 16.09.2012, 16:06
Re: Little problem.. - by pblbms - 16.09.2012, 18:31
Re: Little problem.. - by AtItsMax - 16.09.2012, 18:46
Re: Little problem.. - by pblbms - 17.09.2012, 07:39

Forum Jump:


Users browsing this thread: 2 Guest(s)