20.01.2012, 16:28
hm... i would do that like:
before spawning the car, its stored in a Variable, i assume. when the car spawns, remark its ID:
after the vehicle spawned, and its ID is "written down" in Car, its time to set a PVar.which stores that vehicle id:
from now on you can use that
when you destroy that vehicle now, you need to delete the pvar aswell, coz its referring to a not existing vehicle (or even worse, a wrong one).
..if this all aucceds and works like mentioned, its easy to enhance the whole script to work like that. its a good idea to search for "vehicle" in the entire script, and look if some changes are required.
edit: just noticed: when you /despawnmycar, then the car will be lost. you need to ad one more variable which tells the vehicle model id, so you can spawn it again...
before spawning the car, its stored in a Variable, i assume. when the car spawns, remark its ID:
pawn Код:
new Car=CreateVehicle();//if you got 1900 cars on your map already, then this vehicle will get ID 1901 assigned. this 1901 will get stored in Car. like Car=1901;
pawn Код:
SetPVarInt(playerid,"VehicleIDOwned",Car);
pawn Код:
GetPVarInt(playerid,"VehicleIDOwned")
pawn Код:
//despawnmycar
DestroyVehicle(GetPVarInt(playerid,"VehicleIDOwned");
DeletePVar(playerid,"VehicleIDOwned");
edit: just noticed: when you /despawnmycar, then the car will be lost. you need to ad one more variable which tells the vehicle model id, so you can spawn it again...