All pastes #835511 Raw Edit

Stuff

public text v1 · immutable
#835511 ·published 2007-12-28 22:20 UTC
rendered paste body
#include <a_samp>

#define TEAM_GREEN 1
#define TEAM_BLUE 2
#define TEAM_SPEC 3
#define TEAM_GREEN_COLOR 0x00FF77AA // GREEN
#define TEAM_BLUE_COLOR 0x33CCFFAA // BLUE
#define COLOR_RED 0xFF0000AA // RED
#define COLOR_GREY 0xCCCCCCAA // Grey, not GRAY
#define COLOR_WHITE 0xFFFFFFAA // White
#define COLOR_YELLOW 0xFFFF00AA // Yeller
forward UnJailTeamKiller();
new bool:gGreenFlagTaken = false;
new bool:gBlueFlagTaken = false;
new gTeam[MAX_PLAYERS];
new gGreenPlayers = 0;
new gBluePlayers = 0;
new gSpecPlayers = 0;
new Text:gYourTeam[MAX_PLAYERS];
new gBlueScore = 0;
new gGreenScore = 0;
new bool:gFirst[MAX_PLAYERS] = true;
new Menu:gPunishMenu;
new bool:IsJailed[MAX_PLAYERS] = false;
new gTeamKilledKillerId;
new gTclass[MAX_PLAYERS] = 0;
new Float:GreenSpawn[][3] =
{
 // Positions, (X, Y, and Z)
   {-1131.5358,1052.8577,1345.7502},
   {-1132.2432,1048.7261,1345.7507},
   {-1133.7327,1035.0548,1345.7434},
   {-1131.9167,1062.2585,1345.7604},
   {-1132.2800,1094.5775,1345.7935}
};
new Float:BlueSpawn[][3] =
{
// Also, X Y and Z coords
	{-973.9919,1068.3162,1345.0004},
	{-973.7117,1094.7766,1344.9829},
	{-973.0699,1083.6094,1344.9923},
	{-974.0729,1056.8716,1345.0128},
	{-973.6195,1024.5537,1345.0481}
};

// This is a comment

/*This is
a lot
of comments
in a few lines */

main()
{
	print("\n----------------------------------");
	print("BattleZone Capture The Flag by Fry ");
	print("----------------------------------\n");
}



ShowTeamJoinMessage(playerid)
{
		if (gFirst[playerid] == true)
		{
	    SendClientMessage(playerid, COLOR_YELLOW, "Please ensure you have read /help, /commands and /rules.");
		if (gTeam[playerid] == TEAM_BLUE)
		{
			new name[MAX_PLAYER_NAME];
			GetPlayerName(playerid, name, sizeof(name));
			new bjoin[256];
			format(bjoin, sizeof(bjoin), "<Teams> %s joined the blue team.", name);
			SendClientMessageToAll(TEAM_BLUE_COLOR, bjoin);
			gYourTeam[playerid] = TextDrawCreate(10.0, 100.0, "team blue");
			TextDrawUseBox(gYourTeam[playerid], 1);
			TextDrawShowForPlayer(playerid, gYourTeam[playerid]);
		}
		if (gTeam[playerid] == TEAM_GREEN)
		{
		    new name[MAX_PLAYER_NAME];
			GetPlayerName(playerid, name, sizeof(name));
			new gjoin[256];
			format(gjoin, sizeof(gjoin), "<Teams> %s joined the green team.", name);
			SendClientMessageToAll(TEAM_GREEN_COLOR, gjoin);
			gYourTeam[playerid] = TextDrawCreate(10.0, 100.0, "team green");
			TextDrawUseBox(gYourTeam[playerid], 1);
			TextDrawShowForPlayer(playerid, gYourTeam[playerid]);
		}
		}
}

SetRandomTeamSpawnPos(playerid)
{
	if (gTeam[playerid] == TEAM_BLUE)
	{
		new iRandom = random(5); // 'random' is a function, not a symbol
	 	// Due to the 5 spawns, generate a number between 0 and 4
		SetPlayerPos(playerid, BlueSpawn[iRandom][0], BlueSpawn[iRandom][1], BlueSpawn[iRandom][2]);
		// SetPlayerPos to the random spawn information
		SetPlayerFacingAngle(playerid, 90.0);
		SetCameraBehindPlayer(playerid);
	}
	if (gTeam[playerid] == TEAM_GREEN)
 	{
		new iRandom = random(5);
	    SetPlayerPos(playerid, GreenSpawn[iRandom][0], GreenSpawn[iRandom][1], GreenSpawn[iRandom][2]);
	    SetPlayerFacingAngle(playerid, 270.0);
	    SetCameraBehindPlayer(playerid);
	}
}

ShowTeamScores()
{
	if (gBlueScore > gGreenScore)
	{
	//Say that blue is winning above score in TEAM_BLUE_COLOR
	}
	if (gGreenScore > gBlueScore)
	{
	//Say that GREEN is winning above the score in TEAM_GREEN_COLOR
	}
	if (gGreenScore == gBlueScore)
	{
	// Say that it is a tie in COLOR_GREY :)
	}
	//A text draw here using gBlueScore and gGreenScore
	// AKA: Green: 0 Blue: 0
	// Preferably in the correct colors
}

