SA-MP Forums Archive
Need help on despawning a car. - 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)
+--- Thread: Need help on despawning a car. (/showthread.php?tid=469005)



Need help on despawning a car. - DavidLuango - 11.10.2013

Hello guys, last night I thought i fixed it, but today my tester was online, So when I did /despawncopcar being inside car, I wanted it to despawn the car I am on it only, meaning a cop car.

But It destroyed the car the other player was in, which was id 204 and mine was 205.

I need help making something like this

> It'd despawn only one car at the time.
> Cop would only be despawn cop car
if (strcmp("/despawncopcar", cmdtext, true, 5) == 0)
{
if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pMember] == 14 ||PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pMember] == 5 || PlayerInfo[playerid][pMember] >= // || AdminDuty[playerid]==1 && !(IsPlayerInRangeOfPoint(15.0, playerid,2259.098145, -2389.186279, 19.174612)))
{

new LSPDCAR1;
LSPDCAR1 = GetPlayerVehicleID(playerid);



for(new v = 204; v <= 204; v++)
{
if(LSPDCAR1) DestroyVehicle(v);
}


SendClientMessage(playerid, COLOR_BLUE, "Successfully despawned!");
return 1;
}
}

Help would really be appriciated, I tried way too many things none of them seem to work :/


Re: Need help on despawning a car. - xVIP3Rx - 11.10.2013

Why is there
pawn Код:
for(new v = 204; v <= 204; v++)
?
As I understood you want to destroy the current vehicle the player is in, So
pawn Код:
DestroyVehicle(LSPDCAR1);
will do so.


Re: Need help on despawning a car. - Konstantinos - 11.10.2013

I don't really understand what you want to do especially with that loop.

Would you mind to explain it better?


Re: Need help on despawning a car. - DavidLuango - 11.10.2013

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
I don't really understand what you want to do. Especially with the loop.

Would you mind to explain it better?
The reason why I put loop there is to define the cars that can only be removed.

204 and 205 are some of the cop cars in LSPD, I might be wrong because, when I spawned another car it Spawned with id 205 sultan.

Could someone just help me out on these things

> Destroying only cop vehicles
> Destroying the only ones that are used /despawncopcar being inside the car.


Re: Need help on despawning a car. - Konstantinos - 11.10.2013

Vehicle IDs are managed by the server; therebefore you cannot be sure about what the vehicleid is going to be.

I'd use arrays. Like:
pawn Код:
new
    cop_veh[ 10 ]
;

// It can hold 10 vehicle IDs for cop vehicles (0-9). When you create the car, assign the id to the array and then:

// in your command:
for( new c; c != sizeof( cop_veh ); c++ ) DestroyVehicle( cop_veh[ c ] );



Re: Need help on despawning a car. - xVIP3Rx - 11.10.2013

Also you can destroy all the cars by model, But It will destroy all the vehicles of the same model in whole San andreas.


Re: Need help on despawning a car. - DavidLuango - 11.10.2013

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
Also you can destroy all the cars by model, But It will destroy all the vehicles of the same model in whole San andreas.
I am not exactly looking for that.

@Kos I am trying what you said.

Thank you for the reply.

I didn't get this, could you be more specific and clear for me please ?

new
cop_veh[ 10 ]
;

// It can hold 10 vehicle IDs for cop vehicles (0-9). When you create the car, assign the id to the array and then:

// in your command:
for( new c; c != sizeof( cop_veh ); c++ ) DestroyVehicle( cop_veh[ c ] );