All pastes #481160 Raw Edit

LSTDM

public text v1 · immutable
·published 2007-05-10 17:34 UTC
rendered paste body
//------------------------------------------------------------------------------

//

// LOS SANTOS TEAM Deathmatch for  SA-MP 0.1

//

//------------------------------------------------------------------------------

#include "a_samp"
#include "dini"
#include <core>

#include <float>

#define settings "settings.ini"
#define spawned PLAYER_STATE_SPAWNED
#define foot PLAYER_STATE_ONFOOT
#define vehicle PLAYER_STATE_DRIVER
#define COLOR_GREY 0xAFAFAFAA

#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define PocketMoney 500 // Amount player recieves on spawn.
#define INACTIVE_PLAYER_ID 255
#define GIVECASH_DELAY 5000 // Time in ms between /givecash commands.

#define NUMVALUES 4

forward MoneyGrubScoreUpdate();
forward Givecashdelaytimer(playerid);
//forward GrubModeReset();
forward SetPlayerRandomSpawn(playerid);
forward SetupPlayerForClassSelection(playerid);
forward GameModeExitFunc();

new speed;
new hp;
new clear;
new stick;
new c1;
enum AC
{
	SP,
	HP
}
new A1C[AC];
enum T
{
	H,
	S,
	ST
}
new r[MAX_PLAYERS][T];
enum SavePlayerPosEnum
{
    Float:LastX,
    Float:LastY,
    Float:LastZ
}
new SavePlayerPos[MAX_PLAYERS][SavePlayerPosEnum];
new mph[MAX_PLAYERS];
new bWeapons[5][1] = { {34}, {35}, {36}, {19}, {20} };
new chat[MAX_PLAYERS];
public OnFilterScriptInit()
{
	print("\n..:: [:] [:] [:] [:] [:] [:] [:] [:] ::..");
	print("..:: [:]  xReaper - Anti!Cheat   [:] ::..");
	print("..:: [:] [:] [:] [:] [:] [:] [:] [:] ::..\n");
	return 1;
}

public OnPlayerConnect(playerid)
{
	if(A1C[SP] == 0)
	{
	 	speed = SetTimer("Hp",1000,1);
	    hp = SetTimer("Speed",1160,1);
	    clear = SetTimer("Clear",15000,1);
	    stick = SetTimer("Stick",1000,1);
		c1 = SetTimer("cClear",4800,1);
	}
	return 1;
}

public OnPlayerDisconnect(playerid)
{
	new p = GetConnectedPlayers();
	if(p == 0)
	{
	    KillTimer(speed);
	    KillTimer(hp);
	    KillTimer(clear);
	    KillTimer(stick);
		KillTimer(c1);
	    A1C[SP] = 0;
	}
	return 1;
}

public OnPlayerDeath(playerid,killerid,reason)
{
	new str[130],player[24],killer[24],Float:x,Float:y,Float:z;
	if(killerid != INVALID_PLAYER_ID)
	{
	    GetPlayerPos(killerid,x,y,z);
	    GetPlayerName(playerid,killer,24);
	}
	GetPlayerName(playerid,player,24);
	for(new s=0; s<5; s++)
	if(reason == bWeapons[s][0])
	{
 		format(str,sizeof(str),"..:: xReaperx - Player %s has been [Possibly] detected |Fake Kill| ::..",player);
		Report(str);
	}
	if(z > 700)
	{
		format(str,sizeof(str),"..:: xReaperx - Player %s has been [Possibly] detected |Indoor Weapons| ::..",killer);
		Report(str);
	}
	return 1;
}


public OnPlayerText(playerid,text[])
{
	new str[130],player[24];
	GetPlayerName(playerid,player,24);
	if(chat[playerid] >= 3)
	{
		format(str,sizeof(str),"..:: xReaperx - Player %s has been [Possibly] doing |Spam| ::..",player);
		Report(str);
 	}
	return 1;
}

