[Ajuda] Verificar quantidade de players.
#1

Queria saber como faзo pra criar um sistema de verificar quantidade de players nas favelas.
Exemplo:

Sou da Favela Paraisуpolis, vou dominar o Helipa, mas so poder dominar se no Helipa tiver 3 ou mais players logados dessa favela ...
Reply
#2

Como nгo temos informaзгo sobre as variбveis, a lуgica й esta:

pawn Код:
#include <a_samp>
#include <zcmd>

new count;

CMD:atacar(playerid, params[]){

    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && DatadoJogador[i][Favela] == "Paraisopolis")
        {
            count++;
        }
    }

    if(count => 3)
    {
        //pode atacar
    }

    else
    {
        //nгo pode atacar
    }

    return 1;

}
Nгo testei, nгo й optimizado e й capaz de ter algum erro porque nгo testei o cуdigo (escrevi a partir do telemуvel). Claro que depois terб de mudar o valor da variбvel count quando o player se desconectar.
Reply
#3

Quote:
Originally Posted by Twizted
Посмотреть сообщение
Como nгo temos informaзгo sobre as variбveis, a lуgica й esta:

pawn Код:
#include <a_samp>
#include <zcmd>

new count;

CMD:atacar(playerid, params[]){

    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && DatadoJogador[i][Favela] == "Paraisopolis")
        {
            count++;
        }
    }

    if(count => 3)
    {
        //pode atacar
    }

    else
    {
        //nгo pode atacar
    }

    return 1;

}
Nгo testei, nгo й optimizado e й capaz de ter algum erro porque nгo testei o cуdigo (escrevi a partir do telemуvel). Claro que depois terб de mudar o valor da variбvel count quando o player se desconectar.
Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(CP[playerid] == 1)
    {
    	GameTextForPlayer(playerid, "~r~Alvo localizado!", 2500, 3);
    	DisablePlayerCheckpoint(playerid);
    	CP[playerid] = 0;
    }
    for(new i=0;i<MAX_GZS;i++)
  	{
        if(GetPlayerVisibleDynamicCP(playerid) == ChecksDominio[i])
  		{
  		    if(Player[playerid][pChefe] >= 1 || Player[playerid][pBraзo] >= 1)
  		    {
	    		if(ContagemDominio[i] != 0) return 1;
	      		if((strcmp(GZDono[i], "BALLAS", true) == 0) && Player[playerid][pGang] == 1 ||
                   (strcmp(GZDono[i], "BALLAS", true) == 0) && Player[playerid][pGang] == 2 ||
                   (strcmp(GZDono[i], "GROVE", true) == 0) && Player[playerid][pGang] == 3 ||
                   (strcmp(GZDono[i], "GROVE", true) == 0) && Player[playerid][pGang] == 4)
		   		return SendClientMessage(playerid, COR_ERRO, "ERRO: Esta area jб estб dominada!");

		   		if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING )
		 	    {
				    return 1;
                }

	        	SetPVarInt(playerid,"AreaAtacada",i);
	         	ContagemDominio[i] = SetTimerEx("Contar",1000,1,"i",playerid);
	           	GangZoneFlashForAll(GangZonas[GetPVarInt(playerid,"AreaAtacada")],GetPlayerColor(playerid));
	           	CP[playerid] = 4;
	            SendFormattedMessageToAll(COR_INFO, "[GANGS]: %s estб dominando a area '%s{FFFFD2}'.", getPName(playerid), GangZone[i][GZName]);
	            return 1;
	       	}
	       	else SendClientMessage(playerid, COR_ERRO, "ERRO: Vocк nгo tem permissгo para dominar!");
   		}
	}
	return 1;
}
ai o codigo de dominar, tem como fazer um codigo simples com as variareis pra eu ter uma noзгo melhor?
Reply
#4

up...
Reply
#5

Na YSI tem o y_groups e o y_iterate vai facilitar a sua vida muito.

Pesquise e estude sobre isso.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)