help with car respawn
#1

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?
Reply
#2

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;
}
Reply
#3

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
Reply
#4

well i tried the ways u said and it only works with cars i place into the script not bought cars.
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.
Reply
#5

pawn Код:
public OnVehicleSpawn(vehicleid)
{
  SetVehiclePos(vehicleid, x, y, z);
  SetVehicleZAngle(vehicleid, a);
  return 1;
}
Reply
#6

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)