All pastes #825302 Raw Edit

Untitled

public text v1 · immutable
#825302 ·published 2007-12-20 14:02 UTC
rendered paste body
#include <a_samp>
#define CP_SFCAR 0
#define CP_WANGS 1
#define CP_TRAMS 2
#define CP_MARKET 3
#define CP_CLUB 4
#define CP_BURGER 5
#define CP_MISTYS 6
#define CP_GARAGE 7
#define CP_TRAIN 8
#define CP_ZEROS 9
#define CP_THEATER 10
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_RED 0xAA3333AA
#define COLOR_GREEN 0x33AA33AA
#define P_SFCAR      0
#define P_WANGS     1
#define P_TRAMS     2
#define P_MARKET     3
#define P_CLUB     4
#define P_BURGER     5
#define P_MISTYS     6
#define P_GARAGE     7
#define P_TRAIN     8
#define P_ZEROS     9
#define P_THEATER    	10
#define P_OFFSET    11

new giveplayer[MAX_PLAYER_NAME];
new playerCheckpoint[MAX_PLAYERS];

#define MAX_POINTS 11
new Float:checkCoords[MAX_POINTS][4] = {
{-2035.6470,-119.3649,-2021.5370,-113.6046},
{-1964.7784,308.0349,-1941.9794,253.6098},
{-2374.3145,553.3713,-2236.6191,518.3326},
{-2517.1367,719.4539,-2399.0366,798.6450},
{-2723.4802,-323.2720,-2718.6848,-312.1307},
{379.1006,-76.7808,362.3110,-56.4985},
{512.0634,-88.7290,489.6101,-71.8145},
{-2060.9048,183.4393,-2016.7871,118.7150},
{-1978.7048,162.6923,-1961.9302,113.2506},
{-2239.7976,127.7212,-2219.3057,136.8329},
{-2240.7241,308.9796,-2156.5479,217.9425}
};

new Float:checkpoints[MAX_POINTS][3] = {
{-2029.7269,-116.2020,1035.1719},
{-1956.4724,285.1592,35.4688},
{-2269.491455,534.383666,35.015625},
{-2442.6479,755.0816,35.1719},
{-2719.1909,-318.1408,7.8438},
{368.4482,-73.1867,1001.5078},
{495.3479,-75.2320,998.7578},
{-2032.0352,161.4595,29.0461},
{-1971.9601,138.1361,27.6875},
{-2236.1519,130.6743,1035.4141},
{-2228.3884,251.8337,35.3203}
};

new checkpointType[MAX_POINTS] = {
CP_SFCAR,
CP_WANGS,
CP_TRAMS,
CP_MARKET,
CP_CLUB,
CP_BURGER,
CP_MISTYS,
CP_GARAGE,
CP_TRAIN,
CP_ZEROS,
CP_THEATER

};
#define MAX_PROPERTIES 11
new propertyNames[MAX_PROPERTIES][32] = {
"San Fierro Driving School",
"Wang Cars",
"San Fierro Tram Service",
"'Supa Save' SuperMarket",
"San Fierro Country Club",
"Burger Shot",
"Mistys Shithole Bar",
"The Rusty Garage Co.",
"San Fierro Train Station",
"Zero's RC Shop",
"The Royal San Fierro Theatre"
};

new propertyValues[MAX_PROPERTIES] = {
130000,
210000,
90000,
115000,
2000000,
50000,
45000,
60000,
240000,
80000,
3000000
};

new propertyEarnings[MAX_PROPERTIES] = {
4500,
6000,
2000,
2700,
25000,
1200,
900,
1700,
6500,
2000,
34000
};

new propertyOwner[MAX_PROPERTIES] = {999, ...};

forward PropertyScoreUpdate();
forward getCheckpointType(playerID);
forward checkpointUpdate();
forward isPlayerInArea(playerID, Float:data[4]);

#if defined FILTERSCRIPT


#endif

public PropertyScoreUpdate()
{
	new owners[MAX_PROPERTIES];
	new payments[MAX_PROPERTIES];

	for(new i=0; i < MAX_PROPERTIES; i++)
	    owners[i]=999;

	for(new i=0; i < MAX_PROPERTIES; i++)
	{
		if(propertyOwner[i] < 999) {

			for(new j=0; j < MAX_PROPERTIES; j++) {
			    if(owners[j]==propertyOwner[i]) {
			        payments[j]+=propertyEarnings[i];
			        j = MAX_PROPERTIES;
			    } else if (owners[j]==999) {
					owners[j]=propertyOwner[i];
					payments[j]+=propertyEarnings[i];
			        j = MAX_PROPERTIES;
				}
			}

		}
	}

	for(new i=0; i < MAX_PROPERTIES; i++) {
		if(owners[i] < 999 && IsPlayerConnected(owners[i])) {
			new string[256];

			GivePlayerMoney(owners[i], payments[i]);

			format(string, sizeof(string), "You earned $%d from your properties.", payments[i]);
			SendClientMessage(owners[i], COLOR_YELLOW, string);
		}
	}

}


