15.07.2016, 11:46
PHP код:
#include <a_samp>
#include <zcmd>
#include <streamer>
#define ARMY 0 //Army Hotel
#define TEAM_Eurasia 0
#define TEAM_USA 1
#define TEAM_NONE
#define TEAM_ZONE_Eurasia_COLOR 0x15FF0055
#define TEAM_ZONE_USA_COLOR 0x0080FF55
#define C_RED 0xFF0000FF
#define red 0xFF0000AA
#define cred "{FF0000}"
#define green 0x33FF33AA
#define COLOR_WHITE "{FFFFFF}"
new tCP[2]; // tCP variable is presenting the team capture point.
new bool:UnderAttack[2]; // UnderAttack bool is presenting is that the zone under attacked or not.
new CP[2]; // CP variable is presenting the Capture point
new Zone[2]; // Zone variable is presenting the Zone Area
new Captured[MAX_PLAYERS][2]; //Captured variable is presenting is that zone captured or not
new timer[MAX_PLAYERS][2]; // Timer variable is for zone capturing time
new CountVar[MAX_PLAYERS][2]; //Countvar variable is for zone countdown
new IsPlayerCapturing[MAX_PLAYERS][2];// IsPlayerCapturing Variable is to detect is that player capturing or not!
new gTeam[MAX_PLAYERS]; // This variable is to detect ur team mate.
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by FrAnKiN");
print("----------------------------------\n");
}
#endif
public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
{
tCP[ARMY] = TEAM_NONE; // We set this team none so when the Game Mode start it would be capture by none team so all team can capture the zone.
CP[ARMY] = CreateDynamicCP(-551.5466,2593.7825,53.9348, 3, -1, -1, -1, 100.0); // Ok this is an Zone co ordinates to create an zone u can paste ur co ordinates where u want to create an area
Zone[ARMY] = GangZoneCreate(-497.263885, 2657.306396, -632.633850, 2531.431152); // same as i said this is ur co ordinates add this
Create3DTextLabel( "Army Hotel Capture Area", 0xA00000FF, -497.263885, 2657.306396, -632.633850, 50.0, 0, 1 ); // you can also add create 3dlabel on that location but it's optional so u can skip this.
CreatePickup(1314, 1, -551.5466, 2593.7825, 53.9348, -1);// And this is an also optional if u want add this u can otherwise u can skip it.
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
IsPlayerCapturing[playerid][ARMY] = 0; // So when player connect IsPlayerCapturing will be 0 otherwise you will face troubles in ur script
CountVar[playerid][ARMY] = 25; // We Set Gang Zone time to 25 seconds that 25 representing 25 seconds
SetPlayerMapIcon(playerid, 2, -551.5466, 2593.7825, 53.9348, 19, MAPICON_GLOBAL); // This is an SetPlayerMapIcon to show ur zone on map you can also set this MAPICON_LOCAL then it would show when u go near to the zone
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(Captured[playerid][ARMY] == 0 && IsPlayerCapturing[playerid][ARMY] == 1) // This is now when u left so it would cancel the capturing to prevent bugging
{
LeavingArmyHotel(playerid); // This will contain some killtimer to stop capturing from the player and set it to normal condition
}
return 1;
}
public OnPlayerSpawn(playerid)
{
if(Captured[playerid][ARMY] == 0 && IsPlayerCapturing[playerid][ARMY] == 1) // Ok this is the thing when u spawn so it would cancel the capturing to prevent bugging :)
{
LeavingArmyHotel(playerid); // // This will contain some killtimer to stop capturing from the player and set it to normal condition
}
switch(tCP[ARMY]) // Okay we are using switch here so it fast then if else structure
{
case TEAM_NONE: GangZoneShowForAll(Zone[ARMY], -66); // okay -66 is an simple White color and when the gamemode start it would be white
case TEAM_Eurasia: GangZoneShowForAll(Zone[ARMY], TEAM_ZONE_Eurasia_COLOR); // if the zone is captured by team Eurasia then the zone would be green
case TEAM_USA: GangZoneShowForAll(Zone[ARMY], TEAM_ZONE_USA_COLOR); // if the zone is captured by team USA then the zone would be blue
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(Captured[playerid][ARMY] == 0 && IsPlayerCapturing[playerid][ARMY] == 1) // This is now when u died so it would cancel the capturing to prevent bugging
{
LeavingArmyHotel(playerid); //This is an if u leave the capture area then it would cancel as we all know :)
}
return 1;
}
CaptureZoneMessage(playerid, messageid); // we create this thing to safe our some time
{
switch(messageid) // we create message id and 2 cases and we use them this in next steps
{
case 1:
{
SendClientMessage(playerid, red,"You cannot capture while in vehicle!");
}
case 2:
{
SendClientMessage(playerid, red,"This zone is already being taken over by your team!");
}
}
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
//==============================================================================
//=================[ OnPlayerEnter and OnPlayerLeave Dynamic CP]================
//==============================================================================
public OnPlayerEnterDynamicCP(playerid, checkpointid) // we don't need to forward that cuz this is already public function so we don't need to forward that
{ // Bracket 1
if(checkpointid == CP[ARMY]) // So, When u enter on the zone all the process will be start from their.
{ // Bracket 2
if(UnderAttack[ARMY] == false) // This is Checking is that zone in underattack or not if it is then it will not let you capture.
{ // bracket 3
if(tCP[ARMY] != gTeam[playerid]) //This is checking that zone is captured by ur team or not if it's not u can capture if it's already capture by ur team u can't capture this zone
{ //bracket 4
ActiveArmyHotel(playerid); // this is the main thing which is whole capture zone depend on.
} else return SendClientMessage(playerid, red,"*This zone is already captured by your team!");
} else return CaptureZoneMessage(playerid, 2);
}
return 1;
}
public OnPlayerLeaveDynamicCP(playerid, checkpointid) // we don't need to forward that cuz this is already public function so we don't need to forward that
{
if(checkpointid == CP[ARMY] && Captured[playerid][ARMY] == 0 && IsPlayerCapturing[playerid][ARMY] == 1 && !IsPlayerInDynamicCP(playerid, CP[ARMY])) // This is an if u leave the capture area then it would cancel as we all know :)
{
LeavingArmyHotel(playerid); // This function will contain some killtimer to stop capturing from the player and set it to normal condition
}
return 1;
}
//====================================================
//==================forward ActiveZone================
//==================Public ActiveZone=================
forward ActiveSnakeFarm(playerid);
public ActiveSnakeFarm(playerid)
{
if(UnderAttack[ARMY] == false) // This Variable is checking that the zone is capturing or not
{
if(!IsPlayerInAnyVehicle(playerid)) //This thing is checking that the player is in vehicle or not
{
// switch(PlayerInfo[playerid][dRank]) //This is an optional Part if u don't want this u can skip but if u got Donor/Vip System in ur script this can be useful in ur script.
//{
// case 0: //donor level 0 means Normal Player
// {
timer[playerid][ARMY] = SetTimerEx("ArmyHotel", 25000, false,"i",playerid); // this is an timer of 25 seconds to capture an zone
CountVar[playerid][ARMY] = 25; // as we set 25 second timer so we set zone timer 25 which mean 25 seconds we add this to here to prevent bugs
SendClientMessage(playerid, 0xFFFFFFFF,">> Stay in this checkpoint to capture! <<");
//}
/*case 1: //donor level 1
{
timer[playerid][ARMY] = SetTimerEx("SnakeFarm", 22000, false,"i",playerid);
CountVar[playerid][ARMY] = 22;
SendClientMessage(playerid, 0xFFFFFFFF,">> Stay in this checkpoint to capture! <<");
}
case 2: //donor level 2
{
timer[playerid][ARMY] = SetTimerEx("SnakeFarm", 20000, false,"i",playerid);
CountVar[playerid][ARMY] = 20;
SendClientMessage(playerid, 0xFFFFFFFF,">> Stay in this checkpoint to capture! <<");
}
case 3: //donor level 3
{
timer[playerid][ARMY] = SetTimerEx("SnakeFarm", 17000, false,"i",playerid);
CountVar[playerid][ARMY] = 17;
SendClientMessage(playerid, 0xFFFFFFFF,">> Stay in this checkpoint to capture! <<");
}
}*/
UnderAttack[ARMY] = true; // We set Under Attack to 1 so no one capture when u capturing this zone as jimmych got bugged of multiple capturing zone
Captured[playerid][ARMY] = 0; // We use this cause is still capturing it until it capture we can't set this to 1
IsPlayerCapturing[playerid][ARMY] = 1; // This variable means that player is capturing this zone if we add this in for(new loop or Foreach loop then it will start timer for each and each player who enter in this capture point so we don't need to use this in loop
switch(gTeam[playerid]) // This Switch to for our team mates
{
case TEAM_Eurasia: GangZoneFlashForAll(Zone[ARMY], TEAM_ZONE_Eurasia_COLOR); //If Eurasia team is capturing then it would flash in Eurasia color which is green.
case TEAM_USA: GangZoneFlashForAll(Zone[ARMY], TEAM_ZONE_USA_COLOR); // If USA team is capturing then it would flash in USA color which is blue..
}
//------Message-----
switch(tCP[ARMY])
{
case TEAM_NONE: // This msg u will get when u capture it once
{
SendClientMessage(playerid, COLOR_WHITE,"This zone is not controlled by any team");
}
case TEAM_Eurasia: // This msg u will get when u capture it from Eurasia
{
SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team <Eurasia>");
SendTeamMessage(TEAM_Eurasia, green,"*Snakes Farm is under attack!");
}
case TEAM_USA: // This msg u will get when u capture it from USA
{
SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team "C_RED"<USA>");
SendTeamMessage(TEAM_USA, green,"*Snakes Farm is under attack!");
}
}
}
else return CaptureZoneMessage(playerid, 1);
}
else return CaptureZoneMessage(playerid, 2);
return 1;
}
forward SnakeFarmCaptured(playerid);
public SnakeFarmCaptured(playerid)
{
Captured[playerid][ARMY] = 1;//Now that variable is showed that the zone is belong to u
UnderAttack[ARMY] = false; // This bool is false for now cuz that zone is captured and now it is not in under attack
IsPlayerCapturing[playerid][ARMY] = 0;// This is for now that no one capturing this zone.
KillTimer(timer[playerid][ARMY]); // It kill the timer to be prevent bugged
CountVar[playerid][ARMY] = 25; // We set back to zone to 25 seconds
GivePlayerScore(playerid, 5); // Okay we are giving 5 score to that person who capture this zone
GivePlayerMoney(playerid, 5000);// Same we giving the player 5000$ for capturing Army Hotel
SendClientMessage(playerid, green,"You got +5 scores and +$5000 cash for this area!");
//==========================================================================
foreach(Player, i) // Foreach loop cuz it's efficient
{
if(gTeam[i] == gTeam[playerid] && i != playerid) // first thing we create this loop to give all team mates 1 score as an reward
{
SendClientMessage(i, 0xFFFFFFFF,"*Your team has captured "cred"Army Hotel"cwhite"! You received +1 score for it!");
GivePlayerScore(i, 1); // Giving score to all of them
}
}
//==========================================================================
tCP[ARMY] = gTeam[playerid]; // Now we go to that zone to stop the flash.
GangZoneStopFlashForAll(Zone[ARMY]);
//==========================================================================
switch(gTeam[playerid]) // this is switch to stop flash for all teams
{
case TEAM_Eurasia: GangZoneShowForAll(Zone[ARMY], TEAM_ZONE_Eurasia_COLOR);
case TEAM_USA: GangZoneShowForAll(Zone[ARMY], TEAM_ZONE_USA_COLOR);
}
//==========================================================================
return 1;
}
forward LeavingSnakeFarm(playerid);
public LeavingSnakeFarm(playerid)
{
Captured[playerid][ARMY] = 1; // Okay this is 1 cuz it let the current team player that the zone is still belong to old team when u left
UnderAttack[ARMY] = false; // We set underattack bool to false cuz the old player left the snake farm
KillTimer(timer[playerid][ARMY]); // Okay we killing the timer.
CountVar[playerid][ARMY] = 25; // We set the zone back to it's 25 seconds
GangZoneStopFlashForAll(Zone[ARMY]); // We set the snake to stop it flash
SendClientMessage(playerid, red,"*You have been failed to capture this zone!");
IsPlayerCapturing[playerid][ARMY] = 0; // We set the zone that the zone u left it become 0 cuz u left it :D
return 1;
}
forward ArmyHotel(playerid);
public ArmyHotel(playerid)
{
ArmyHotelCaptured(playerid); // this timer will be over on 25 second and then it will capture OH YEA :D
return 1;
}
GivePlayerScore(playerid, score)
{
SetPlayerScore(playerid, GetPlayerScore(playerid)+5);
return 1;
}