Comando de respawn sin uso, funciona mal
#1

Buenas a todos.
Como indica el tнtulo, mi problema es con un comando de respawn de vehнculos sin uso.
El comando lo tengo hecho con una funciуn y un stock, pero el problema es que respawnea todos los vehнculos, inclusive en el que estй subido.
Tengo un comando que funciona bien, pero no guarda el tuning ni el seguro del vehнculo.
Y el comando que tengo con la funciуn, cierra los vehнculos tengan o no puesto el seguro, y guarda el tuning..

Dejу la funciуn a ver si alguien puede ayudarme.


Код:
function rac(playerid)
{
    Loop(c,VEH)
    {
        if(IsAnOwnableCar©)
        {
            SetVehicleToRespawn©;
            SetVehiclePos(c, CarInfo[c][cLocationx],CarInfo[c][cLocationy],CarInfo[c][cLocationz]);
            SetVehicleZAngle(c, CarInfo[c][cAngle]);

            if( CarInfo[ c ][ cOwned ] == 1 )
                SetVehicleParamsEx( c, 0, 0, 0, 1, 0, 0, 0 );
            else
                SetVehicleParamsEx( c, 0, 0, 0, 0, 0, 0, 0 );

            engineOn[c] = false;
            ChangeVehicleColor(c, CarInfo[c][cColorOne], CarInfo[c][cColorTwo]);
            AddCarTuning( c ); // Cr34 =>
        }
        else
            if(!VehEnUso©)
            {
                SetVehicleToRespawn©;
                SetVehicleParamsEx( c, 0, 0, 0, 0, 0, 0, 0 );
                engineOn[c] = false;
            }
    }
    new string[128]
    format(string, sizeof(string), "Respawn General realizado por: %s.", PlayerName(playerid));
  BroadCast(COLOR_GREY,string);
  return 1;
}
Stock:
Код:
stock VehEnUso(vehid)
        {
            for (new i=0; i<MAX_PLAYERS; i++)
                if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
                    if(GetPlayerVehicleID(i) == vehid)
                        return 1;
            return 0;
        }
Reply
#2

No puedo hablar espaсol, estaba pasando por la board Espaсol y vio a su pregunta sin respuesta, a ver si este nuevo cуdigo resuelve su problema:

PHP код:
stock VehEnUso(vehid)
{
    new 
boolnadie false;
    for(new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            if(
IsPlayerInAnyVehicle(i))
            {
                if(
GetPlayerVehicleID(i) == vehid)
                {
                    
nadie true;
                    break;
                }
            }
        }
    }
    return 
nadie;

Reply
#3

Quote:
Originally Posted by NathanLive
Посмотреть сообщение
No puedo hablar espaсol, estaba pasando por la board Espaсol y vio a su pregunta sin respuesta, a ver si este nuevo cуdigo resuelve su problema:

PHP код:
stock VehEnUso(vehid)
{
    new 
boolnadie false;
    for(new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            if(
IsPlayerInAnyVehicle(i))
            {
                if(
GetPlayerVehicleID(i) == vehid)
                {
                    
nadie true;
                    break;
                }
            }
        }???
    }
    return 
nadie;

No funciona, sigue igual
Reply
#4

Mira Samm si no me amas voy a tener que meterte una chancla por el occipital , pero yo se que si me amas ��❤
Reply
#5

Quote:
Originally Posted by HeisenbergEZ
Посмотреть сообщение
Mira Samm si no me amas voy a tener que meterte una chancla por el occipital , pero yo se que si me amas ��❤


Alguien puede ayudarme?
Reply
#6

Yo hice esta funciуn, y funciona muy bien:

pawn Код:
new VehicleExist[MAX_VEHICLES];

stock IsVehicleOcuppied(vehid)
{
    new
        getid;
       
    foreach(new i: Player)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInAnyVehicle(i))
            {
                getid = GetPlayerVehicleID(i);
                if(getid == vehid)
                    return true;
            }
        }
    }
    return false;
}
Y luego estos comandos, para probar:

