Vehicle destroyed bug.
#1

Hello samp

I've issue when some vips or admins spawn vehicle some time there vehicle sometime destroyed even they didn't spawned any car before.
this is also sometime happen like i am driving spawned vehicle another admin/vip spawn vehicle mine vehicle got destroyed and some time his vehicle spawned and destroyed quickly.

Код:
under OnPlayerConnect(playerid)
pInfo[playerid][LastSpawnedCar] = INVALID_VEHICLE_ID

CMD:bike(playerid)return GiveVehicle(playerid,522);
public GiveVehicle(playerid,vehicleid)
{
	    if(pInfo[playerid][LastSpawnedCar] != INVALID_VEHICLE_ID)
		{
	    	DestroyVehicle(pInfo[playerid][LastSpawnedCar]);
			GivePlayerVehicle(playerid,vehicleid);
		}
		if(pInfo[playerid][LastSpawnedCar] == INVALID_VEHICLE_ID)
		{
			GivePlayerVehicle(playerid,vehicleid);
		}
		return 1;
}

GivePlayerVehicle(playerid,vehicleid)
{
	    new Float:x, Float:y, Float:z, Float:angle;
		GetPlayerPos(playerid, x, y, z);
	 	GetPlayerFacingAngle(playerid, angle);
	    new veh = CreateVehicle(vehicleid, x, y, z, angle, -1, -1, -1);
		SetVehicleVirtualWorld(veh, GetPlayerVirtualWorld(playerid));
		LinkVehicleToInterior(veh, GetPlayerInterior(playerid));
		SetVehicleHealth(veh,999);
  		PutPlayerInVehicleEx(playerid, veh, 0);
		pInfo[playerid][LastSpawnedCar] = veh;
                return 1;
}
Kindly help me out thanks.
Reply
#2

Some vehicles spawn a little below the ground surface. You need to create your vehicles a little higher than the player's position.
I once spawned every vehicle-model at the airport, where the ground is flat.
I recorded the player's position, spawn a vehicle, enter it and get the vehicle's coordinates when the player is at the driver seat.
Then calculate the difference in Z-coordinate and the highest deviation is from the cargobob with 1.6 meters offset.
So if you add 1.6 to the z-coordinate, you should do fine.
All those offsets are recorded in my MySQL database and my script adds the offset to the player's position when a vehicle is created and I haven't had a problem since.
Reply
#3

Well i've no issue with Z cord of the vehicle vehicle spawn correctly at the position but issue is they destroyed for unknown issue. But i will still try what you are telling me to do.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)