SetPlayerTeamFromClass(playerid, classid)
{
	if (classid == 1)
	{
		gTeam[playerid] = TEAM_GREEN;
	}
	else if (classid == 0)
	{
		gTeam[playerid] = TEAM_BLUE;
	}
}

SetPlayerToTeamColor(playerid)
{
	if (gTeam[playerid] == TEAM_GREEN)
	{
		SetPlayerColor(playerid, TEAM_GREEN_COLOR);
		gGreenPlayers++;
	}
	else if (gTeam[playerid] == TEAM_BLUE)
	{
		SetPlayerColor(playerid, TEAM_BLUE_COLOR);
		gBluePlayers++;
	}
}

public OnGameModeInit()
{

	SetGameModeText("BZ CTF v0.2b");
	EnableStuntBonusForAll(0);
	DisableInteriorEnterExits();
	AllowInteriorWeapons(1);
    UsePlayerPedAnims();
    ShowPlayerMarkers( 0 );
   	EnableZoneNames( 0 );
	EnableTirePopping(0);
	AddPlayerClass(275, -973.9919,1068.3162,1345.0004,0, 29, 150, 24, 35, 0, 0); // Blue spawn -- no statue
	AddPlayerClass(276, -1131.5358,1052.8577,1345.7502,0, 29, 150, 24, 35, 0, 0); // Green spawn -- statue near base
	CreateObject(3279,-1131.71,1041.71,1337.67, 0, 0, 180); // Green Base Watch-Tower
	CreateObject(3279,-974.006,1077.21,1337.67, 0, 0, 0); //Blue Base Watch-Tower
	CreateObject(1559,-1130.9127,1057.8650,1348.4141, 0, 0, 0); // Green base flag
	CreateObject(1559, -974.0116,1061.2657,1347.6733, 0, 0, 0); // Blue base flag
 	AddStaticPickup(358, 2, -973.8896,1076.9581,1354.7482); // Blue sniper rifle
 	AddStaticPickup(358, 2, -1131.6648,1041.6102,1354.7482); // Green sniper rifle
	new Bfag = AddStaticVehicle(462, -975.5077,1089.7086,1344.5709,90.0,7,0);
	new Gfag = AddStaticVehicle(462, -1131.4498,1029.1062,1345.3229,270.0, 16, 0);
    LinkVehicleToInterior(Bfag, 10);
	LinkVehicleToInterior(Gfag, 10);
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	gFirst = true; // Resets their new status
	gTclass[playerid] = classid;
	gTeam[playerid] = TEAM_SPEC;
	gSpecPlayers++;
	SetPlayerColor(playerid, COLOR_WHITE); // White while selecting team or new team
	SetPlayerInterior(playerid, 14);
	SetPlayerPos(playerid, 259.2731,-41.5857,1002.0234);
	SetPlayerFacingAngle(playerid, 90.0);
	SetPlayerCameraPos(playerid, 257.834,-43.1422,1003.12);
	SetPlayerCameraLookAt(playerid, 259.2731,-41.5857,1002.0234);
	return 1;
}

public OnPlayerRequestSpawn(playerid)
{
	gSpecPlayers--;
	return 1;
}

public OnPlayerConnect(playerid)
{
	ShowTeamScores();
	new name[MAX_PLAYER_NAME];
    new string[48];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s (ID:%d) joined the server.", name, playerid);
    printf(string);
	new GreenBase = GangZoneCreate(-1137.5613, 1018.7019, -1124.8693, 1100.4685);
	new BlueBase = GangZoneCreate(-967.8145, 1100.4773, -980.5365, 1018.7019);
	GangZoneShowForAll(GreenBase, TEAM_GREEN_COLOR);
	GangZoneShowForAll(BlueBase, TEAM_BLUE_COLOR);
    SendClientMessageToAll(COLOR_WHITE, string);
    SendClientMessage(playerid, COLOR_YELLOW, "Welcome to Capture the Flag!");
    SendClientMessage(playerid, COLOR_YELLOW, "Please pick a team to begin playing.");
    SetPlayerColor(playerid, COLOR_GREY); // Grey on connection
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	if (gTeam[playerid] == TEAM_BLUE)
	{
	gBluePlayers--;
	}
	if (gTeam[playerid] == TEAM_GREEN)
	{
	gGreenPlayers--;
	}
	if (gTeam[playerid] == TEAM_SPEC)
	{
	gSpecPlayers--;
	}
	new name[MAX_PLAYER_NAME];
    new string[48];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s left the server.", name);
    printf(string);
    SendClientMessageToAll(COLOR_WHITE, string);
	return 1;
}

