Problema con sistema de carreras
#1

Hola, uso el sistema de carreras de RyDer y todo normal, pero cuando el server llega a una tal cantidad de usuarios (mбs de 100 usuarios) y ya sea que un usuario crea la carrera o el sistema de carreras crea automбticamente la carrera los comandos para ingresar a la carrera se empiezan a buguear, dice que no hay ninguna carrera disponible para entrar siendo que la carrera se estб iniciando, pones /Join y en el caso de los players les dice eso y aparte los deja congelados y el server responde diciйndole que no existe el comando, incluso los TexdtDraw's que anuncian la carrera se quedan bugueados, porque una vez que empieza la carrera estos se quitan, pero no, se quedan congelados.. Intento terminarlas con /stoprace o /desbugrace y se quedan congeladas las funciones dejando inutilizable el sistema. xd

Pienso que la funciуn ForEach(i, MAX_PLAYERS) es la que buguea todo el sistema... No tengo ningъn define con MAX_PLAYERS

PHP код:
CMD:join(playeridparams[])
{
    if(
RaceStarted == 1)
    return 
SendClientMessage(playeridRojo"<!> La carrera ya empeso! Espera que termine!");
    if(
RaceBusy == 0x00)
    return 
SendClientMessage(playeridRojo"<!> No hay carreras para competir!");
    if(
Joined[playerid] == true)
    return 
SendClientMessage(playeridRojo"<!> Has Entrado a la carrera!");
    if(
IsPlayerInAnyVehicle(playerid))
    return 
SetTimerEx("SetupRaceForPlayer"25000"e"playerid), RemovePlayerFromVehicle(playerid), Joined[playerid] = true,SetPlayerVirtualWorld(playerid,5);
    
SetupRaceForPlayer(playerid);
    
ResetPlayerWeapons(playerid);
    
SetPlayerVirtualWorld(playerid,5);
    
Joined[playerid] = true;
    
DisableRemoteVehicleCollisions(playerid1);
    return 
1;
}
CMD:stoprace(playeridparams[])
{
    if(
Informacion[playerid][pVip] >= )
    {
    new 
string[128];
       
GetPlayerName(playerid,string,sizeof(string));
       
format(string,sizeof(string),"* Jugador VIP (ID:%d) %s utilizу el comando /StopRace",playerid,string);
    
MensajesVip(amarillo,string);
       if(
RaceBusy == 0x00 || RaceStarted == 0) return SendClientMessage(playeridRojo"* No hay carreras activas!");
    
StopRace();
    }
    else return 
NoEsVIP(playerid);
    return 
1;
}
CMD:desbugrace(playeridparams[])
{
    if(
Informacion[playerid][Admin] >= || Informacion[playerid][pVip] >= )
    {
        new 
string[128];
        
GetPlayerName(playerid,string,sizeof(string));
        
format(string,sizeof(string),"* Jugador VIP (ID:%d) %s utilizу el comando /desbugrace",playerid,string);
        
MensajesVip(amarillo,string);
        
        
KillTimer(rCounter);
        
KillTimer(CountTimer);
        
RaceStarted 0;
        
RaceTick 0;
        
JoinCount 0;
        
FinishCount 0;
        
RaceBusy 0x00;
        ForEach(
iMAX_PLAYERS)
        {
            
GetPlayerVirtualWorld(i);
            if(
GetPlayerVirtualWorld(i) != 0)
            {
                 if(
MiniJuego[i] == MJ_NO && Informacion[i][Jailed] == && UserEnJuego[i] == 0)
                 {
                    
DisablePlayerRaceCheckpoint(i);
                    
DestroyVehicle(CreatedRaceVeh[i]);
                    
Joined[i] = false;
                    
CPProgess[i] = 0;
                    
KillTimer(InfoTimer[i]);
                    
SetPlayerVirtualWorld(i,0);
                    
DisableRemoteVehicleCollisions(i,0);
                }
                    
SendClientMessage(playerid,Rojo,"* Carreras desbugeadas.");
                }
            }
        }
        else return 
NoEsVIP(playerid);
    return 
1;
}
function 
LoadRaceNames()
{
    new
        
rNameFile[64],
        
string[64]
    ;
    
format(rNameFilesizeof(rNameFile), "/rRaceSystem/RaceNames/RaceNames.txt");
    
TotalRaces dini_Int(rNameFile"TotalRaces");
    
Loop(xTotalRaces)
    {
        
format(stringsizeof(string), "Race_%d"x), strmid(RaceNames[x], dini_Get(rNameFilestring), 020sizeof(RaceNames));
        
/*printf(">> Loaded Races: %s", RaceNames[x]);*/
    
}
    return 
1;
}
function 
LoadAutoRace(rName[])
{
    new
        
rFile[256],
        
string[256]
    ;
    
format(rFilesizeof(rFile), "/rRaceSystem/%s.RRACE"rName);
    if(!
dini_Exists(rFile)) return printf("Race \"%s\" doesn't exist!"rName);
    
strmid(RaceNamerName0strlen(rName), sizeof(RaceName));
    
RaceVehicle dini_Int(rFile"vModel");
    
RaceType dini_Int(rFile"rType");
    
TotalCP dini_Int(rFile"TotalCP");
    
#if DEBUG_RACE == 1
    
printf("VehicleModel: %d"RaceVehicle);
    
printf("RaceType: %d"RaceType);
    
printf("TotalCheckpoints: %d"TotalCP);
    
#endif
    
Loop(x2)
    {
        
format(stringsizeof(string), "vPosX_%d"x), RaceVehCoords[x][0] = dini_Float(rFilestring);
        
format(stringsizeof(string), "vPosY_%d"x), RaceVehCoords[x][1] = dini_Float(rFilestring);
        
format(stringsizeof(string), "vPosZ_%d"x), RaceVehCoords[x][2] = dini_Float(rFilestring);
        
format(stringsizeof(string), "vAngle_%d"x), RaceVehCoords[x][3] = dini_Float(rFilestring);
        
#if DEBUG_RACE == 1
        //printf("VehiclePos %d: %f, %f, %f, %f", x, RaceVehCoords[x][0], RaceVehCoords[x][1], RaceVehCoords[x][2], RaceVehCoords[x][3]);
        #endif
    
}
    
Loop(xTotalCP)
    {
         
format(stringsizeof(string), "CP_%d_PosX"x), CPCoords[x][0] = dini_Float(rFilestring);
         
format(stringsizeof(string), "CP_%d_PosY"x), CPCoords[x][1] = dini_Float(rFilestring);
         
format(stringsizeof(string), "CP_%d_PosZ"x), CPCoords[x][2] = dini_Float(rFilestring);
         
#if DEBUG_RACE == 1
         //printf("RaceCheckPoint %d: %f, %f, %f", x, CPCoords[x][0], CPCoords[x][1], CPCoords[x][2]);
         #endif
    
}
    
Position 0;
    
FinishCount 0;
    
JoinCount 0;
    
Loop(x2PlayersCount[x] = 0;
    
CountAmount COUNT_DOWN_TILL_RACE_START;
    
RaceTime MAX_RACE_TIME;
    
RaceBusy 0x01;
    
CountTimer SetTimer("CountTillRace"9991);
//    TimeProgress = 0;
    
return 1;
}
function 
LoadRace(playeridrName[])
{
    new
        
rFile[256],
        
string[256]
    ;
    
format(rFilesizeof(rFile), "/rRaceSystem/%s.RRACE"rName);
    if(!
dini_Exists(rFile)) return SendClientMessage(playeridRojo"<!> Race doesn't exist!"), printf("Race \"%s\" doesn't exist!"rName);
    
strmid(RaceNamerName0strlen(rName), sizeof(RaceName));
    
RaceVehicle dini_Int(rFile"vModel");
    
RaceType dini_Int(rFile"rType");
    
TotalCP dini_Int(rFile"TotalCP");
    
#if DEBUG_RACE == 1
    
printf("VehicleModel: %d"RaceVehicle);
    
printf("RaceType: %d"RaceType);
    
printf("TotalCheckpoints: %d"TotalCP);
    
#endif
    
Loop(x2)
    {
        
format(stringsizeof(string), "vPosX_%d"x), RaceVehCoords[x][0] = dini_Float(rFilestring);
        
format(stringsizeof(string), "vPosY_%d"x), RaceVehCoords[x][1] = dini_Float(rFilestring);
        
format(stringsizeof(string), "vPosZ_%d"x), RaceVehCoords[x][2] = dini_Float(rFilestring);
        
format(stringsizeof(string), "vAngle_%d"x), RaceVehCoords[x][3] = dini_Float(rFilestring);
        
#if DEBUG_RACE == 1
        //printf("VehiclePos %d: %f, %f, %f, %f", x, RaceVehCoords[x][0], RaceVehCoords[x][1], RaceVehCoords[x][2], RaceVehCoords[x][3]);
        #endif
    
}
    
Loop(xTotalCP)
    {
         
format(stringsizeof(string), "CP_%d_PosX"x), CPCoords[x][0] = dini_Float(rFilestring);
         
format(stringsizeof(string), "CP_%d_PosY"x), CPCoords[x][1] = dini_Float(rFilestring);
         
format(stringsizeof(string), "CP_%d_PosZ"x), CPCoords[x][2] = dini_Float(rFilestring);
         
#if DEBUG_RACE == 1
         //printf("RaceCheckPoint %d: %f, %f, %f", x, CPCoords[x][0], CPCoords[x][1], CPCoords[x][2]);
         #endif
    
}
    
Position 0;
    
FinishCount 0;
    
JoinCount 0;
    
Loop(x2PlayersCount[x] = 0;
    
Joined[playerid] = true;
    
//Informacion[playerid][Modo] = 2;
    //DisableRemoteVehicleCollisions(playerid, 1);
    
CountAmount COUNT_DOWN_TILL_RACE_START;
    
RaceTime MAX_RACE_TIME;
    
RaceBusy 0x01;
//    TimeProgress = 0;
    
SetupRaceForPlayer(playerid);
    
CountTimer SetTimer("CountTillRace"9991);
    return 
1;
}
function 
SetupRaceForPlayer(playerid)
{
    
CPProgess[playerid] = 0;
    
FreezePlayerplayerid );
    
CPCoords[playerid][3] = 0;
    
SetCP(playeridCPProgess[playerid], CPProgess[playerid]+1TotalCPRaceType);
    if(
IsOdd(playerid)) IndexD 1;
     else 
IndexD 0;
     
    switch(
IndexD)
    {
        case 
0:
        {
            if(
PlayersCount[0] == 1)
            {
                
RaceVehCoords[0][0] -= (floatsin(-RaceVehCoords[0][3], degrees));
                 
RaceVehCoords[0][1] -= (floatcos(-RaceVehCoords[0][3], degrees));
                   
CreatedRaceVeh[playerid] = CreateVehicle(RaceVehicleRaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2]+2RaceVehCoords[0][3], random(126), random(126), (60 60));
                
SetPlayerPos(playeridRaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2]+2);
                
SetPlayerFacingAngle(playeridRaceVehCoords[0][3]);
                
SetPlayerVirtualWorld(playerid,5);
                
SetVehicleVirtualWorld(CreatedRaceVeh[playerid], 5);
                
TextDrawHideForPlayer(playeridAnuncioCarrera);
                
TextDrawHideForPlayer(playeridTextoAnuncioCarrera);
                
Informacion[playerid][SuperVelocidad]       = 0;
                
Informacion[playerid][GodCar] = 1;
                
DisableRemoteVehicleCollisions(playerid1);
                
ResetPlayerWeapons(playerid);
                
SetPlayerVirtualWorld(playerid,5);
                
Joined[playerid] = true;
                
//DisableRemoteVehicleCollisions(playerid, 1);
                
PutPlayerInVehicle(playeridCreatedRaceVeh[playerid], 0);
                
Camera(playeridRaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2], RaceVehCoords[0][3], 20);
            }
        }
        case 
