All pastes #983423 Raw Edit

cmg

public text v1 · immutable
·published 2008-04-13 10:55 UTC
rendered paste body
#include <a_samp>

#define COLOR_WHITE 0xFFFFFFAA
/*-----------------------------------------------------
How it works?:

Player get on the pickup and the menu comes uot
In menu he can 'enter' or 'exit' the stadium
if he enters ($-1000) ,he will be teleported inside
after he will gen into the car ,he will have to
wait for other 2 drivers (stadium can have 3
players at one time)
If he will be tired of waiting for then ,he can
always type /stadiumquit and he will get $500 back
and teleported to the entrance.
After all 3 player got into the car ,they will get
message to be ready.
(server checks every 10 second for players inside)
Go throught all checkpoints.
Player ,who will pick up the last checkpoint will
get winners variable ,others will get loosers var.
In 20 secs players will get results.
Winner gets $ 3000.

Have fun, Luxeon
2008 (C) All Rights Reserved.
-----------------------------------------------------*/

new stadiumpickup;
new stadiumcar1;
new stadiumcar2;
new stadiumcar3;
new stadfull;
new racestarted;
new stadcheck;
new stadcp1[MAX_PLAYERS];
new stadcp2[MAX_PLAYERS];
new stadcp3[MAX_PLAYERS];
new stadcp4[MAX_PLAYERS];
new stadcp5[MAX_PLAYERS];
new stadcp6[MAX_PLAYERS];
new instadium[MAX_PLAYERS];
new stadwinner[MAX_PLAYERS];
new instadcar[MAX_PLAYERS];
new stadracestarted[MAX_PLAYERS];
new stadlooser[MAX_PLAYERS];
new Menu:stadium;

forward StartStadium();
forward StadiumResult();
forward IsStadiumFull();
forward StadiumToggle();