public Hp()
{
	for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i)) if(GetPlayerState(i) == spawned)
	{
	    new str[130],player[24],Float:h;
	    GetPlayerName(i,player,24);
	    GetPlayerHealth(i,h);
	    if(h > 100)
		{
			if(r[i][H]) break;
		    format(str,sizeof(str),"..:: xReaperx - Player %s has been [Possibly] detected |Health > 100| ::..",player);
			Report(str);
			r[i][H] = 1;
		}
		new oldhealth = GetPlayerHealth(i,h);
		SetPlayerHealth(i,50);
		GetPlayerHealth(i,h);
		if(oldhealth == h)
		{
			if(r[i][H]) break;
		    format(str,sizeof(str),"..:: xReaperx - Player %s has been [Possibly] detected |Timer Health| ::..",player);
			Report(str);
			r[i][H] = 1;
		}
	}
}

public Speed()
{
	for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i)) if(GetPlayerState(i) == spawned)
	{
		new Float:x,Float:y,Float:z,str[130],player[24],Float:distance;
		GetPlayerName(i,player,24);
		GetPlayerPos(i,x,y,z);
		distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2));
   		SavePlayerPos[i][LastX] = x;
    	SavePlayerPos[i][LastY] = y;
    	SavePlayerPos[i][LastZ] = z;
    	mph[i] = floatround(distance * 5600);
	    if(GetPlayerState(i) == foot)
	    {
	        if(mph[i] > 40)
	        {
	            if(z > 700) break;
				if(r[i][S]) break;
			    format(str,sizeof(str),"..:: xReaperx - Player %s has been [Possibly] detected |Airbreak| ::..",player);
				Report(str);
				r[i][S] = 1;
	        }
	    }
	    if(GetPlayerState(i) == vehicle)
	    {
	        if(z > 700)
	        {
	            if(mph[i] > 240)
	            {
					if(r[i][S]) break;
				    format(str,sizeof(str),"..:: xReaperx - Player %s has been [Possibly] detected |Flying Vehicle| ::..",player);
					Report(str);
					r[i][S] = 1;
	            }
	        }
	        if(mph[i] > 240)
	        {
				if(r[i][S]) break;
    			format(str,sizeof(str),"..:: xReaperx - Player %s has been [Possibly] detected |Speed| ::..",player);
				Report(str);
				r[i][S] = 1;
	        }
	    }
	}
}

public Stick()
{
	for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i)) if(GetPlayerState(i) == spawned)
	{
		new Float:x,Float:y,Float:z,Float:x1,Float:y1,Float:z1,player[24],str[130];
		GetPlayerPos(i,x,y,z);
		GetPlayerName(i,player,24);
		new p1 = mph[i];
		if(GetPlayerID(player) != GetPlayerID(player))
		{
		    new p2 = mph[i];
		    GetPlayerPos(i,x1,y1,z1);
		    if(z - z1 < 10 && z - z1 > 0 && x - x1 < 16 && x - x1 > 0)
		    if(y - y1 < 16 && y - y1 > 0 && p1 - p2 < 20)
		    {
				if(r[i][ST]) break;
    			format(str,sizeof(str),"..:: xReaperx - Player %s has been [Possibly] detected |Stick| ::..",player);
				Report(str);
				r[i][ST] = 1;
		    }
		}
 	}
}

public Clear()
{
	for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i))
	{
	    r[i][H] = 0;
	    r[i][S] = 0;
	}
}

public cClear() for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i)) chat[i] = 0;

stock GetConnectedPlayers()
{
	new players;
	for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i)) players++;
	return players;
}

stock Report(string[])
{
	for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i)) if(IsPlayerAdmin(i))
    SendClientMessage(i,0x00FFFFAA,string);
}

stock GetPlayerID(playername[])
{
	new player[24];
	for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i))
	GetPlayerName(i,player,24);
	if(strcmp(player, playername, true) == 0)
	return true;
	return false;
}




//Global stuff and defines for our gamemode

static gTeam[MAX_PLAYERS]; // Tracks the team assignment for each player