public OnGameModeInit()
{
	SetTimer("checkpointUpdate", 1100, 1);
	SetTimer("PropertyScoreUpdate", 40005, 1);
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	new string[256];
	if(strcmp(cmdtext, "/buy", true) == 0) {
		new property=999;

		if(IsPlayerInCheckpoint(playerid)) {
			switch (playerCheckpoint[playerid]) {
				case CP_SFCAR:{
					property = P_SFCAR;
				}
				case CP_WANGS:{
					property = P_WANGS;
				}
				case CP_TRAMS:{
					property = P_TRAMS;
				}
				case CP_MARKET:{
					property = P_MARKET;
				}
				case CP_CLUB:{
					property = P_CLUB;
				}
				case CP_BURGER:{
					property = P_BURGER;
				}
				case CP_MISTYS:{
					property = P_MISTYS;
				}
				case CP_GARAGE:{
					property = P_GARAGE;
				}
				case CP_TRAIN:{
					property = P_TRAIN;
				}
				case CP_ZEROS:{
					property = P_ZEROS;
				}
				case CP_THEATER:{
					property = P_THEATER;
				}
			}

			if(property==999) {
				SendClientMessage(playerid, COLOR_YELLOW, "You need to be in a property checkpoint to /buy it.");
				return 1;
			}

//			property--;

			if(GetPlayerMoney(playerid) < propertyValues[property]) {
				SendClientMessage(playerid, COLOR_RED, "You don't have enough money to buy this property.");
				return 1;
			}
			if(propertyOwner[property]==playerid) {
				SendClientMessage(playerid, COLOR_RED, "You already own this property.");
				return 1;
			}

			if(propertyOwner[property] < 999) {
				GetPlayerName(playerid, giveplayer, sizeof(giveplayer));
				GivePlayerMoney(propertyOwner[property], propertyValues[property]);
				format (string, sizeof(string), "Your property, the %s, has been bought out by %s (id: %d).",propertyNames[property],giveplayer,playerid);
				SendClientMessage(propertyOwner[property], COLOR_RED, string);
			}

			GivePlayerMoney(playerid, 0-propertyValues[property]);

			propertyOwner[property]=playerid;

			format(string, sizeof(string), "You have purchased the %s!", propertyNames[property]);
			SendClientMessage(playerid, COLOR_GREEN, string);

		} else {
			SendClientMessage(playerid, COLOR_YELLOW, "You need to be in a property checkpoint to /buy it.");
			return 1;
		}


		return 1;
	}

	//------------------- /properties

	if(strcmp(cmdtext, "/properties", true) == 0) {
		SendClientMessage(playerid, COLOR_GREEN, "Property Owners List 1:");
		for(new i = 0; i < 8; i++) {
			if(propertyOwner[i] < 999) {
				GetPlayerName(propertyOwner[i], giveplayer, sizeof(giveplayer));
				format(string, sizeof(string), "%d. %s - %s", i, propertyNames[i], giveplayer);
			} else
				format(string, sizeof(string), "%d. %s - None", i, propertyNames[i]);

			SendClientMessage(playerid, COLOR_YELLOW, string);
		}

		return 1;
	}

	if(strcmp(cmdtext, "/properties2", true) == 0) {
		SendClientMessage(playerid, COLOR_GREEN, "Property Owners List 2:");
		for(new i = 9; i < 18; i++) {
			if(propertyOwner[i] < 999) {
				GetPlayerName(propertyOwner[i], giveplayer, sizeof(giveplayer));
				format(string, sizeof(string), "%d. %s - %s", i, propertyNames[i], giveplayer);
			} else
				format(string, sizeof(string), "%d. %s - None", i, propertyNames[i]);

			SendClientMessage(playerid, COLOR_YELLOW, string);
		}

		return 1;
	}
	return 0;
}

public getCheckpointType(playerID) {
	return checkpointType[playerCheckpoint[playerID]];
}

public checkpointUpdate()
{
	for(new i=0; i<MAX_PLAYERS; i++)
	{
	    if(IsPlayerConnected(i)) {
	        for(new j=0; j < MAX_POINTS; j++) {
	            if(isPlayerInArea(i, checkCoords[j])) {
	                if(playerCheckpoint[i]!=j) {
	                    DisablePlayerCheckpoint(i);
						SetPlayerCheckpoint(i, checkpoints[j][0],checkpoints[j][1],checkpoints[j][2],2);
						playerCheckpoint[i] = j;
					}
	            } else {
	            	if(playerCheckpoint[i]==j) {
	            	    DisablePlayerCheckpoint(i);
	            	    playerCheckpoint[i] = 999;
         	    	}
	            }
	        }
		}
	}
}

public isPlayerInArea(playerID, Float:data[4])
{
	new Float:X, Float:Y, Float:Z;

	GetPlayerPos(playerID, X, Y, Z);
	if(X >= data[0] && X <= data[2] && Y >= data[1] && Y <= data[3]) {
		return 1;
	}
	return 0;
}