public OnFilterScriptInit()
{

	print("\n---------------------------------------------------------");
	print("            Crappyeon 's Stadium System[LSS]               ");
	print("---------------------------------------------------------\n");

	stadiumpickup = CreatePickup(1239, 2, -2110.7080,-444.4514,38.7344);
	SetTimer("IsStadiumFull", 10000, 1);

	stadium = CreateMenu("Stadium", 1, 50.0, 180.0, 200.0, 200.0);
	AddMenuItem(stadium, 0, "Enter  (1000$)");
	AddMenuItem(stadium, 0, "Exit");

	stadiumcar1 = CreateVehicle(494,-1394.4614,-213.6085,1042.8416,2.2693,3,6,30000); // stadiumcar1
	LinkVehicleToInterior(stadiumcar1, 7);
	AddVehicleComponent(stadiumcar1, 1010);
	stadiumcar2 = CreateVehicle(502,-1397.6400,-214.5487,1042.8385,3.2977,79,12,30000); // stadiumcar2
	LinkVehicleToInterior(stadiumcar2, 7);
	AddVehicleComponent(stadiumcar2, 1010);
	stadiumcar3 = CreateVehicle(503,-1401.4456,-214.0998,1042.8317,4.0334,126,1,30000); // stadiumcar3
	LinkVehicleToInterior(stadiumcar3, 7);
	AddVehicleComponent(stadiumcar3, 1010);
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	if(pickupid == stadiumpickup)
	{
		ShowMenuForPlayer(Menu:stadium, playerid);
		TogglePlayerControllable(playerid,0);
	}
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	new Menu:Current = GetPlayerMenu(playerid);
	if(Current == stadium)
	{
		switch(row)
		{
			case 0:
			{
			if( GetPlayerMoney(playerid) >= 1000)
			{
				if(stadfull <= 3)
				{
					HideMenuForPlayer(stadium,playerid);
					TogglePlayerControllable(playerid,1);
					SetPlayerInterior(playerid, 7);
					SetPlayerPos(playerid, -1405.7186,-266.6992,1043.6563);
					SendClientMessage(playerid,COLOR_WHITE,"SERVER: Now get in the vehicle!");
					GivePlayerMoney(playerid,-1000);
					new name[MAX_PLAYER_NAME];
					new string[256];
					GetPlayerName(playerid, name, sizeof(name));
					format(string, sizeof(string),"%s has entered the nascar stadium.",name);
					print(string);
				}
				else if(stadfull == 3)
				{
					SendClientMessage(playerid,COLOR_WHITE,"Stadium is full ,try again in some minutes");
					HideMenuForPlayer(stadium,playerid);
					TogglePlayerControllable(playerid,1);
				}
			} else { SendClientMessage(playerid, COLOR_RED, "Not Enough Money !!! "); }
			}
			case 1:
			{
				HideMenuForPlayer(stadium,playerid);
				TogglePlayerControllable(playerid,1);
			}
		}
	}
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{

	if (strcmp("/stadiumquit", cmdtext, true, 12) == 0)
	{
		if(instadium[playerid] == 1)
		{
			if(stadracestarted[playerid] == 0)
			{
				new name[MAX_PLAYER_NAME];
				new string[256];
				GetPlayerName(playerid, name, sizeof(name));
				format(string, sizeof(string),".:: %s has quit the nascar race!",name);
				print(string);
				stadfull--;
				instadcar[playerid] = 0;
				instadium[playerid] = 0;
				TogglePlayerControllable(playerid,1);
				DisablePlayerCheckpoint(playerid);
				SendClientMessage(playerid,COLOR_WHITE,"SERVER: You have quit the stadium.");
				RemovePlayerFromVehicle(playerid);
				GivePlayerMoney(playerid,500);
				SetPlayerInterior(playerid,0);
				SetPlayerPos(playerid,-2110.7080,-444.4514,38.7344);
			}
		}else{
			SendClientMessage(playerid,COLOR_WHITE,"SERVER: You cant exit after the race has started!");
			new name[MAX_PLAYER_NAME];
			new string[256];
			GetPlayerName(playerid, name, sizeof(name));
			format(string, sizeof(string),".:: %s tried to quit the nascar race ,but failed!pwnz0r!",name);
			print(string);
		}
		return 1;
	}
	return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid)
{
	if(vehicleid == stadiumcar1 || vehicleid == stadiumcar2 || vehicleid == stadiumcar3)
	{
		if(instadcar[playerid] == 0)
		{
			new name[MAX_PLAYER_NAME];
			new string[256];
			GetPlayerName(playerid, name, sizeof(name));
			format(string, sizeof(string),".:: %s has entered the nascar vehicle!",name);
			print(string);
			SendClientMessage(playerid,COLOR_WHITE, "SERVER: Wait for other racers (3 total).");
			SendClientMessage(playerid,COLOR_WHITE, "SERVER: If you are tired of waitng ,type /stadiumquit");
			SetTimer("StadiumToggle", 5000, 0);
			stadfull++;
			instadcar[playerid] = 1;
			instadium[playerid] = 1;
			if(stadfull == 1){
				SendClientMessageToAll(COLOR_WHITE, "SERVER: Nascar racers needs 2 more racers!");
			}
			else if(stadfull == 2){
				SendClientMessageToAll(COLOR_WHITE, "SERVER: Nascar racers needs 1 more racer!");
			}
		}
	}
	return 1;
}
public StartStadium()
{
	if(racestarted == 0)
	{
		for ( new i = 0; i < MAX_PLAYERS; ++i )
		{
			if(instadium[i] == 1)
			{
				TogglePlayerControllable(i,1);
				SendClientMessage(i,COLOR_WHITE, "SERVER: Race started !");
				print("Nascar Race has started!");
				stadracestarted[i] = 1;
				racestarted = 1;
				SetPlayerCheckpoint(i,-1453.9421,-132.3770,1046.2058,10);
				stadcp1[playerid] = 1;
			}
		}
	}
	return 1;
}

public StadiumToggle()
{
    for ( new i = 0; i < MAX_PLAYERS; ++i )
    {
	TogglePlayerControllable(i,0);
	}
	return 1;
}
public IsStadiumFull()
{
	if(stadcheck == 0)
	{
		for ( new i = 0; i < MAX_PLAYERS; i++ )
		{
			if(instadium[i] == 1){
				if(instadcar[i] == 1){
					if(stadfull == 1){
						stadcheck = 1;
						SetTimer("StartStadium", 10000, 0);
						GameTextForPlayer(i,"Race will start in 10 seconds",10000,3);
						print("Stadium Check Succed!");
					}
				}
			}
		}
	}
	return 1;
}

public StadiumResult()
{
	for ( new i = 0; i < MAX_PLAYERS; i++ )
	{
		stadfull = 0;
		racestarted = 0;
		stadcheck = 0;
		if(instadium[i] == 1)
		{
			if(stadwinner[i] == 1)
			{
				SendClientMessage(i,COLOR_WHITE, "SERVER: You Won The Race and got 3000$!");
				new name[MAX_PLAYER_NAME];
				new string[256];
				GetPlayerName(i, name, sizeof(name));
				format(string, sizeof(string),".:: %s has won the Nascar Race!",name);
				print(string);
				instadium[i] = 0;
				GivePlayerMoney(i,3000);// you are sooo bad... xD
				stadracestarted[i] = 0;
				stadwinner[i] = 0;
			}else if(stadlooser[i] == 1){
				SendClientMessage(i,COLOR_WHITE,"SERVER: You didnt get first place -> You lost !"); // LOOOZER :P
				instadium[i] = 0;
				stadwinner[i] = 0;
				stadracestarted[i] = 0;
			}
		}
	}
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
		if(stadcp1[playerid] == 1)
		{
			DisablePlayerCheckpoint(playerid);
			SetPlayerCheckpoint(playerid,-1453.9421,-132.3770,1046.2058,10);
			stadcp1[playerid] = 0;
			stadcp2[playerid] = 1;
			stadlooser[playerid] = 1;
		}
		if(stadcp2[playerid] == 1)
		{
			DisablePlayerCheckpoint(playerid);
			SetPlayerCheckpoint(playerid,-1435.2540,-282.1894,1050.9230,10);
			stadcp2[playerid] = 0;
			stadcp3[playerid] = 1;
		}
		if(stadcp3[playerid] == 1)
		{
			DisablePlayerCheckpoint(playerid);
			SetPlayerCheckpoint(playerid,-1273.6451,-250.3865,1050.2200,10);
			stadcp3[playerid] = 0;
			stadcp4[playerid] = 1;
		}
		if(stadcp4[playerid] == 1)
		{
			DisablePlayerCheckpoint(playerid);
			SetPlayerCheckpoint(playerid,-1453.9421,-132.3770,1046.2058,10);
			stadcp4[playerid] = 0;
			stadcp5[playerid] = 1;
		}
		if(stadcp5[playerid] == 1)
		{
			DisablePlayerCheckpoint(playerid);
			SetPlayerCheckpoint(playerid,-1435.2540,-282.1894,1050.9230,10);
			stadcp5[playerid] = 0;
			stadcp6[playerid] = 1;
		}
		if(stadcp6[playerid] == 1)
		{
			stadwinner[playerid] = 1;
			stadlooser[playerid] = 0;
			if(instadium[playerid] == 1)
			{
				DisablePlayerCheckpoint(playerid);
				stadcp6[playerid] = 0;
				SendClientMessage(playerid,COLOR_WHITE,"SERVER: Race finished ,wait for the result.");
				SetTimer("StadiumResult", 20000, 0);
				RemovePlayerFromVehicle(playerid);
				SetPlayerInterior(playerid,0);
				SetPlayerPos(playerid,-2110.7080,-444.4514,38.7344);
				instadcar[playerid] = 0;
			}
		}
	return 1;
}

// You are sooo NoOb in Loops and Timers :P

// The print on top its a Joke :P