new gPlayerClass[MAX_PLAYERS];

//Color Defines

#define COLOR_GREY 0xAFAFAFAA

#define COLOR_GREEN 0x33AA33AA

#define COLOR_RED 0xAA3333AA

#define COLOR_YELLOW 0xFFFF00AA

#define COLOR_PINK 0xFF66FFAA

#define COLOR_BLUE 0x0000BBAA

#define COLOR_LIGHTBLUE 0x33CCFFAA

#define COLOR_DARKRED 0x660000AA

#define COLOR_ORANGE 0xFF9900AA

//Team Defines

#define TEAM_GROVE 0
#define TEAM_BALLAS 11





// Round duration

new gRoundTime = 3600000; // 60 mins

//new gRoundTime = 900000; //15 mins

//new gRoundTime = 300000; // 5 mins



//------------------------------------------------------------------------------



main()

{

	print("\n----------------------------------");

	print("  SFTDM by Pako (2006)\n");

	print("----------------------------------\n");

}



//------------------------------------------------------------------------------



public OnGameModeInit()

{

	SetGameModeText("Los Santos TDM");

	SetTeamCount(20);

	ShowNameTags(1);

	ShowPlayerMarkers(1);

	SetWorldTime(18);



	AddPlayerClass(47,1282.1699,-818.3918,84.1406,175.9438,24,300,25,300,29,500); //
	AddPlayerClass(56,1282.1699,-818.3918,84.1406,175.9438,24,300,25,300,31,500); //
	AddPlayerClass(79,1282.1699,-818.3918,84.1406,175.9438,24,300,25,300,29,500); //
	AddPlayerClass(101,1282.1699,-818.3918,84.1406,175.9438,24,300,25,300,31,500); //
	AddPlayerClass(105,1282.1699,-818.3918,84.1406,175.9438,24,300,25,300,29,500); //
	AddPlayerClass(106,1282.1699,-818.3918,84.1406,175.9438,24,300,25,300,31,500); //
	AddPlayerClass(107,1282.1699,-818.3918,84.1406,175.9438,24,300,25,300,29,500); //
	AddPlayerClass(122,1282.1699,-818.3918,84.1406,175.9438,24,300,25,300,31,500); //
	AddPlayerClass(49,1496.9175,-690.3009,94.7500,177.7114,24,300,25,300,29,500); //
	AddPlayerClass(52,1496.9175,-690.3009,94.7500,177.7114,24,300,25,300,30,500); //
	AddPlayerClass(58,1496.9175,-690.3009,94.7500,177.7114,24,300,25,300,29,500); //
	AddPlayerClass(63,1496.9175,-690.3009,94.7500,177.7114,24,300,25,300,30,500); //
	AddPlayerClass(75,1496.9175,-690.3009,94.7500,177.7114,24,300,25,300,29,500); //
	AddPlayerClass(102,1496.9175,-690.3009,94.7500,177.7114,24,300,25,300,30,500); //
	AddPlayerClass(103,1496.9175,-690.3009,94.7500,177.7114,24,300,25,300,29,500); //
	AddPlayerClass(104,1496.9175,-690.3009,94.7500,177.7114,24,300,25,300,30,500); //

	AddStaticVehicle(470,1254.4850,-806.1432,84.1333,181.8792,43,0);//
	AddStaticVehicle(470,1249.3092,-805.3998,84.1315,182.2304,43,0);//
	AddStaticVehicle(470,1242.5201,-813.0634,84.1336,177.7789,43,0);//
	AddStaticVehicle(470,1245.1660,-741.9871,94.9025,22.9656,43,0);//
	AddStaticVehicle(470,1238.2808,-745.0887,95.4304,23.1017,43,0);//
	AddStaticVehicle(522,1268.7540,-814.2528,83.7079,177.9879,86,16);//
	AddStaticVehicle(522,1265.8370,-814.4905,83.7119,180.2646,86,16);//
	AddStaticVehicle(522,1264.6200,-814.4957,83.7109,172.9588,86,16);//
	AddStaticVehicle(522,1262.1163,-814.4503,83.7047,180.2676,86,16);//
	AddStaticVehicle(522,1258.4558,-814.4160,83.7115,178.3215,86,16);//
	AddStaticVehicle(522,1517.3022,-697.1550,94.3192,89.2545,5,85);//
	AddStaticVehicle(522,1516.9921,-694.2068,94.3191,92.1424,5,85);//
	AddStaticVehicle(522,1516.8472,-691.7002,94.3242,88.8201,5,85);//
	AddStaticVehicle(522,1517.5687,-688.2734,94.3207,92.7422,5,85);//
	AddStaticVehicle(522,1518.5118,-685.0089,94.3134,89.0410,5,85);//
	AddStaticVehicle(470,1460.4401,-661.0147,94.7462,178.6505,43,0);//
	AddStaticVehicle(470,1465.4727,-661.3074,94.7414,181.3076,43,0);//
	AddStaticVehicle(470,1474.1803,-661.9484,94.7438,180.1781,43,0);//
	AddStaticVehicle(470,1503.0111,-704.3004,94.7448,151.4891,43,0);//
	AddStaticVehicle(470,1490.3776,-704.3128,94.7432,213.9106,43,0);//
	AddStaticVehicle(487,1465.3071,-687.2051,94.9263,177.1832,85,5);//
	AddStaticVehicle(487,1291.1893,-787.8260,96.6343,179.4475,86,16);//

//Trains

//	AddStaticVehicle(537,-1943.3127,158.0254,27.0006,357.3614,121,1);

//	AddStaticVehicle(569,-1943.3127,158.0254,27.0006,357.3614,121,1);

//	AddStaticVehicle(569,-1943.3127,158.0254,27.0006,357.3614,121,1);

//	AddStaticVehicle(569,-1943.3127,158.0254,27.0006,357.3614,121,1);

//Pickups

	AddStaticPickup(370, 15, -2209.4707,294.1174,35.1172); // jetpack

	AddStaticPickup(370, 15, -1765.4392,-174.7473,3.5547); // jetpack

	SetTimer("GameModeExitFunc", gRoundTime, 0);

	return 1;

 }