1:
         {
             if(
PlayersCount[1] == 1)
             {
                
RaceVehCoords[1][0] -= (floatsin(-RaceVehCoords[1][3], degrees));
                 
RaceVehCoords[1][1] -= (floatcos(-RaceVehCoords[1][3], degrees));
                   
CreatedRaceVeh[playerid] = CreateVehicle(RaceVehicleRaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2]+2RaceVehCoords[1][3], random(126), random(126), (60 60));
                   
SetPlayerVirtualWorld(playerid,5);
                   
PutPlayerInVehicle(playeridCreatedRaceVeh[playerid], 0);
                
SetPlayerPos(playeridRaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2]+2);
                
SetPlayerFacingAngle(playeridRaceVehCoords[1][3]);
                
PutPlayerInVehicle(playeridCreatedRaceVeh[playerid], 0);
                
SetVehicleVirtualWorld(CreatedRaceVeh[playerid], 5);
                
TextDrawHideForPlayer(playeridAnuncioCarrera);
                
TextDrawHideForPlayer(playeridTextoAnuncioCarrera);
                
Informacion[playerid][SuperVelocidad]       = 0;
                
Informacion[playerid][GodCar] = 1;
                
ResetPlayerWeapons(playerid);
                
SetPlayerVirtualWorld(playerid,5);
                
