OnVehicleSpawn problem - 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: OnVehicleSpawn problem (
/showthread.php?tid=72168)
OnVehicleSpawn problem -
lennard - 06.04.2009
Hello,
when a car spawn, it should change the position. But it doesn't work.
Код:
public OnVehicleSpawn(vehicleid)
{
motors[vehicleid] = 0;
if(vehicleid > 215 && vehicleid < 240)
{
new Float:X, Float:Y, Float:Z;
new string[256];
format(string, sizeof(string), "%dx", vehicleid);
X = dini_Float("Autohaus2.ini", string);
format(string, sizeof(string), "%dy", vehicleid);
Y = dini_Float("Autohaus2.ini", string);
format(string, sizeof(string), "%dz", vehicleid);
Z = dini_Float("Autohaus2.ini", string);
if(X == 999 && Y == 999 && Z == 999)
{
} else {
SetVehiclePos(vehicleid, X, Y, Z);
}
}
return 1;
}
Edit:
https://sampwiki.blast.hk/wiki/SetVehiclePos
Quote:
Important note: This function ONLY works if someone has been in the vehicle since it spawn.
|
Who know how i set a vehicle used when it spawn?
Re: OnVehicleSpawn problem -
lennard - 06.04.2009
No one?
Re: OnVehicleSpawn problem -
Kinetic - 06.04.2009
Set a timer for about 2 seconds after vehicle spawn(has to be a global timer or a timer outside of your onvehiclespawn callback). I have done this for my /park command and when the car blows up, it spawns in the correct spot.
pawn Код:
public OnVehicleSpawn(vehicleid) // OnVehicleSpawn
{
Spawning[vehicleid] += 2;
return 1;
} //----------
pawn Код:
public SecondTimer() // SecondTimer
{
for(new c=1; c<=CarCount; c++)
{
if(Spawning[c] > 0)
{
new tmpowner = CarsOwner[c];
SetVehiclePos(c, PlayerCar[tmpowner][x], PlayerCar[tmpowner][y], PlayerCar[tmpowner][z]);
SetVehicleZAngle(c, PlayerCar[tmpowner][ang]);
Spawning[c]--;
}
}
return 1;
}
Mine looks somethin like that, but yours will look quite a bit different.