SA-MP Forums Archive
[HELP] Destroying Cars - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Destroying Cars (/showthread.php?tid=274724)



[HELP] Destroying Cars - [AF]Junior - 07.08.2011

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


AW: [HELP] Destroying Cars - Nero_3D - 07.08.2011

Something like that ?

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



Re: [HELP] Destroying Cars - Grim_ - 07.08.2011

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.


Re: [HELP] Destroying Cars - [AF]Junior - 07.08.2011

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.


Re: [HELP] Destroying Cars - dowster - 07.08.2011

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?


Re: [HELP] Destroying Cars - [AF]Junior - 07.08.2011

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


Re: [HELP] Destroying Cars - MadeMan - 07.08.2011

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);
        }
    }
}