Auto team balanze en comando
#1

bueno pues quiero que cuando el usuario use /enter se seleccione el equipo del jugador automбticamente,

vi unos ejemplos como este:

EDIT______________________________________________ __________________________________________________

encontrй este:
pawn Код:
#include<a_samp>

#define TEAM_ONE 0
#define TEAM_TWO 1

static gTeam[MAX_PLAYERS];

stock GetPlayersInTeamFromMaxPlayers(teamid)
{
    new playercount = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerState(i) == PLAYER_STATE_NONE) continue;
        if(gTeam[i] != teamid) continue;
        playercount++;
    }
    return playercount;
   
    public OnPlayerRequestSpawn(playerid)
{
    new team1 = GetPlayersInTeamFromMaxPlayers(TEAM_ONE);
    new team2 = GetPlayersInTeamFromMaxPlayers(TEAM_TWO);
    if(team1 > team2 && gTeam[playerid] == TEAM_ONE)
    {
        GameTextForPlayer(playerid, "~r~Team Full!~n~~w~Choose Another Team!", 3000, 5);
        return 0;
    }
    else if(team2 > team1 && gTeam[playerid] == TEAM_TWO)is trying to spawn as TEAM_TWO..
    {
        GameTextForPlayer(playerid, "~r~Team Full!~n~~w~Choose Another Team!", 3000, 5);
        return 0;
    }
    return 1;
}
el problema de este es que al poner
pawn Код:
static gTeam[MAX_PLAYERS];
me da todos estos errores:
Quote:

C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(30) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(35) : warning 225: unreachable code
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(35) : warning 217: loose indentation
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(35) : error 029: invalid expression, assumed zero
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(35) : error 004: function "OnGameModeInit" is not implemented
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(43) : warning 225: unreachable code
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(43) : error 029: invalid expression, assumed zero
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(43) : error 004: function "OnPlayerConnect" is not implemented
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(45) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(49) : warning 225: unreachable code
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(49) : error 029: invalid expression, assumed zero
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(49) : error 004: function "OnPlayerDeath" is not implemented
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(52) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(54) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(55) : error 017: undefined symbol "killerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(56) : error 017: undefined symbol "killerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(57) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(62) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(70) : warning 225: unreachable code
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(70) : error 029: invalid expression, assumed zero
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(70) : error 004: function "OnPlayerCommandText" is not implemented
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(72) : error 017: undefined symbol "cmdtext"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(79) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(87) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(93) : error 017: undefined symbol "cmdtext"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(100) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(103) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(107) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(113) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(119) : error 017: undefined symbol "cmdtext"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(123) : error 017: undefined symbol "playerid"

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


26 Errors.

sin el me salen estos:
Quote:

C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(29) : error 017: undefined symbol "gTeam"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(29) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(29) : error 029: invalid expression, assumed zero
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(29) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

la lнnia de los 4 errores es:
pawn Код:
stock GetPlayersInTeamFromMaxPlayers(teamid)
{
    new playercount = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerState(i) == PLAYER_STATE_NONE) continue;
        if(gTeam[playerid] != teamid) continue; //AQUI
        playercount++;
    }
    return playercount;
Reply
#2

https://sampwiki.blast.hk/wiki/GetPlayerTeam

pawn Код:
COMMAND:enter(playerid, params[]){
    if(GetPlayerTeam(playerid) == 1){
    //LA FUNCION PARA EL EQUIPO 1
    }
    else if(GetPlayerTeam(playerid) == 2){
    //LA FUNCION PARA EL EQUIPO 2
    }
    //ETC...
    return true;
}
Reply
#3

no es eso , lo que me referнa era a cuando el usuario use /enter entre en un equipo, con un balanze automatico

con eso me refiero a :

hay 3 personas en un event 2 en el rojo y uno en el azul , y cuando otro usuario use /enter le obligue a entrar en el equipo con menos jugadores
Reply
#4

encontrй este:
pawn Код:
#include<a_samp>

#define TEAM_ONE 0
#define TEAM_TWO 1