public OnPlayerSpawn(playerid)
{
	SetPlayerTeamFromClass(playerid, gTclass[playerid]);
 	SetRandomTeamSpawnPos(playerid);	//Set the right spawns for the right teams
	ShowTeamJoinMessage(playerid);
 	SetPlayerToTeamColor(playerid);
	SetPlayerInterior(playerid, 10);
 	SetPlayerArmour(playerid, 100.0);
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid, playerid, reason);
	//This is very buggy
	/*if (IsJailed[playerid] == true)
    {
    JailTeamKiller();
    }*/
	if (killerid != INVALID_PLAYER_ID && gTeam[playerid] == gTeam[killerid])
	{
		gTeamKilledKillerId = killerid;
		SendClientMessage(playerid, COLOR_RED, "You have been team-killed!");
	    SendClientMessage(playerid, COLOR_RED, "Choose to punish or forgive your killer.");
        gPunishMenu = CreateMenu("Team-Killed", 1, 0.0, 200.0, 150.0);
		AddMenuItem(gPunishMenu, 0, "Punish");
		AddMenuItem(gPunishMenu, 0, "Forgive");
		ShowMenuForPlayer(gPunishMenu, playerid);
	}
	SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
    gFirst[playerid] = false;
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

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

public OnPlayerText(playerid, text[])
{


	if (text[0] == '!')
	{
		new Message[256];
		new name[MAX_PLAYER_NAME];
		GetPlayerName(playerid, name, sizeof(name));
		format(Message, sizeof(Message), "<TEAM> %s: %s", name, text[1]);
		for (new i = 0; i < MAX_PLAYERS; i++ )
		{
			if (gTeam[playerid] == gTeam[i] && gTeam[playerid] == TEAM_BLUE)
			{
				SendClientMessage(i, TEAM_BLUE_COLOR, Message);
			}
			if (gTeam[playerid] == gTeam[i] && gTeam[playerid] == TEAM_GREEN)
			{
				SendClientMessage(i, TEAM_GREEN_COLOR, Message);
			}
			if (gTeam[playerid] == gTeam[i] && gTeam[playerid] == TEAM_SPEC)
			{
				SendClientMessage(i, COLOR_WHITE, Message);
			}
		}
		return 0;
	}
	
	
	
 	if (strfind(text, "fuck", true) != -1)
 	{
		SendClientMessage(playerid, COLOR_RED, "Do not use bad language!");
		return 0; // Don't echo into the server
 	}
 	if (strfind(text, "cunt", true) != -1)
	{
		SendClientMessage(playerid, COLOR_RED, "Do not use bad language!");
		return 0; // Don't echo into the server
	}
	return 1;
}
public OnPlayerPrivmsg(playerid, recieverid, text[])
{
	if (gTeam[playerid] != gTeam[recieverid])
	{
	SendClientMessage(playerid, COLOR_RED, "You can only PM people on your team.");
	return 0;
	}
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (!strcmp("/kill", cmdtext, true, 5))
	{
		SetPlayerHealth(playerid,0.0); // Set their health to 0, aka kill them
		return 1;
	}
	if (!strcmp(cmdtext, "/me", true, 3))
	{
	    if(cmdtext[3] == 0)
	 	{
	    SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /me [action]");
	    return 1;
		}
		new str[128];
 		GetPlayerName(playerid, str, sizeof(str));
 		format (str, sizeof(str), "* %s %s", str, cmdtext[4]);
 		new playerColor = GetPlayerColor(playerid);
 		SendClientMessageToAll(playerColor, str);
 		return 1;
 	}
	return 0;
}

public OnPlayerInfoChange(playerid)
{
	return 1;
}

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

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

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	if (gTeam[playerid] == TEAM_BLUE && gBlueFlagTaken == false)
	{
	}
	if (gTeam[playerid] == TEAM_GREEN && gGreenFlagTaken == false)
	{
	}
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	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)
{
    new Menu:CurrentMenu = GetPlayerMenu(playerid);
	if(CurrentMenu == gPunishMenu)
	switch(row)
	{
    	case 0: //Punishing
        {
			JailTeamKiller(gTeamKilledKillerId);
            
        }
       	case 1: //Forgiveness
        {
            SendClientMessage(gTeamKilledKillerId, COLOR_YELLOW, "You have been forgiven for team-killing.");
        }
	}

	return 1;
}

new gJailTimer;

JailTeamKiller(killerid)
{
SetPlayerInterior(gTeamKilledKillerId, 10);
SetPlayerPos(gTeamKilledKillerId, 421.769, 2536.52, 10.0);
SetPlayerFacingAngle(gTeamKilledKillerId, 90.0);
ResetPlayerWeapons(gTeamKilledKillerId);
SendClientMessage(gTeamKilledKillerId, COLOR_RED, "You were sent to jail for one minute for a team-kill!");
IsJailed[gTeamKilledKillerId] = true;
gJailTimer = SetTimerEx("UnJailTeamKiller",60000,false,"i", killerid);
}

public UnJailTeamKiller()
{
IsJailed[killerid] = false;
SendClientMessage(killerid, COLOR_YELLOW, "You are free from jail.");
SpawnPlayer(killerid);
KillTimer(gJailTimer);
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}