Joined[playerid] = true;
                
DisableRemoteVehicleCollisions(playerid1);
                
PutPlayerInVehicle(playeridCreatedRaceVeh[playerid], 0);
                
Camera(playeridRaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2], RaceVehCoords[1][3], 20);
            }
         }
    }
    switch(
IndexD)
    {
        case 
0:
        {
            if(
PlayersCount[0] != 1)
            {
                   
CreatedRaceVeh[playerid] = CreateVehicle(RaceVehicleRaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2]+2RaceVehCoords[0][3], random(126), random(126), (60 60));
                   
PutPlayerInVehicle(playeridCreatedRaceVeh[playerid], 0);
                
SetPlayerPos(playeridRaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2]+2);
                
SetPlayerFacingAngle(playeridRaceVehCoords[0][3]);
                
SetPlayerVirtualWorld(playerid,5);
                
PutPlayerInVehicle(playeridCreatedRaceVeh[playerid], 0);
                
SetVehicleVirtualWorld(CreatedRaceVeh[playerid], 5);
                
TextDrawHideForPlayer(playeridAnuncioCarrera);
                
TextDrawHideForPlayer(playeridTextoAnuncioCarrera);
                
Informacion[playerid][SuperVelocidad]       = 0;
                
Informacion[playerid][GodCar] = 1;
                
ResetPlayerWeapons(playerid);
                
SetPlayerVirtualWorld(playerid,5);
                
Joined[playerid] = true;
                
DisableRemoteVehicleCollisions(playerid1);
                
PutPlayerInVehicle(playeridCreatedRaceVeh[playerid], 0);
                
Camera(playeridRaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2], RaceVehCoords[0][3], 20);
                
