new GZ;
//Quando a GangZone for criada, ou iniciar uma dominaзгo
GZ = GangZoneCreate(1248.011, 2072.804, 1439.348, 2204.319);
VerificarGZ();
forward VerificarGZ();
public VerificarGZ() {
static cont, Str[35];
for(new i; i != MAX_PLAYERS; i++) {
// No lugar de 1248.011, 2072.804, 1439.348, 2204.319, coloque as suas coordenadas
if(IsPlayerConnected(i) && IsPlayerInArea(i, 1248.011, 2072.804, 1439.348, 2204.319) && /*Variбvel da org inimiga Ex:*/ PlayerInfo[playerid][Membro] == ORG_INIMIGA) cont++;
}
if(cont >= 3) {
for(new i; i != MAX_PLAYERS; i++) {
if(IsPlayerConnected(i) && /*Variбvel da org que irб receber a mensagem Ex:*/ PlayerInfo[playerid][Membro] == ORG_ALIADA) {
format(Str, 35, "Possui %i inimigos na sua бrea.", cont);
SendClientMessage(i, -1, Str);
}
}
}
cont = 0;
SetTimer("VerificarGZ", 1000, false);
return 1;
}
IsPlayerInArea(playerid, Float:MinX, Float:MinY, Float:MaxX, Float:MaxY) {
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(X >= MinX && X <= MaxX && Y >= MinY && Y <= MaxY) return 1;
return 0;
}
Acredito que isso que fiz jб й uma boa base para comeзar.
PHP код:
|
Entгo assim que a gangzone for criada eu coloco VerificarGZ(); ai essa public vai verificar quando os membros da org rival entrar na бrea ai vai avisar ?
OBS: Obg pela base |
Isso mesmo, mas vocк tem que tomar cuidado pois essa callback quando for chamada ela irб ficar sendo chamada a cada segundo, vocк precisa saber para que fim usar, se for para verificar a todo momento, pode fazer pegando a base, mas se vocк quer que verifique em determinado tempo, vocк deverб criar uma variбvel para verificar se й necessбrio chamar essa callback a todo momento.
Espero ter ajudado. |
forward VerificarGZ2(); public VerificarGZ2() { static cont,cont2, Str[150]; for(new i; i != MAX_PLAYERS; i++) { // No lugar de 1248.011, 2072.804, 1439.348, 2204.319, coloque as suas coordenadas if(IsPlayerConnected(i) && IsPlayerInArea(i, 2071.699, -2175.33, 2790.435, -1760.817) && /*Variбvel da org inimiga Ex:*/ Player[i][MotoClube] == 2){ cont++; } if(IsPlayerConnected(i) && IsPlayerInArea(i, 2071.699, -2175.33, 2790.435, -1760.817) && /*Variбvel da org inimiga Ex:*/ Player[i][MotoClube] == 1){ cont2++; } } if(cont >= 3) { for(new i; i != MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && Player[i][Gangs] == 1) { format(Str, 150, "{00A180}[SERVER]:{ffffff} Cuidado %i membros dos Mayans em Oakland.", cont); SendClientMessage(i, -1, Str); } } } if(cont2 >= 3) { for(new i; i != MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && Player[i][Gangs] == 1) { format(Str, 150, "{00A180}[SERVER]:{ffffff} Cuidado %d membros dos Sons of Anarchy em Oakland.", cont2); SendClientMessage(i, -1, Str); } } } cont = 0; cont2 = 0; SetTimer("VerificarGZ2", 1000, false); return 1; }
bom amigo, eu deixei desse jeito.
Код:
forward VerificarGZ2(); public VerificarGZ2() { static cont,cont2, Str[150]; for(new i; i != MAX_PLAYERS; i++) { // No lugar de 1248.011, 2072.804, 1439.348, 2204.319, coloque as suas coordenadas if(IsPlayerConnected(i) && IsPlayerInArea(i, 2071.699, -2175.33, 2790.435, -1760.817) && /*Variбvel da org inimiga Ex:*/ Player[i][MotoClube] == 2){ cont++; } if(IsPlayerConnected(i) && IsPlayerInArea(i, 2071.699, -2175.33, 2790.435, -1760.817) && /*Variбvel da org inimiga Ex:*/ Player[i][MotoClube] == 1){ cont2++; } } if(cont >= 3) { for(new i; i != MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && Player[i][Gangs] == 1) { format(Str, 150, "{00A180}[SERVER]:{ffffff} Cuidado %i membros dos Mayans em Oakland.", cont); SendClientMessage(i, -1, Str); } } } if(cont2 >= 3) { for(new i; i != MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && Player[i][Gangs] == 1) { format(Str, 150, "{00A180}[SERVER]:{ffffff} Cuidado %d membros dos Sons of Anarchy em Oakland.", cont2); SendClientMessage(i, -1, Str); } } } cont = 0; cont2 = 0; SetTimer("VerificarGZ2", 1000, false); return 1; } tб complicado de explicar mas acho que entendeu... |
forward VerificarGZ2();
public VerificarGZ2() {
new cont[2], //Coloque a quantidade de tipo de motoclub que desejar.
//Neste caso sу serгo vбlidos motoclub 1 e 2 (cйlula 0 = motoblub 1 \\\ cйlula 1 = motoclub 2)
Str[128];
static bool: player_GZ[MAX_PLAYERS][2]; //Variavel para setar true caso o player esteja na GZ, false caso ele nгo esteja na GZ
for(new i; i != MAX_PLAYERS; i++) {
if(IsPlayerConnected(i) && 0 < Player[i][MotoClube] < 3) { //Verifica se o motoclub й entre 1 e 2
if(IsPlayerInArea(i, 2071.699, -2175.33, 2790.435, -1760.817)) { //Verifica quem estб na GZ
if(player_GZ[i][ Player[i][MotoClube] - 1 ] == false) { //Verifica se existe mais jogadores na GZ, se ele nгo estava antes e estб na GZ irб contabilizar +1 e setarб a variбvel do jogador a true (ele estб na GZ)
cont[ Player[i][MotoClube] - 1 ]++;
player_GZ[i][ Player[i][MotoClube] - 1 ] = true; // motoclub 1 й cйlula 0 | motoclub 2 й cйlula 1
}
}
else player_GZ[i][ Player[i][MotoClube] - 1 ] = false; //Quem nгo estiver na GZ seta a variбvel a false
}
}
for(new x; x != sizeof(cont); x++) { //Farб um loop em todas as contagens
if(cont[x] >= 3) { //Ira verificar se cada contagem й maior ou igual a 3
for(new i; i != MAX_PLAYERS; i++) {
if(IsPlayerConnected(i) && Player[i][Gangs] == 1) {
format(Str, 128, "{00A180}[SERVER]:{ffffff} Cuidado %i membros dos %s em Oakland.", cont[x], GetNameMotoClube(x + 1)); //Soma +1 pois queremos agr o valor real do motoclub
SendClientMessage(i, -1, Str);
}
}
}
}
SetTimer("VerificarGZ2", 1000, false);
return 1;
}
//Crie esta funзгo para pegar os nomes dos motoclub
GetNameMotoClube(playerid) {
static Name[15];
switch(Player[playerid][MotoClube]) {
//case 0: Name = ""; //Nome do motoclub 0 se tiver, caso nгo tenha sу excluir a linha
case 1: Name = "Mayans";
case 2: Name = "Sons of Anarchy";
default: Name = "Nenhum";
}
return Name;
}
forward VerificarGZ(); public VerificarGZ() { for(new i; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(IsPlayerInArea(i, 2071.699, -2175.33, 2790.435, -1760.817)) { if(Player[i][MotoClube] == 1 && !Player[i][NaGZ][1]) { GZ[0][Cont]++; if(GZ[0][Cont] >= 1) { if(IsPlayerConnected(i) && Player[i][Gangs] == 1) { new Str[128]; format(Str, 128, "{00A180}[SERVER]:{ffffff} Cuidado %i membros dos Sons of Anarchy em Oakland.", GZ[0][Cont]); SendClientMessage(i, -1, Str); } } } if(Player[i][MotoClube] == 2 && !Player[i][NaGZ][1]) { GZ[1][Cont]++; Player[i][NaGZ][1] = true; if(GZ[1][Cont] >= 1) { if(IsPlayerConnected(i) && Player[i][Gangs] == 1) { new Str[128]; format(Str, 128, "{00A180}[SERVER]:{ffffff} Cuidado %i membros dos Mayans em Oakland.", GZ[1][Cont]); SendClientMessage(i, -1, Str); } } } else { GZ[0][Cont]--; GZ[1][Cont]--; Player[i][NaGZ][0] = Player[i][NaGZ][1] = false; } } if(IsPlayerInArea(i, 683.6639, -1397.625, 1360.569, -943.6342)) { if(Player[i][Gangs] == 1 && !Player[i][NaGZ][2]) { GZ[2][Cont]++; Player[i][NaGZ][2] = true; if(GZ[2][Cont] >= 1) { if(IsPlayerConnected(i) && Player[i][MotoClube] == 1) { new Str[128]; format(Str, 128, "{00A180}[SERVER]:{ffffff} Cuidado %i membros dos Niners em Charming.", GZ[2][Cont]); SendClientMessage(i, -1, Str); } } } if(Player[i][MotoClube] == 2 && !Player[i][NaGZ][3]) { GZ[3][Cont]++; Player[i][NaGZ][3] = true; if(GZ[3][Cont] >= 1) { if(IsPlayerConnected(i) && Player[i][MotoClube] == 1) { new Str[128]; format(Str, 128, "{00A180}[SERVER]:{ffffff} Cuidado %i membros dos Mayans em Charming.", GZ[3][Cont]); SendClientMessage(i, -1, Str); } } } else { GZ[2][Cont]--; GZ[3][Cont]--; Player[i][NaGZ][2] = false; Player[i][NaGZ][3] = false; } } } } }
Ainda estou com o mesmo problema. Se tiver alguйm podendo me dar esse help!!
|