View Full Version : Vehicle despawn

07/03/2013, 05:30 PM
Hello, today i started to make vehicle ownership.

I made that when you buy your car it automaticly spawns next to dealership, then you can type buypark and it changes parking place, it all works good but when i despawn it i cant get it anymore.

I use this for despawning

new currentveh;
currentveh = GetPlayerVehicleID(playerid);

Maybe its wrong?

07/03/2013, 06:23 PM

07/03/2013, 06:35 PM
Can you link me code?

07/03/2013, 06:45 PM
I didn't get you, explain further details please.

07/03/2013, 07:18 PM

When i type command /buypark It saves coordinates X,Y,Z

And when i type command /getcar It creates vehicle to saved X,Y,Z

But i want to despawn it driving to my point where i bought BUYPARK and i type /park

my /park commands code is this

new currentveh;
currentveh = GetPlayerVehicleID(playerid);

But when i park it, it doesnt spawns back using command /getcar.

Maybe i dont have to Destroy it but despawn in other way?

08/03/2013, 07:32 AM

08/03/2013, 07:47 AM
I think you may be looking to respawn the vehicle??

If that is the case, try http://wiki.sa-mp.com/wiki/SetVehicleToRespawn .
Then under OnVehicleSpawn, check if it is a car spawned by a player, then set it to the X, Y and Z coordinates.

08/03/2013, 07:48 AM
it's simple when u do that /buypark cmd the vehicle completely gets destroyed and in order to get it back u need a server restart if it's imported in the script! The solution is a way that everyone uses

change from

new currentveh;
currentveh = GetPlayerVehicleID(playerid);

new currentveh = GetPlayerVehicleID(playerid), Float:x, Float:y, Float:z, Float:Za;
GetVehiclePos(currentveh, x, y,z);
GetVehicleZAngle(currentveh, Za);
CreateVehicle(411, x, y, z, Za, 0, 0, -1) // The model 411 is just an example change it with your ways to the model that got destroyed

08/03/2013, 08:08 AM
Nope guys, thats not what im looking for. Maybe im explaining it very incomprehensible.

You all know rp servers where you can park car its not like you set it to spawn place but car just disappears.

And when its parked (disappeared) you can spawn another of your cars (because spawned car limit is 1)

Basicly i have 3 commands

/getcar - this spawns your car.

SCM(playerid,-1,"Folow the red marker to find your car");
SetPlayerCheckpoint(playerid, CarInfo[vehid][cLocationx], CarInfo[vehid][cLocationy],CarInfo[vehid][cLocationz], 3.0);


new Float:x;
new Float:y;
new Float:z;

new vehid;
vehid = GetPlayerVehicleID(playerid);
GetVehiclePos(vehid, x, y, z);
CarInfo[vehid][cLocationx] = x;
CarInfo[vehid][cLocationy] = y;
CarInfo[vehid][cLocationz] = z;
SCM(playerid,red,"Your parking place changed");


new currentveh;
currentveh = GetPlayerVehicleID(playerid);
CarInfo[playerid][cSpawned] = 0;
return 1;

I havent set spawning limit yet so i can do /buypark and then /getcar wihout destroying my current car, wihout destroying it spawns where i did /buypark but when i destroy it, when i do /getcar it spawns somewhere in blueberry i have no ideas why.

And when car is destroyed(like i smash it into tree and it explodes) i want that it disappears too and i have to do /getcar to spawn it back.

08/03/2013, 09:04 AM
Problem solved, thanks enyone who tried to help!