PlayersCount[0] = 1;
            }
        }
        case 
1:
        {
            if(
PlayersCount[1] != 1)
            {
                   
CreatedRaceVeh[playerid] = CreateVehicle(RaceVehicleRaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2]+2RaceVehCoords[1][3], random(126), random(126), (60 60));
                   
PutPlayerInVehicle(playeridCreatedRaceVeh[playerid], 0);
                
SetPlayerPos(playeridRaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2]+2);
                
SetPlayerFacingAngle(playeridRaceVehCoords[1][3]);
                
TextDrawHideForPlayer(playeridAnuncioCarrera);
                
TextDrawHideForPlayer(playeridTextoAnuncioCarrera);
                
SetPlayerVirtualWorld(playerid,5);
                
PutPlayerInVehicle(playeridCreatedRaceVeh[playerid], 0);
                
SetVehicleVirtualWorld(CreatedRaceVeh[playerid], 5);
                
Informacion[playerid][SuperVelocidad]       = 0;
                
Informacion[playerid][GodCar] = 1;
                
ResetPlayerWeapons(playerid);
                
SetPlayerVirtualWorld(playerid,5);
                
Joined[playerid] = true;
                
DisableRemoteVehicleCollisions(playerid1);
                
PutPlayerInVehicle(playeridCreatedRaceVeh[playerid], 0);
                
Camera(playeridRaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2], RaceVehCoords[1][3], 20);
                
PlayersCount[1] = 1;
            }
           }
    }
    
JoinCount++;
    return 