pawn Код:
CMD:respawnall(playerid, params[])
{
    new
        str[128],
        count=0;
       
    for(new i=0; i<MAX_VEHICLES; i++)
    {
        if(VehicleExist[i] && !IsVehicleOcuppied(i))
        {
            SetVehicleToRespawn(i);
                count++;
        }
    }
        format(str, sizeof(str),"%d vehнculos han sido respawneados", count);
        SendClientMessage(playerid, -1, str);
    return 1;
}

CMD:createcar(playerid, params[])
{
    new
        Float:Pos[4];
       
    GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
    GetPlayerFacingAngle(playerid, Pos[3]);
   
    new vehicle = CreateVehicle(411, Pos[0], Pos[1]+2, Pos[2], Pos[3], 1, 1, -1);
        VehicleExist[vehicle] = true;
    return 1;
}
El VehicleExist lo hice simplemente para que me compruebe los coches que realmente existen en el servidor. Si queres no lo haces y listo, yo porque lo hago asн.

Acб estбn las pruebas de que funciona http://imgur.com/a/GqGBO
Reply
#7

Modifiquй tu comando, pero al usarlo se efectъa correctamente pero muestra el texto del comando incorrecto/inexistente que tiene mi GM.

їCerrй mal o hice algo mal en el comando?

Код:
    CMD:racs(playerid, params[])
{
	for(new i=0; i<MAX_VEHICLES; i++)
	{
		if(!IsVehicleOcuppied(i))
		{
		    SetVehicleToRespawn(i);

			   if( CarInfo[ i ][ cOwned ] == 1 )
			   SetVehicleParamsEx( i, 0, 0, 0, 1, 0, 0, 0 );
			   else
			   SetVehicleParamsEx( i, 0, 0, 0, 0, 0, 0, 0 );

			   engineOn[i] = false;
			   ChangeVehicleColor(i, CarInfo[i][cColorOne], CarInfo[i][cColorTwo]);
			   AddCarTuning( i );
		}
      }
  return 1;
}
Reply
#8

pawn Код:
CMD:racs(playerid, params[])
{
    for(new i=0; i<MAX_VEHICLES; i++)
    {
        if(!IsVehicleOcuppied(i))
        {
            SetVehicleToRespawn(i);

               if( CarInfo[ i ][ cOwned ] == 1 )
                           {
                       SetVehicleParamsEx( i, 0, 0, 0, 1, 0, 0, 0 );
               }
                           else
                           {
                               SetVehicleParamsEx( i, 0, 0, 0, 0, 0, 0, 0 );

                       engineOn[i] = false;
                       ChangeVehicleColor(i, CarInfo[i][cColorOne], CarInfo[i][cColorTwo]);
                       AddCarTuning( i );
                           }
        }
      }
  return 1;
}
Probalo asн y decime
Reply
#9

Quote:
Originally Posted by Juance
Посмотреть сообщение
pawn Код:
CMD:racs(playerid, params[])
{
    for(new i=0; i<MAX_VEHICLES; i++)
    {
        if(!IsVehicleOcuppied(i))
        {
            SetVehicleToRespawn(i);

               if( CarInfo[ i ][ cOwned ] == 1 )
                           {
                       SetVehicleParamsEx( i, 0, 0, 0, 1, 0, 0, 0 );
               }
                           else
                           {
                               SetVehicleParamsEx( i, 0, 0, 0, 0, 0, 0, 0 );

                       engineOn[i] = false;
                       ChangeVehicleColor(i, CarInfo[i][cColorOne], CarInfo[i][cColorTwo]);
                       AddCarTuning( i );
                           }
        }
      }
  return 1;
}
Probalo asн y decime
Sigue tirando el error, a pesar de que el comando en sн hace lo que se le pide..
Reply
#10

Raro che...proba colocando el "i" del bucle en 1.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)