//-----------------------------------------------------------
public OnPlayerCommandText(playerid, cmdtext[])
{
	new string[256];
	new playermoney;
	new sendername[MAX_PLAYER_NAME];
	new giveplayer[MAX_PLAYER_NAME];
	new cmd[256];
	new giveplayerid, moneys, idx;

	cmd = strtok(cmdtext, idx);

	if(strcmp(cmd, "/help", true) == 0) {
		SendPlayerFormattedText(playerid,"Los Santos GangWar by Pako.",0);
		SendPlayerFormattedText(playerid,"Type: /objective : to find out what to do in this gamemode.",0);
		SendPlayerFormattedText(playerid,"Type: /givecash [playerid] [money-amount] to send money to other players.",0);
		SendPlayerFormattedText(playerid,"Type: /tips : to see some tips from the creator of the gamemode.", 0);
    return 1;
	}
	if(strcmp(cmd, "/objective", true) == 0) {
		SendPlayerFormattedText(playerid,"This gamemode is faily open, there's no specific win / endgame conditions to meet.",0);
		SendPlayerFormattedText(playerid,"In LS TDM , when you kill a player, you will receive whatever money they have.",0);
		SendPlayerFormattedText(playerid,"Consequently, if you have lots of money, and you die, your killer gets your cash.",0);
		SendPlayerFormattedText(playerid,"However, you're not forced to kill players for money, you can always gamble in the", 0);
		SendPlayerFormattedText(playerid,"Casino's.", 0);
    return 1;
	}
	if(strcmp(cmd, "/tips", true) == 0) {
		SendPlayerFormattedText(playerid,"Spawning with just M4/Ak47/Mp5, Deagle and Shotgun",0);
		SendPlayerFormattedText(playerid,"gamemode is to Kill the other Team",0);
		SendPlayerFormattedText(playerid,"most cash. Once you've got the most cash, the idea is to stay alive(with the",0);
		SendPlayerFormattedText(playerid,"cash intact)until the game ends, simple right ?", 0);
    return 1;
	}

	if(strcmp(cmd, "/givecash", true) == 0) {
	    new tmp[256];
		tmp = strtok(cmdtext, idx);

		if(!strlen(tmp)) {
			SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
			return 1;
		}
		giveplayerid = strval(tmp);

		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp)) {
			SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
			return 1;
		}
 		moneys = strval(tmp);

		//printf("givecash_command: %d %d",giveplayerid,moneys);


		if (IsPlayerConnected(giveplayerid)) {
			GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
			GetPlayerName(playerid, sendername, sizeof(sendername));
			playermoney = GetPlayerMoney(playerid);
			if (moneys > 0 && playermoney >= moneys) {
				GivePlayerMoney(playerid, (0 - moneys));
				GivePlayerMoney(giveplayerid, moneys);
				format(string, sizeof(string), "You have sent %s(player: %d), $%d.", giveplayer,giveplayerid, moneys);
				SendClientMessage(playerid, COLOR_YELLOW, string);
				format(string, sizeof(string), "You have recieved $%d from %s(player: %d).", moneys, sendername, playerid);
				SendClientMessage(giveplayerid, COLOR_YELLOW, string);
				printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
			}
			else {
				SendClientMessage(playerid, COLOR_YELLOW, "Invalid transaction amount.");
			}
		}
		else {
				format(string, sizeof(string), "%d is not an active player.", giveplayerid);
				SendClientMessage(playerid, COLOR_YELLOW, string);
			}
		return 1;
	}

	// PROCESS OTHER COMMANDS


	return 0;
}