1;
}
function 
CountTillRace()
{
         
    switch(
CountAmount)
    {
         case 
0:
        {
           ForEach(
iMAX_PLAYERS)
        {
              if(
Joined[i] == false)
            {
                
TextDrawHideForAll(AnuncioCarrera);
                
TextDrawHideForAll(TextoAnuncioCarrera);
                }
               }
                
StartRace();
            }
        case 
1..5:
        {
        new 
string[100];
        ForEach(
iMAX_PLAYERS)
        {
            if(
Joined[i] == true)
            {
                
SetCameraBehindPlayer(i);
                
format(stringsizeof(string), "~G~~h~~h~%d!"CountAmount);
            }
        if(
Joined[i] == true)
        {
            
GameTextForPlayer(istring9995);
            
PlayerPlaySound(i10390.00.00.0);
            }
          }
    }
    case 
6..29:
    {
    new
        
string[100]
                    ;
            
format(stringsizeof(string), "~n~~r~~h~~h~%d!"CountAmount);
            ForEach(
iMAX_PLAYERS)
            {
                if(
Joined[i] == true)
                {
                    
GameTextForPlayer(istring9995);
                    
PlayerPlaySound(i10560.00.00.0);
                }
            }
        }
        case 
30:
        {
            new 
string[500];
            ForEach(
iMAX_PLAYERS)
            {
                if(
MiniJuego[i] == MJ_NO && Joined[i] == false && Informacion[i][Jailed] == 0)
                {
                    
format(stringsizeof(string), "{00FF00}|| Carrera || En %d segundos comienza la carrera {FFFFFF}%s {00FF00}Escribe {FFFFFF}/Join {00FF00}para participar"CountAmount ,RaceName);
                    
SendClientMessage(i,verdestring);
                }
            }
            
TextDrawShowForAll(TextoAnuncioCarrera);
            
TextDrawShowForAll(AnuncioCarrera);
        }
    }
    return 
CountAmount--;
}
function 
StartRace()
{
    ForEach(
iMAX_PLAYERS)
    {
        if(
Joined[i] == true)
        {
            
PlayerPlaySound(i11410.00.00.0);
              
GameTextForPlayer(i"~b~~h~~h~ya ya ya!!!!"20005);
              
UnfreezePlayer);
            
TextDrawHideForAll(AnuncioCarrera);
            
TextDrawHideForAll(TextoAnuncioCarrera);
        }
    }
    
//rCounter = SetTimer("RaceCounter", 10*60, 1);
    
rCounter SetTimer("RaceCounter"9001);
    
RaceTick GetTickCount();
    
RaceStarted 1;
    
KillTimer(CountTimer);
    return 
1;
}
function 
StopRace()
{
    
KillTimer(rCounter);
    
RaceStarted 0;
    
RaceTick 0;
    
JoinCount 0;
    
FinishCount 0;
    
RaceBusy 0x00;
//    TimeProgress = 0;
    
ForEach(iMAX_PLAYERS)
    {
        
GetPlayerVirtualWorld(i);
        if(
GetPlayerVirtualWorld(i) != 0)
        {
            if(
Joined[i] == true)
            {
                
DisablePlayerRaceCheckpoint(i);
                
DestroyVehicle(CreatedRaceVeh[i]);
                
Joined[i] = false;
                
CPProgess[i] = 0;
                
KillTimer(InfoTimer[i]);
                
SetPlayerVirtualWorld(i,0);
                
DisableRemoteVehicleCollisions(i,0);
            }
        }
     }
    
TextDrawHideForAll(AnuncioCarrera);
    
TextDrawHideForAll(TextoAnuncioCarrera);
    if(
AutomaticRace == trueLoadRaceNames(), LoadAutoRace(RaceNames[random(TotalRaces)]);
    return 
1;

Reply
#2

Pues define el MAX_PLAYERS igual a la cantidad del servidor a ver que sucede.
Reply
#3

En realidad, MAX_PLAYERS ya esta definido... Intenta usar GetPlayerPoolSize.
PHP код:
{
    for(new 
0GetPlayerPoolSize(); <= ji++) 
    {
        
SendClientMessage(playerid, -1,"Tu funcion aca xd");
    }

Ademas(No si cambiara en algo), es asi:
PHP код:
foreach(new iPlayer)
{
 
//Funcion

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)