[Ajuda] Dividir um numero em varias partes?
#1

Alguem poderia me ajudar? Tф precisando de um code aqui, mas eu nгo estou conseguindo,

exemplo, TotalPlayers = 9;

Quero dividir esses 9 players para 3 times diferentes,

TimeA
TimeB
TimeC

Alguem poderia me ajudar?
Reply
#2

Simmm
Reply
#3

Sim й possivel!
Exemplo classico e basico!
PHP код:
CMD:montartime(playerid)
{
    new 
time = 0;
    for(new 
i = 0; i < TotalPlayers; i++)
    {
        if(
IsPlayerConnected(i))
        {
            switch(
time)
            {
                case 
0://Time A
                
{
                    
SetPlayerTeam(i, 1);
                    
SendClientMessage(playerid, -1, "Vocк estб no time A");
                }
                case 
1:
                {
                    
SetPlayerTeam(i, 2);
                    
SendClientMessage(playerid, -1, "Vocк estб no time B");
                }case 
2:
                {
                    
SetPlayerTeam(i, 2);
                    
SendClientMessage(playerid, -1, "Vocк estб no time C");
                    
time = -1;    
                }
            }
            
time ++;
        }
    }
    return 
1;
} 
Reply
#4

Quote:
Originally Posted by AdrianoStk
Посмотреть сообщение
Sim й possivel!
Exemplo classico e basico!
PHP код:
CMD:montartime(playerid)
{
    new 
time = 0;
    for(new 
i = 0; i < TotalPlayers; i++)
    {
        if(
IsPlayerConnected(i))
        {
            switch(
time)
            {
                case 
0://Time A
                
{
                    
SetPlayerTeam(i, 1);
                    
SendClientMessage(playerid, -1, "Vocк estб no time A");
                }
                case 
1:
                {
                    
SetPlayerTeam(i, 2);
                    
SendClientMessage(playerid, -1, "Vocк estб no time B");
                }case 
2:
                {
                    
SetPlayerTeam(i, 2);
                    
SendClientMessage(playerid, -1, "Vocк estб no time C");
                    
time = -1;    
                }
            }
            
time ++;
        }
    }
    return 
1;
} 
Isso realmente funcionaria?
Reply
#5

PHP код:
new TotalPlayers = 10;
const 
Float:teams = 3;
const 
MaxPerTeam = floatround(float(TotalPlayers) / teams, floatround_floor);
new 
team = 1, players = 0;
if(
MaxPerTeam < 1) MaxPerTeam = TotalPlayers;
for(new 
i = 0; i < MAX_PLAYERS; i++)
{
    if(
IsPlayerConnected(i) && ....) //suas condicionais
    
{
        
SetTeam(i, team); //sua funзгo de colocar o jogador na equipe
        
players++;
        if(
players >= MaxPerTeam && team < teams) //equipe 1 e 2 seguem o limite, jб a 3Є nгo (caso sobre jogadores)
        
{
            
players = 0; //zera o contador de jogadores
            
team++; //prуxima equipe
        
}
    }
} 
Reply
#6

Faz um random.
Reply
#7

Vocк pode separar de acordo com o id do jogador.

pawn Код:
for(new i = GetPlayerPoolSize(); i > -1; --i) {
    time[i] = (i % numeroDeTimes);
}
Reply
#8

Ou entгo pode colocar os os ids dos players em uma array e dividir em partes iguais
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)