As includes necessarias são as:
#include <a_samp> #include <cpstream>
#pragma tabsize 0
#define SOLDADO 1 #define CHINES 2
Depois crie a forward para riar a public com as funções para dominar o territorio no CheckPoint:
forward ZoneCheckpointCheckerbyRangel();
new gzcolor[3] = //2+1 = (3) pois tem 2 GZs... { 0x33AA33AA, 0xFF9900AA };
new cpzone[MAX_PLAYERS][3]; //2+1 (3) pois tem 2 GZs...
new lastcp[MAX_PLAYERS];
Agora criando as GZ's:
new Soldado; new Chines;
new cpsoldado; new cpchines;
Agora em OnGameModeInit
coloque as skins:
AddPlayerClass(287,-1324.0948,497.2354,11.1953,137.1467,0,0,0,0,0,0);//Soldado AddPlayerClass(123,-2185.7253,706.9626,53.8906,225.8146,0,0,0,0,0,0);//Chines
Também em OnGameModeIni
coloque as GZ's:
Soldado = GangZoneCreate(-1753.477, 246.9049, -1007.979, 613.7866); Chines = GangZoneCreate(-2379.232, 577.1168, -1988.689, 1489.569);
E também os ChecksPoints em OnGameModeInit.
Checkpoints (crie os checkpoints na mesma ordem das GZs, senão da erro na hora de conquistar)
cpsoldado = CPS_AddCheckpoint(-1371.5627,492.2494,11.1953,2.0,80); cpchines = CPS_AddCheckpoint(-2206.7749,701.3187,49.4375,2.0,80);
Novamente em OnGameModeInit
Coloque isso para definir as checks
#pragma unused cpchines, cpsoldado
Agora o RequestClass
Vamos criar esse basico aqui depois você modificade acordo com sua preferêcia:
if(classid == 0)//Isso define a posisao das skins no OnGameModeInit { Gang[playerid] = SOLDADO; GameTextForPlayer(playerid,"~y~Soldado",6000,6); SetPlayerInterior(playerid,3); SetPlayerPos(playerid, -2669.8770,1410.3972,912.7240); SetPlayerFacingAngle(playerid, 267.7684); SetPlayerCameraPos(playerid, -2663.8770,1410.3972,912.7240); SetPlayerCameraLookAt(playerid, -2669.8770,1410.3972,912.7240); ApplyAnimation(playerid,"PED","WALK_DRUNK",4.0,1,1,1,1,0); } else if(classid == 1)//Isso define a posisao das skins no OnGameModeInit { Gang[playerid] = CHINES; GameTextForPlayer(playerid,"~y~Chines",6000,6); SetPlayerInterior(playerid,3); SetPlayerPos(playerid, -2669.8770,1410.3972,912.7240); SetPlayerFacingAngle(playerid, 267.7684); SetPlayerCameraPos(playerid, -2663.8770,1410.3972,912.7240); SetPlayerCameraLookAt(playerid, -2669.8770,1410.3972,912.7240); ApplyAnimation(playerid,"PED","WALK_DRUNK",4.0,1,1,1,1,0); }
OnPlayerRequestSpawn a cor das gangs:
if(Gang[playerid] == SOLDADO) { SetPlayerInterior(playerid,0); SetPlayerColor(playerid, 0x33AA33AA); //Verde Claro } else if(Gang[playerid] == CHINES) { SetPlayerInterior(playerid,0); SetPlayerColor(playerid, 0xFF00FFAA); //Rosa }
As cores das GZs:
GangZoneShowForPlayer(playerid, Soldado, gzcolor[0]); GangZoneShowForPlayer(playerid, Chines, gzcolor[1]);
Na public OnPlayerLeaveCheckpoint
coloque isso:
new checkpointid = lastcp[playerid]; if(checkpointid > 0 && checkpointid <= 2) //são 2 checkpoints, então mude se for colocar mais... { cpzone[playerid][checkpointid] = 0; //saiu do CP... GangZoneStopFlashForAll(checkpointid-1); }
Agora a public que criandos a Forward no inicio:
public ZoneCheckpointCheckerbyRangel() { for(new i; i < MAX_PLAYERS; i++) { if(!IsPlayerConnected(i))continue; if(CPS_GetPlayerCheckpoint(i) > 0 && CPS_GetPlayerCheckpoint(i) <= 2 && //são 2 checkpoints, então mude se for colocar mais... gzcolor[CPS_GetPlayerCheckpoint(i)-1] != GetPlayerColor(i)) { if(cpzone[i][CPS_GetPlayerCheckpoint(i)] < 30) { cpzone[i][CPS_GetPlayerCheckpoint(i)]++; new tmp[10]; format(tmp, sizeof tmp, "~w~%2d/30", cpzone[i][CPS_GetPlayerCheckpoint(i)]); GameTextForPlayer(i, tmp, 1001, 4); GangZoneFlashForAll(CPS_GetPlayerCheckpoint(i)-1, GetPlayerColor(i)); } else if(cpzone[i][CPS_GetPlayerCheckpoint(i)] == 30) //passou 30 segundos dentro do checkpoint { GameTextForPlayer(i, "~w~Conquistado", 4000, 1); gzcolor[CPS_GetPlayerCheckpoint(i)-1] = GetPlayerColor(i); GangZoneStopFlashForAll(CPS_GetPlayerCheckpoint(i)-1); GangZoneHideForAll(CPS_GetPlayerCheckpoint(i)-1); GangZoneShowForAll(CPS_GetPlayerCheckpoint(i)-1, GetPlayerColor(i));//Ficar piscando a cor do player na GZ } } } }
Créditos: Link_