//----------------------------------------------------------



public OnPlayerSpawn(playerid)

{

	SetPlayerInterior(playerid,0);

	if(gTeam[playerid] == TEAM_GROVE) {

	SetPlayerColor(playerid,COLOR_GREEN); // Green

  }




	else if(gTeam[playerid] == TEAM_BALLAS) {

	SetPlayerColor(playerid,COLOR_BLUE); // Blue

		}


	

	return 1;

}



//------------------------------------------------------------------------------







//------------------------------------------------------------------------------



public SetupPlayerForClassSelection(playerid)

{

	SetPlayerInterior(playerid,14);

	SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);

	SetPlayerFacingAngle(playerid, 90.0);

	SetPlayerCameraPos(playerid,256.0815,-43.0475,1003.0234);

	SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);

}



//------------------------------------------------------------------------------



public OnPlayerRequestClass(playerid, classid)

{

	SetPlayerClass(playerid, classid);

	SetupPlayerForClassSelection(playerid);

	gPlayerClass[playerid] = classid;

	switch (classid) {

	    case 0..7:

	        {

				GameTextForPlayer(playerid, "~g~Grove", 500, 3);

			}

		case 8..16:

		    {

				GameTextForPlayer(playerid, "~g~Ballas", 500, 3);



}
}

	return 1;

}



//------------------------------------------------------------------------------



public GameModeExitFunc()

 {

	GameModeExit();

	return 1;

 }


//------------------------------------------------------------------------------



SetPlayerClass(playerid, classid) {

	if(classid == 0) {

	gTeam[playerid] = TEAM_GROVE;

	} else if(classid == 1) {

	gTeam[playerid] = TEAM_BALLAS;



	}

}




public SendPlayerFormattedText(playerid, const str[], define)
{
	new tmpbuf[256];
	format(tmpbuf, sizeof(tmpbuf), str, define);
	SendClientMessage(playerid, 0xFFFF00AA, tmpbuf);
}

public SendAllFormattedText(playerid, const str[], define)
{
	new tmpbuf[256];
	format(tmpbuf, sizeof(tmpbuf), str, define);
	SendClientMessageToAll(0xFFFF00AA, tmpbuf);
}

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;
}