capture zone - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: capture zone (
/showthread.php?tid=595446)
capture zone -
GeneralAref - 03.12.2015
how to create basic capture zone?with check point and countdown.
Re: capture zone -
GeneralAref - 03.12.2015
Nothing ?
Re: capture zone -
gurmani11 - 03.12.2015
Use ****** next time
https://sampforum.blast.hk/showthread.php?tid=353267
https://sampforum.blast.hk/showthread.php?tid=584540
https://sampforum.blast.hk/showthread.php?tid=453013
Re: capture zone -
SilverStand - 03.12.2015
If you got a function like "GetTeamArea" then you need to replace "if(gTeam[i] ==)"
Add this at the area capture
NOTE: You don't have to add the loops everywhere. At the top of the public function start with "for(new i; i < MAX_PLAYERS; i++)".
Open with a bracket and then end with a bracket.
Код:
for(new i; i < MAX_PLAYERS; i++)
{
if(gTeam[i] == gTeam[playerid])
{
SetPVarInt(i, "areaTaken/*add the area here for example Area69*/", 1);
}
}
Add this when he enters the area
Код:
for(new i; i < MAX_PLAYERS; i++)
{
if(gTeam[i] == /* add team here*/ && (GetPVarInt(i, "areaTaken/*add the area here for example Area69*/") == 1))
{
SendClientMessage(playerid, "Your team has already taken over this area");
SetPVarInt(playerid, "team/*team name*/_area/*area name*/", 1);
}
}
Add this when the area is taken over from an other team
Код:
for(new i; i < MAX_PLAYERS; i++)
{
if(GetPVarInt(i, teamEurope_areaArea69) == 1) // THIS IS AN EXAMPLE
{
SetPVarInt(i, teamEurope_areaArea69, 0);
}
if(gTeam[i] == /* add team here*/ && (GetPVarInt(i, "areaTaken/*add the area here for example Area69*/") == 1))
{
SetPVarInt(playerid, "team/*team name*/_area/*area name*/", 1);
}
}
Re: capture zone -
GeneralAref - 03.12.2015
Quote:
Originally Posted by gurmani11
|
i use ****** but im not under stand that.
Re: capture zone -
GeneralAref - 03.12.2015
i use this but dosent work:
http://******************/post/10721/Advanced_Capture_Zone_Creator_[Unique_and_useful!]/Jarnu/other/tool
Код:
#include <streamer> //Important include you need to have streamer in-case you want this to work!
//Variables (Put them after your includes)
new iCP[MAX_PLAYERS];
new UnderAttack[30];
new Captured[30];
new CP[30];
new Zone[30];
new timer[MAX_PLAYERS][30];
new CountVar[MAX_PLAYERS] = 25;
new InCP[MAX_PLAYERS][30];
new CountTime[MAX_PLAYERS];
//=================================
new gTeam[MAX_PLAYERS]; //Team variable. ignore if you already got
#define TEAM_ARMY 0 //Ignore if you already got team defines
#define TEAM_TERRORIST 1 //Ignore if you already got team defines
#define TEAM_NONE 2 //Ignore if you already got team defines
#define ARMY_COLOR 0x375FFFFF
#define TERRORIST_COLOR 0xFF0000FF
//========Zone=Defines=============
#define cz1 0
//=================================
//========OnGameModeInit Codes============
CP[cz1] = CreateDynamicCP("220.6493, 1420.9388")
Zone[cz1] = GangZoneCreate("105.1009, 1319.6, 338.6584, 1494.768")
UnderAttack[cz1] = -1
Captured[cz1] = -1
tCP[cz1] = TEAM_NONE
//========== OnPlayerConnect codes ======
iCP[playerid] = -1;
InCP[playerid][GAS] = 0;
if(tCP[cz1] == TEAM_ARMY) return GangZoneShowForPlayer(playerid, Zone[cz1], 0x375FFFFF);
else if(tCP[cz1] == TEAM_TERRORIST) return GangZoneShowForPlayer(playerid, Zone[cz1], 0xFF0000FF);
//=========== OnPlayerDisconnect codes ==
if(InCP[playerid][cz1] == 1)
{
UnderAttack[cz1] = 0;
}
//==========================================
//==========OnPlayerDeath Codes===================
KillTimer(timer[playerid][cz1]);
KillTimer(CountTime[playerid]);
UnderAttack[cz1] = 0;
//==========================================
//=======OnPlayerEnterDynamicCP (Main codes!)===========
//You can just copy paste the following in-case you didn't got the call back defined already!
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
if(checkpointid == CP[cz1])
{
if(UnderAttack[cz1] == 1)
{
SendClientMessage(playerid, 0xFF0000FF,"This zone is already being captured!");
}
else if(gTeam[playerid] == tCP[cz1])
{
SendClientMessage(playerid, 0xFF0000FF,"This zone is already being captured!");
}
else if(gTeam[playerid] == TEAM_NONE)
{
SendClientMessage(playerid, 0xFF0000FF,"You have no team so you cannot capture!");
}
else
{
UnderAttack[cz1] = 1;
timer[playerid][cz1] = SetTimerEx("SetCaptureZone", 25000, false,"i",playerid);
CountTime[playerid] = SetTimerEx("CountDown", 1, false,"i", playerid);
iCP[playerid] = cz1;
InCP[playerid][cz1] = 1;
Captured[cz1] = 0;
if(gTeam[playerid] == TEAM_ARMY)
{
GangZoneFlashForAll(Zone[cz1], ARMY_COLOR);
}
else if(gTeam[playerid] == TEAM_TERRORIST)
{
GangZoneFlashForAll(Zone[cz1], TERRORIST_COLOR);
}
new string[128], name[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string),"%s is trying to capture thecz1",name);
SendClientMessageToAll(ARMY_COLOR, string);
}
}
return 1;
}
//================================OnPlayerLeaveDynamicCP codes=============================
//You can just copy paste the following in-case you didn't got the call back defined already!
public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
if(checkpointid == CP[cz1])
{
if(Captured[cz1] == 1)
{
GangZoneStopFlashForAll(Zone[cz1]);
UnderAttack[cz1] = 0;
InCP[playerid][cz1] = 0;
tCP[cz1] = gTeam[playerid];
if(gTeam[playerid] == TEAM_ARMY)
{
GangZoneShowForAll(Zone[cz1], ARMY_COLOR);
}
else if(gTeam[playerid] == TEAM_TERRORIST)
{
GangZoneShowForAll(Zone[cz1], TERRORIST_COLOR);
}
KillTimer(timer[playerid][cz1]);
KillTimer(CountTime[playerid]);
}
else if(Captured[cz1] == 0)
{
SendClientMessage(playerid, TERRORIST_COLOR,"You have left the flag you have failed to capture the zone!");
UnderAttack[cz1] = 0;
InCP[playerid][cz1] = 0;
GangZoneStopFlashForAll(Zone[cz1]);
KillTimer(timer[playerid][cz1]);
KillTimer(CountTime[playerid]);
}
}
return 1;
}
//======================SetCaptureZone function!====================
//You can just copy paste the following under the above callback!
forward SetCaptureZone(playerid);
public SetCaptureZone(playerid)
{
if(iCP[playerid] == cz1)
{
SetPlayerScore(playerid, GetPlayerScore(playerid)+5);
GivePlayerMoney(playerid, 5000);
SendClientMessage(playerid, ARMY_COLOR,"Congratulations! You have successfully captured the Gas Station! You earned +5 scores and +$5000!");
tCP[cz1] = gTeam[playerid];
if(gTeam[playerid] == TEAM_ARMY)
{
GangZoneShowForAll(Zone[cz1], ARMY_COLOR);
}
else if(gTeam[playerid] == TEAM_TERRORIST)
{
GangZoneShowForAll(Zone[cz1], TERRORIST_COLOR);
}
GangZoneStopFlashForAll(Zone[cz1]);
Captured[cz1] = 1;
KillTimer(CountTime[playerid]);
KillTimer(timer[playerid][cz1]);
}
return 1;
}
//====================CountTime Function======================
//You can just copy paste the following under the above function!
forward CountDown(playerid);
public CountDown(playerid)
{
CountVar[playerid]--;
if(CountVar[playerid] == 0)
{
CountVar[playerid] = 25;
KillTimer(CountTime[playerid]);
}
else
{
new str[124];
format(str, sizeof(str),"~n~~n~~n~~n~~n~~n~~r~%d/~y~25 ~w~Seconds left~n~~g~to capture", CountVar[playerid]);
GameTextForPlayer(playerid, str, 1000, 3);
}
CountTime[playerid] = SetTimerEx("CountDown", 1000, false,"i", playerid);
return 1;
}
//-------------Capture Zone Codes Created using J_Capture Zone tool!-----------//