[Ajuda] Limita a uma pessoa por checkpoint
#1

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,
PHP код:
SendClientMessage(playerid,vermelho,"[INFO]: {FFFFFF}Apenas uma pessoa por checkpoint,espere o outro sair de cima"); 
Sistema de gangzone e checkpoint
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
    
0x007900AA0xFF0080AA0x400040AA  // igual
};
new 
gzcolor[MAX_GANGS+1] = // cores para as gangzones
{
    
0x007900AA0xFF0080AA0x400040AA  // igual
};
public 
OnGameModeInit()
{
    
SetTimer("ZoneCheckpointChecker"1000true); // 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(1052532.4045,-1667.5391,15.1688,83.0852,0,0,0,0,0,0); // skin paga a gang 2
    //gang 3
    
AddPlayerClass(1082155.7913,-1665.1510,15.0859,36.2461,0,0,0,0,0,0); //skin para a gang 3
    
gang1 GangZoneCreate(2406.349, -1764.7642573.673, -1606.855); // cria gangzone para a gang 1
    
gang2 GangZoneCreate(1584.936, -1745.0261828.318, -1516.057); // cria gangzone para a gang 2
    
gang3 GangZoneCreate(1835.923, -1267.3492075.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(playeridclassid)
{
    switch(
classid)
    {
        case 
0:
        {
            
GameTextForPlayer(playeridGangNames[0], 20003);  // nome da gang
            
SetPlayerTeam(playerid0); // seta o time para nгo ocorrer teamkill
        
}
        case 
1:
        {
            
GameTextForPlayer(playeridGangNames[1], 20003); // nome da gang
            
SetPlayerTeam(playerid1); // seta o time para nгo ocorrer teamkill
        
}
        case 
2:
        {
            
GameTextForPlayer(playeridGangNames[2], 20003); // nome da gang
            
SetPlayerTeam(playerid2); // seta o time para nгo ocorrer teamkill
        
}
     }
     return 
1;
}
public 
OnPlayerLeaveCheckpoint(playerid)
{
    if(
lastcp[playerid] > && 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) == 0SetPlayerColor(playeridpgzcolor[0]); // seta o player com a cor da gang 1
    
if(GetPlayerTeam(playerid) == 1SetPlayerColor(playeridpgzcolor[1]); // seta o player com a cor da gang 2
    
if(GetPlayerTeam(playerid) == 2SetPlayerColor(playeridpgzcolor[2]); // seta o player com a cor da gang 3
    
GangZoneShowForPlayer(playeridgang1gzcolor[0]); // mostra a gangzone da gang 1
    
GangZoneShowForPlayer(playeridgang2gzcolor[1]); // mostra a gangzone da gang 2
    
GangZoneShowForPlayer(playeridgang3gzcolor[2]); // mostra a gangzone da gang 3
    
return 1;
}
public 
ZoneCheckpointChecker() // callback para checar as gangzones
{
    new 
string[75],tmp[10];
    for(new 
i!= MAX_PLAYERS; ++i)
    {
        if(!
IsPlayerConnected(i)) continue;
        if(
CPS_GetPlayerCheckpoint(i) > && CPS_GetPlayerCheckpoint(i) <= MAX_GANGS+&& gzcolor[CPS_GetPlayerCheckpoint(i)-1] != GetPlayerColor(i))
        {
            if(
cpzone[i][CPS_GetPlayerCheckpoint(i)] < ZONE_TIME)
            {
                
cpzone[i][CPS_GetPlayerCheckpoint(i)]++;
                
format(tmpsizeof tmp"~g~%2d/20"cpzone[i][CPS_GetPlayerCheckpoint(i)]);
                
GameTextForPlayer(itmp10014);
                
GangZoneFlashForAll(CPS_GetPlayerCheckpoint(i)-1GetPlayerColor(i));
            }
            else if(
cpzone[i][CPS_GetPlayerCheckpoint(i)] == ZONE_TIME)
            {
                
GameTextForPlayer(i"~r~Area ~w~Conquistada"40001);
                
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)-1GetPlayerColor(i));
                
format(stringsizeof(string), "*>> [GANGZONES]: A gang '{00FF00}%s{FFFF00}' dominou mais um territуrio!",GangNames[GetPlayerTeam(i)][0]);
                
PlayerPlaySound(i1058000);
                
SendClientMessageToAll(0xFFFF00AA" ");
                
SendClientMessageToAll(0xFFFF00AAstring);
                
SendClientMessageToAll(0xFFFF00AA" ");
            }
        }
    }
    return 
0;

Reply
#2

Alguem?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)