26.06.2013, 19:16
Seguindo este exemplo de sistema de gangzone e checkpoint abaixo,como eu faria pra limitar pra apenas uma pessoa no checkpoint? exemplo eu entro no checkpoint e comeзo a dominar,ai um segundo player entra no checkpoint e aparece a mensagem pra ele,
Sistema de gangzone e checkpoint
PHP код:
SendClientMessage(playerid,vermelho,"[INFO]: {FFFFFF}Apenas uma pessoa por checkpoint,espere o outro sair de cima");
PHP код:
#include <cpstream> // include para que os checkpoints funcionem
#define MAX_GANGS 3 // maximo de gangs, aqui no caso serгo 3 gangs
#define ZONE_TIME 20 // tempo para dominar em segundos
forward ZoneCheckpointChecker(); // declaraзгo da callback para checar as gangzones
static cpzone[MAX_PLAYERS][MAX_GANGS+1],lastcp[MAX_PLAYERS]; // getar checkpoint e salvar o ultimo checkpoint em que vocк passou
new gang1,gang2,gang3,cpgang1,cpgang2,cpgang3; // declaraзгo dos checkpoints e das gangzones
new GangNames[3][] = // nome das gangs para aparecer 'A gang X doiminou mais um territуrio'
{
"Gang 1",
"Gang 2",
"Gang 3"
};
new pgzcolor[MAX_GANGS+1] = // cores para os plaeyrs
0x007900AA, 0xFF0080AA, 0x400040AA // igual
};
new gzcolor[MAX_GANGS+1] = // cores para as gangzones
{
0x007900AA, 0xFF0080AA, 0x400040AA // igual
};
public OnGameModeInit()
{
SetTimer("ZoneCheckpointChecker", 1000, true); // timer para a callback
//gang 1
AddPlayerClass(101,2303.6819,-1630.4944,14.5754,189.4422,0,0,0,0,0,0); // skin para a gang 1
//gang 2
AddPlayerClass(105, 2532.4045,-1667.5391,15.1688,83.0852,0,0,0,0,0,0); // skin paga a gang 2
//gang 3
AddPlayerClass(108, 2155.7913,-1665.1510,15.0859,36.2461,0,0,0,0,0,0); //skin para a gang 3
gang1 = GangZoneCreate(2406.349, -1764.764, 2573.673, -1606.855); // cria gangzone para a gang 1
gang2 = GangZoneCreate(1584.936, -1745.026, 1828.318, -1516.057); // cria gangzone para a gang 2
gang3 = GangZoneCreate(1835.923, -1267.349, 2075.502, -1121.283); // cria gangzone para a gang 3
cpgang1 = CPS_AddCheckpoint(2495.0383,-1686.9420,13.5140,2.0,80); // cria checkpoint para gang 1
cpgang2 = CPS_AddCheckpoint(1722.3857,-1607.7697,13.5469,2.0,80); // cria checkpoint para gang 2
cpgang3 = CPS_AddCheckpoint(1976.1494,-1234.6455,20.0469,2.0,80); // cria checkpoint para gang 3
#pragma unused cpgang1,cpgang2,cpgang3 // declaraзгo de nгo uso para nгo dar warning
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
switch(classid)
{
case 0:
{
GameTextForPlayer(playerid, GangNames[0], 2000, 3); // nome da gang
SetPlayerTeam(playerid, 0); // seta o time para nгo ocorrer teamkill
}
case 1:
{
GameTextForPlayer(playerid, GangNames[1], 2000, 3); // nome da gang
SetPlayerTeam(playerid, 1); // seta o time para nгo ocorrer teamkill
}
case 2:
{
GameTextForPlayer(playerid, GangNames[2], 2000, 3); // nome da gang
SetPlayerTeam(playerid, 2); // seta o time para nгo ocorrer teamkill
}
}
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
if(lastcp[playerid] > 0 && lastcp[playerid] <= MAX_GANGS+1)
{
cpzone[playerid][lastcp[playerid]] = 0; // quando o player sai do checkpoint a contagem й reiniciada e o dominio й abortado
GangZoneStopFlashForAll(lastcp[playerid]-1);
}
return 1;
}
public OnPlayerSpawn(playerid)
{
if(GetPlayerTeam(playerid) == 0) SetPlayerColor(playerid, pgzcolor[0]); // seta o player com a cor da gang 1
if(GetPlayerTeam(playerid) == 1) SetPlayerColor(playerid, pgzcolor[1]); // seta o player com a cor da gang 2
if(GetPlayerTeam(playerid) == 2) SetPlayerColor(playerid, pgzcolor[2]); // seta o player com a cor da gang 3
GangZoneShowForPlayer(playerid, gang1, gzcolor[0]); // mostra a gangzone da gang 1
GangZoneShowForPlayer(playerid, gang2, gzcolor[1]); // mostra a gangzone da gang 2
GangZoneShowForPlayer(playerid, gang3, gzcolor[2]); // mostra a gangzone da gang 3
return 1;
}
public ZoneCheckpointChecker() // callback para checar as gangzones
{
new string[75],tmp[10];
for(new i; i != MAX_PLAYERS; ++i)
{
if(!IsPlayerConnected(i)) continue;
if(CPS_GetPlayerCheckpoint(i) > 0 && CPS_GetPlayerCheckpoint(i) <= MAX_GANGS+1 && gzcolor[CPS_GetPlayerCheckpoint(i)-1] != GetPlayerColor(i))
{
if(cpzone[i][CPS_GetPlayerCheckpoint(i)] < ZONE_TIME)
{
cpzone[i][CPS_GetPlayerCheckpoint(i)]++;
format(tmp, sizeof tmp, "~g~%2d/20", cpzone[i][CPS_GetPlayerCheckpoint(i)]);
GameTextForPlayer(i, tmp, 1001, 4);
GangZoneFlashForAll(CPS_GetPlayerCheckpoint(i)-1, GetPlayerColor(i));
}
else if(cpzone[i][CPS_GetPlayerCheckpoint(i)] == ZONE_TIME)
{
GameTextForPlayer(i, "~r~Area ~w~Conquistada", 4000, 1);
GivePlayerMoney(i,GetPlayerMoney(i) + 100000);
gzcolor[CPS_GetPlayerCheckpoint(i)-1] = GetPlayerColor(i);
GangZoneStopFlashForAll(CPS_GetPlayerCheckpoint(i)-1);
GangZoneHideForAll(CPS_GetPlayerCheckpoint(i)-1);
GangZoneShowForAll(CPS_GetPlayerCheckpoint(i)-1, GetPlayerColor(i));
format(string, sizeof(string), "*>> [GANGZONES]: A gang '{00FF00}%s{FFFF00}' dominou mais um territуrio!",GangNames[GetPlayerTeam(i)][0]);
PlayerPlaySound(i, 1058, 0, 0, 0);
SendClientMessageToAll(0xFFFF00AA, " ");
SendClientMessageToAll(0xFFFF00AA, string);
SendClientMessageToAll(0xFFFF00AA, " ");
}
}
}
return 0;
}