//Here we will define the teams !
#define TEAM_GROOVE 0
#define TEAM_BALLAS 1
#define TEAM_VAGOS 2
//We will define the colors of the team
#define GROOVE_COLOR 0x0FEA1F96 //here we define that Groove team will be green
#define BALLAS_COLOR 0xBC0EC096 // here we define that Ballas team is rose
#define VAGOS_COLOR 0xDFEF1F96 // here we define that vagos team is yellow
#define MAX_ZONES 3
//this will change if you have other zone, example if you have 5 zones or 5 gang zones you must change this for 5 and if is 6 change it to 6 etc..!
#define MAX_TEAMS 3
new gTeam[MAX_PLAYERS]; //you need define this i will explain later !
//defining zones...!
//well we need define some zones here ! something like this !
//here also we will define the bases for the players !
new GROOVEZ;
new BALLASZ;
new VAGOSZ;
//for the bases will be something like this
new GROOVEB;
new BALLASB;
new VAGOSB; //you can change the name ^ of this ^ whatever do you want !
//now that Bases and Zones are defined we gotta go to OnGameModeInIt
enum Z_Info
{
Float:z_minx,
Float:z_miny,
Float:z_maxx,
Float:z_maxy,
z_team, //team
z_id //the id
}
new ZoneTakeOverTeam[MAX_ZONES];// and this
new ZoneTakeOverTime[MAX_ZONES]; //fixed, define this too !
new ZoneInfo[MAX_ZONES][Z_Info] = {
//here we need post the coord of zones that are capturable
{2437.5,-1722.65625,2525.390625,-1634.765625, TEAM_GROVE},//an example, but this gang zone are defined as GROVEB in OnGameModeInIt
{x,y,z, TEAM_BALLAS},
{x,y,z, TEAM_VAGOS} //here without a comma ,
}; //close
//remember that if you have 4 5 6..etc or more zones capturables you must change #define MAX_ZONES 3 this to the numbers of zones that are you getting.. in this case is 3
//new savetimer;
new zonetimer; // here we define the timer !!! in the zone
KillTimer(zonetimer);//We need define this to define the kill time(You don't say)
//Here we define the spawn of the players ! and here we can define a base if you want, but that base aren't capturable
AddPlayerClass(107,2478.6343,-1662.2228,13.3438,249.9869,0,0,0,0,0,0); // GROOVE SPAWN
AddPlayerClass(104,1961.4006,-1152.5022,26.0251,249.9869,0,0,0,0,0,0); // BALLAS SAWN
AddPlayerClass(108,2804.2061,-1092.7837,30.7285,251.2403,0,0,0,0,0,0); // vagos spawn
//AddPlayerClass(skinid, coord:x, Coord:y, COord:z, angle, here we can add weapons too, weapon ammo, weap2,ammo2,weap3,ammo3);
//we need close it with a ; to avoid many errors !
//This is a example
//well now we need define the BASES ZONES AND ZONES CAPTURABLES !
//Here we need do something like this !
GROOVEZ = GangZoneCreate(2229.4921875,-1731.4453125,2326.171875,-1666.9921875); //here we define that GROOVE zone is now a gang zone but still isn't capturable
BALLASZ = GangZoneCreate(1851.5625,-1453.125,1974.609375,-1353.515625); //same as GROOVE
VAGOSZ = GangZoneCreate(2452.1484375,-1262.6953125,2563.4765625,-1201.171875); //Like groove and ballas
//now we gonna define the bases
GROOVEB = GangZoneCreate(2437.5,-1722.65625,2525.390625,-1634.765625); //here we defined the bases are not capturables but are defined now
BALLASB = GangZoneCreate(1869.140625,-1265.625,2059.5703125,-1148.4375); //now we need show the players that the zone is created go to OnPlayerSpawn
VAGOSB = GangZoneCreate(2742.1875,-1262.6953125,2841.796875,-1163.0859375); // :D !
//now after do these things ! we must define this (is important)
//this for the zones this define that we gonna take a zone and will be capturable but still don't define what zone is capturable
for(new i=0; i<MAX_ZONES; i++)
{
ZoneInfo[i][z_id] = GangZoneCreate(ZoneInfo[i][z_minx], ZoneInfo[i][z_miny], ZoneInfo[i][z_maxx], ZoneInfo[i][z_maxy]);
ZoneTakeOverTeam[i] = -1;
}
public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Blank Script");
KillTimer(zonetimer);//We need define this to define the kill time(You don't say)
//Here we define the spawn of the players ! and here we can define a base if you want, but that base aren't capturable
AddPlayerClass(107,2478.6343,-1662.2228,13.3438,249.9869,0,0,0,0,0,0); // GROOVE SPAWN
AddPlayerClass(104,1961.4006,-1152.5022,26.0251,249.9869,0,0,0,0,0,0); // BALLAS SAWN
AddPlayerClass(108,2804.2061,-1092.7837,30.7285,251.2403,0,0,0,0,0,0); // vagos spawn
//AddPlayerClass(skinid, coord:x, Coord:y, COord:z, angle, here we can add weapons too, weapon ammo, weap2,ammo2,weap3,ammo3);
//we need close it with a ; to avoid many errors !
//This is a example
//i will add a base but later ! i will explain it too ! don't worry
//well now we need define the BASES ZONES AND ZONES CAPTURABLES !
//Here we need do something like this !
GROOVEZ = GangZoneCreate(2229.4921875,-1731.4453125,2326.171875,-1666.9921875); //here we define that GROOVE zone is now a gang zone but still isn't capturable
BALLASZ = GangZoneCreate(1851.5625,-1453.125,1974.609375,-1353.515625); //same as GROOVE
VAGOSZ = GangZoneCreate(2452.1484375,-1262.6953125,2563.4765625,-1201.171875); //Like groove and ballas
//now we gonna define the bases
GROOVEB = GangZoneCreate(2437.5,-1722.65625,2525.390625,-1634.765625); //here we defined the bases are not capturables but are defined now
BALLASB = GangZoneCreate(1869.140625,-1265.625,2059.5703125,-1148.4375); //now we need show the players that the zone is created go to OnPlayerSpawn
VAGOSB = GangZoneCreate(2742.1875,-1262.6953125,2841.796875,-1163.0859375); // :D !
//now after do these things ! we must define this (is important)
//this for the zones this define that we gonna take a zone and will be capturable but still don't define what zone is capturable
for(new i=0; i<MAX_ZONES; i++)
{
ZoneInfo[i][z_id] = GangZoneCreate(ZoneInfo[i][z_minx], ZoneInfo[i][z_miny], ZoneInfo[i][z_maxx], ZoneInfo[i][z_maxy]);
ZoneTakeOverTeam[i] = -1;
}
return 1;
}
public OnPlayerSpawn(playerid)
{
for(new i=0; i<MAX_ZONES; i++)
{
GangZoneShowForPlayer(playerid, ZoneInfo[i][z_id], GetTeamColor(ZoneInfo[i][z_team]));
if(ZoneTakeOverTeam[i] != -1) GangZoneFlashForPlayer(playerid, ZoneInfo[i][z_id], GetTeamColor(ZoneTakeOverTeam[i]));
}
GangZoneShowForAll(GROOVEZ, 0x0FEA1F96); //this define the colors of the zones !
GangZoneShowForAll(BALLASZ, 0xBC0EC096);
GangZoneShowForAll(VAGOSZ, 0x0FEA1F96);
//Now the bases
GangZoneShowForAll(GROOVEB, 0x0FEA1F96);
GangZoneShowForAll(VAGOSB, 0xDFEF1F96);//now we must define something
GangZoneShowForAll(BALLASB, 0xBC0EC096);//what we gonna explain and create now? we need a forward a new funtion ! c'mon !
return 1;
}
//Here we will post the code of the new Funtion !
//what do this funtion? this send a message and send the score and check if a player is in the zone check if
//3 users are in the zone to start to capture the zone !
//check the time that you must stay to capture the zone !
//i;m gonna explain the funtion !
forward ZoneUpdate();
public ZoneUpdate()
{
for(new z=0; z < MAX_ZONES; z++)
{
if(ZoneTakeOverTeam[z] == -1)
{
for(new t=0; t < MAX_TEAMS; t++)
{
if(t == ZoneInfo[z][z_team]) continue;
if(GetMembersInZone(z, t) >= 3) //this you can change ! if you change this to 1, you can capture a zone with 1 player and don't need more help !
{
ZoneTakeOverTeam[z] = t;
GangZoneFlashForAll(ZoneInfo[z][z_id], GetTeamColor(t));// this is when you are in the zone start to attack it, and will change of color !
ZoneTakeOverTime[z] = 0;
}
}
}
else
{
if(GetMembersInZone(z, ZoneTakeOverTeam[z]) > 0)
{
ZoneTakeOverTime[z]++;
if(ZoneTakeOverTime[z] >= 30)//this is the time that you need wait to capture the zone, now is 30 seconds but you can change it ! :D !
{
GangZoneStopFlashForAll(ZoneInfo[z][z_id]);
GangZoneShowForAll(ZoneInfo[z][z_id], GetTeamColor(ZoneTakeOverTeam[z]));///here if you capture the zones, the zone will change to the color of your team !
ZoneInfo[z][z_team] = ZoneTakeOverTeam[z];
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))//above, checks if you are online
{
if(GetPlayerZone(i) == z && gTeam[i] == ZoneTakeOverTeam[z])//this checks if you capture the gang zone !
{
SetPlayerScore(i, GetPlayerScore(i) + 2);//here if u capture the zone will give you 2 of score you can change it to 5 20 523 :D
pInfo[i][Kills] += 2;//will add you 2 kills
GameTextForPlayer(i, "~g~Turf ~r~taken over~n~~b~~h~+2 score", 6000, 3);// this is the message when you capture the zone
}
}
}
ZoneTakeOverTeam[z] = -1;
ZoneTakeOverTime[z] = 0;
}
}
else
{
ZoneTakeOverTeam[z] = -1;
GangZoneStopFlashForAll(ZoneInfo[z][z_id]);//this shows to all players when the zone is attacked and when is captured (with the ned color)
ZoneTakeOverTime[z] = 0;
}
}
}
}
//now we need define more things ! with this you can check if a player is the gang zone ! if no, isn't able to capture the zone (logic)
//im gonna to explain !
GetMembersInZone(zoneid, team)
{
new count = 0; // you do here a new count ! above
new Float:px, Float:py, Float:pz; //this to check if the players is in the x gang zone !
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))///checks if you are online
{
if(GetPlayerState(i) != PLAYER_STATE_WASTED && gTeam[i] == team)//this checks if you are in Wasted state !
{
GetPlayerPos(i, px, py, pz);//gets your position and start to capture the zone !
if(px > ZoneInfo[zoneid][z_minx] && py > ZoneInfo[zoneid][z_miny] && px < ZoneInfo[zoneid][z_maxx] && py < ZoneInfo[zoneid][z_maxy])//this gets the zone info where are you possioned !
{
count++;
}
}
}
}
return count;
}
//now we need define the colors of the teams
//ups not of the teams of the gang zones when you capture for example
// case:TEAM_GROOVE: return 0x0FEA1F96 thats says that if a user that is using
//Groove team will capture with the color GReen this is the code of the color green 0x0FEA1F96
GetTeamColor(team)
{
switch(team)
{
case TEAM_GROOVE: return 0x0FEA1F96;//we define the colors i explained before
case TEAM_BALLAS: return 0xBC0EC096;
case TEAM_VAGOS: return 0xDFEF1F96;// :D continue !
}
return 0;
}
stock GetPlayerZone(playerid)
{
if(GetPlayerState(playerid) != PLAYER_STATE_WASTED)//waa this?, this get the zone that we are attacking in the momment !, this checks if the zone is capturable or not !
{
new Float:px, Float:py, Float:pz;//here gets the coords !
GetPlayerPos(playerid, px, py, pz);//gets your position !
for(new i=0; i<MAX_ZONES; i++)//to all players
{
if(px > ZoneInfo[i][z_minx] && py > ZoneInfo[i][z_miny] && px < ZoneInfo[i][z_maxx] && py < ZoneInfo[i][z_maxy]) return i;
}//and finito ! already we defined all zones capturables and zones not capturables
}
return -1;
}
It's good and all that, but there's tutorials extremely similar to this that already exist.
|
what tutorial?
i've searched many tutorials to do this and nothin' i've made this bcz many ppl are requestin' this and well, just tryin' to get it right :3 just trying to share somethingXD but nvm ty C: ! |
https://sampforum.blast.hk/showthread.php?tid=353267
https://sampforum.blast.hk/showthread.php?tid=276352 I'm not saying yours is bad, it's good, I was just saying that there's already a couple :P. |
C:\Users\Gebruiker\Desktop\SA-MP 0.3x\gamemodes\Test.pwn(501) : error 017: undefined symbol "ZoneInfo"
C:\Users\Gebruiker\Desktop\SA-MP 0.3x\gamemodes\Test.pwn(501) : warning 215: expression has no effect C:\Users\Gebruiker\Desktop\SA-MP 0.3x\gamemodes\Test.pwn(501) : error 001: expected token: ";", but found "]" C:\Users\Gebruiker\Desktop\SA-MP 0.3x\gamemodes\Test.pwn(501) : error 029: invalid expression, assumed zero C:\Users\Gebruiker\Desktop\SA-MP 0.3x\gamemodes\Test.pwn(501) : fatal error 107: too many error messages on one line I get these error messages on the line ZoneInfo[i][z_id] = GangZoneCreate(ZoneInfo[i][z_minx], ZoneInfo[i][z_miny], ZoneInfo[i][z_maxx], ZoneInfo[i][z_maxy]); |
new ZoneInfo[MAX_ZONES][Z_Info] = {
//here we need post the coord of zones that are capturable
{2437.5,-1722.65625,2525.390625,-1634.765625, TEAM_GROVE},//an example, but this gang zone are defined as GROVEB in OnGameModeInIt
{x,y,z, TEAM_BALLAS},
{x,y,z, TEAM_VAGOS} //here without a comma ,
}; //close
//remember that if you have 4 5 6..etc or more zones capturables you must change #define MAX_ZONES 3 this to the numbers of zones that are you getting.. in this case is 3