Need help on despawning a car.
#1

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 :/
Reply
#2

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.
Reply
#3

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

Would you mind to explain it better?
Reply
#4

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.
Reply
#5

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 ] );
Reply
#6

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

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 ] );
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)