static gTeam[MAX_PLAYERS];

stock GetPlayersInTeamFromMaxPlayers(teamid)
{
    new playercount = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerState(i) == PLAYER_STATE_NONE) continue;
        if(gTeam[i] != teamid) continue;
        playercount++;
    }
    return playercount;
   
    public OnPlayerRequestSpawn(playerid)
{
    new team1 = GetPlayersInTeamFromMaxPlayers(TEAM_ONE);
    new team2 = GetPlayersInTeamFromMaxPlayers(TEAM_TWO);
    if(team1 > team2 && gTeam[playerid] == TEAM_ONE)
    {
        GameTextForPlayer(playerid, "~r~Team Full!~n~~w~Choose Another Team!", 3000, 5);
        return 0;
    }
    else if(team2 > team1 && gTeam[playerid] == TEAM_TWO)is trying to spawn as TEAM_TWO..
    {
        GameTextForPlayer(playerid, "~r~Team Full!~n~~w~Choose Another Team!", 3000, 5);
        return 0;
    }
    return 1;
}
el problema de este es que al poner
pawn Код:
static gTeam[MAX_PLAYERS];
me da todos estos errores:
Quote:

C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(30) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(35) : warning 225: unreachable code
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(35) : warning 217: loose indentation
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(35) : error 029: invalid expression, assumed zero
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(35) : error 004: function "OnGameModeInit" is not implemented
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(43) : warning 225: unreachable code
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(43) : error 029: invalid expression, assumed zero
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(43) : error 004: function "OnPlayerConnect" is not implemented
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(45) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(49) : warning 225: unreachable code
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(49) : error 029: invalid expression, assumed zero
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(49) : error 004: function "OnPlayerDeath" is not implemented
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(52) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(54) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(55) : error 017: undefined symbol "killerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(56) : error 017: undefined symbol "killerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(57) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(62) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(70) : warning 225: unreachable code
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(70) : error 029: invalid expression, assumed zero
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(70) : error 004: function "OnPlayerCommandText" is not implemented
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(72) : error 017: undefined symbol "cmdtext"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(79) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(87) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(93) : error 017: undefined symbol "cmdtext"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(100) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(103) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(107) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(113) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(119) : error 017: undefined symbol "cmdtext"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(123) : error 017: undefined symbol "playerid"

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


26 Errors.

sin el me salen estos:
Quote:

C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(29) : error 017: undefined symbol "gTeam"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(29) : error 017: undefined symbol "playerid"
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(29) : error 029: invalid expression, assumed zero
C:\Users\Porta0123\Desktop\PAWN\filterscripts\OSEv ent.pwn(29) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

la lнnia de los 4 errores es:
pawn Код:
stock GetPlayersInTeamFromMaxPlayers(teamid)
{
    new playercount = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerState(i) == PLAYER_STATE_NONE) continue;
        if(gTeam[playerid] != teamid) continue; //AQUI
        playercount++;
    }
    return playercount;
Reply
#5

Es asн:

pawn Код:
stock GetPlayersInTeamFromMaxPlayers(teamid)
{
    new playercount = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerState(i) == PLAYER_STATE_NONE) continue;
        if(gTeam[playerid] != teamid) continue; //AQUI
        playercount++;
    }
    return playercount;
} // Te faltу cerrar la llave.
Reply
#6

ok gracias, solucionado, ahora probarй que funciona
Reply
#7

hace asi
pawn Код:
CMD:enter (playerid,params[])
{
new team =
getteamdata ();
SetPlayerTeam (playerid, team);
return 1;
}

stock getteamdata ()
{
new ret, teamcount [2];
for (new i; i < MAX_PLAYERS; i++)
{
if (GetPlayerState (i) != PLAYER_STATE_NONE)
teamcount[GetPlayerTeam(i)] ++;
}
if (teamcount  [0] > teamcount [1])
ret = 1;
else if (teamcount  [0] < teamcount [1])
ret = 0;
else  
ret = random (2);
return ret;
}
Reply
#8

ya estaba solucionado pero aun asн se agradece
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)