[HELP] Destroying Cars
#1

I need a command to destroy the cars of the variables CarVIP[playerid] and caradm[playerid]. I tried and failed.

Look this:

pawn Код:
if(strcmp(cmd, "/respawncars", true) == 0 || strcmp(cmd, "/rc", true) == 0)
{
    ResetCars();
    return 1;
}
pawn Код:
stock ResetCars(playerid)
{
    for( new i = 0; i < MAX_VEHICLES; i++ )
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(IsPlayerInVehicle(playerid, CarVIP[playerid] && caradm[playerid])) {
            DestroyVehicle(vehicleid);
        }
    }
}
Fail
Reply
#2

Something like that ?

pawn Код:
stock ResetCars() {
    for(new i; i != MAX_PLAYERS; ++i) {
        SetVehicleToRespawn(CarVip[i]);
        SetVehicleToRespawn(caradm[i]);
    }
}
Reply
#3

You're trying to destroy the vehicles for the player that are stored in CarVIP and caradm? And only if they are in one or the other? If so, something like this should do the trick:
pawn Код:
stock ResetCars( playerid )
{
   if( IsPlayerInVehicle( playerid, CarVIP[ playerid ] ) || IsPlayerInVehicle( playerid, caradm[ playerid ] ) )
   {
      DestroyVehicle( CarVIP[ playerid ] );
      DestroyVehicle( caradm[ playerid ] );
   }
}
However, if you're trying to destroy whichever the player is ine:
pawn Код:
stock ResetCars( playerid )
{
   if( IsPlayerInVehicle( playerid, CarVIP[ playerid ] ) )
   {
      DestroyVehicle( CarVIP[ playerid ] );
   }
   else if( IsPlayerInVehicle( playerid, caradm[ playerid ] ) )
   {
      DestroyVehicle( caradm[ playerid ] );
   }
}
Please explain more thoroughly what you're trying to accomplish.
Reply
#4

When I respawn and I'm inside the vehicle, the vehicle is destroyed and I'm on foot. When I respawn outside the vehicle, the vehicle for a respawn and it is not destroyed.

I want the vehicle to be destroyed and not respawn. Sorry for my bad english.
Reply
#5

just so you know you arent using the loop correctly, do you want it to check every vehicle that players are in, and respawn them. or just respawn all the vip and admin vehicles?
Reply
#6

I want to respawn in normal cars and destroy cars vip and admin not being used.
Reply
#7

pawn Код:
stock ResetCars()
{
    new vehicleused[MAX_VEHICLES];
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
            vehicleused[GetPlayerVehicleID(i)] = 1;
        }
    }
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(CarVIP[i] && !vehicleused[CarVIP[i]])
        {
            DestroyVehicle(CarVIP[i]);
            CarVIP[i] = 0;
        }
        if(caradm[i] && !vehicleused[caradm[i]])
        {
            DestroyVehicle(caradm[i]);
            caradm[i] = 0;
        }
    }
    for(new i=0; i < MAX_VEHICLES; i++)
    {
        if(!vehicleused[i])
        {
            SetVehicleToRespawn(i);
        }
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)