help with car respawn - 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 with car respawn (
/showthread.php?tid=256132)
help with car respawn -
Marshell - 19.05.2011
So im trying to make it that when a car blows up it respawns at a set location.
Say like the police impound or a scarp yard, I've used search and checked wiki
but to be honest i have no idea what im looking for.
can someone please help me?
Re: help with car respawn -
Sascha - 19.05.2011
either just save the vehicle where it should respawn (that's the normal thing, that nearly everybody does)..
or set it to a certain location when it spawns (you'll need variables for the vehicles in this case)
pawn Код:
new car;
public OnGameModeInit()
{
car = AddStaticVehicle(...);
return 1;
}
public OnVehicleSpawn(vehicleid)
{
if(vehicleid == car)
{
SetVehiclePos(car, x, y, z); //replace it with your positions
SetVehicleZAngle(car, a); // replace it with the heading of the car
}
return 1;
}
or use random spawns
pawn Код:
new VSpawns[][4] =
{
{x, y, z, a}, {x, y, z, a}, {x, y, z, a} //replace the coords with different positions where the car could spawn add
};
new car;
public OnGameModeInit()
{
car = AddStaticVehicle(....); //the car you want to spawn at the random pos
return 1;
}
public OnVehicleSpawn(vehicleid)
{
if(vehicleid == car)
{
new n = random(sizeof(VSpawns));
SetVehiclePos(car, VSpawns[n][0], VSpawns[n][1], VSpawns[n][2]);
SetVehicleZAngle(car, VSpawns[n][3]);
}
return 1;
}
Re: help with car respawn -
Marshell - 19.05.2011
This works for cars saved at that location? because i want cars that have been bought from a Dealership to respawn after been destroyed in a set location
Re: help with car respawn -
Marshell - 20.05.2011
well i tried the ways u said and it only works with cars i place into the script not bought cars.
![Sad](images/smilies/sad.gif)
what i need is like this
A Player buys a car from the Dealership it spawns, they drive around ect car gets damaged and blows up.
On blowing up the car doesnt respawn at there /park place it respawns in an impound or a set location where
all cars will respawn no matter if there from gamemode Createcar (...) or bought from the dealership.
Re: help with car respawn -
Sascha - 20.05.2011
pawn Код:
public OnVehicleSpawn(vehicleid)
{
SetVehiclePos(vehicleid, x, y, z);
SetVehicleZAngle(vehicleid, a);
return 1;
}
Re: help with car respawn -
Marshell - 20.05.2011
thanks it worked that was simple... i feel stupid haha.
also
is there a way to add a radius on there?
say like a car will spawn anywhere within 10 yards or something