OnVehicleSpawn problem
#1

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

No one?
Reply
#3

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)