CurrentVehicle , Old vehicle
#1

Hi

I face many problens with destroy old vehicle (unused)
Now when i drive a vehicle after 5 seconds my car is gone.. now can i make currentvehicle and old vehicle so when player spawn new vehicle delete the old and when he death destroy both? I hope some 1 can help because im suffering from this problem!

Underonplayerdeath
Код:
if(CurrentSpawnedVehicle[playerid] != -1)
		{
			DestroyVehicle(CurrentSpawnedVehicle[playerid]);
		}
Under command cars for example
Код:
CreateVehicleEx(playerid,582, X,Y,Z+1, Angle, random(126), random(126), -1);
my codes:
Код:
stock CreateVehicleEx(playerid, modelid, Float:posX, Float:posY, Float:posZ, Float:angle, Colour1, Colour2, respawn_delay)
{
	new world = GetPlayerVirtualWorld(playerid);
	new interior = GetPlayerInterior(playerid);
	if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	{
		DestroyVehicle(GetPlayerVehicleID(playerid));
		GetPlayerPos(playerid, posX, posY, posZ);
		GetPlayerFacingAngle(playerid, angle);
		if(CurrentSpawnedVehicle[playerid] != -1)
		{
			DestroyVehicle(CurrentSpawnedVehicle[playerid]);
		}
		CurrentSpawnedVehicle[playerid] = CreateVehicle(modelid, posX, posY, posZ, angle, Colour1, Colour2, respawn_delay);
        LinkVehicleToInterior(CurrentSpawnedVehicle[playerid], interior);
		SetVehicleVirtualWorld(CurrentSpawnedVehicle[playerid], world);
		SetVehicleZAngle(CurrentSpawnedVehicle[playerid], angle);
		PutPlayerInVehicle(playerid, CurrentSpawnedVehicle[playerid], 0);
		SetPlayerInterior(playerid, interior);
	}
	if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
	{
	    if(IsVehicleOccupied(CurrentSpawnedVehicle[playerid])) {} else DestroyVehicle(CurrentSpawnedVehicle[playerid]);
		GetPlayerPos(playerid, posX, posY, posZ);
		GetPlayerFacingAngle(playerid, angle);
		if(CurrentSpawnedVehicle[playerid] != -1)
		{
			DestroyVehicle(CurrentSpawnedVehicle[playerid]);
		}
		CurrentSpawnedVehicle[playerid] = CreateVehicle(modelid, posX, posY, posZ, angle, Colour1, Colour2, respawn_delay);
		LinkVehicleToInterior(CurrentSpawnedVehicle[playerid], interior);
		SetVehicleVirtualWorld(CurrentSpawnedVehicle[playerid], world);
		SetVehicleZAngle(CurrentSpawnedVehicle[playerid], angle);
		PutPlayerInVehicle(playerid, CurrentSpawnedVehicle[playerid], 0);
		SetPlayerInterior(playerid, interior);
	}
	return 1;
    }
Reply
#2

Taken from https://sampwiki.blast.hk/wiki/CreateVehicle...
Quote:

(modelid, Float, Float:y, Float:z, Float:angle, color1, color2, respawn_delay)
modelid The model for the vehicle.
Float:X The X coordinate for the vehicle.
Float:Y The Y coordinate for the vehicle.
Float:Z The Z coordinate for the vehicle.
Float:angle The facing angle for the vehicle.
color1 The primary color ID.
color2 The secondary color ID.
respawn_delay The delay until the car is respawned without a driver in seconds. Using -1 will prevent the vehicle from respawning.

Notice where it says respawn_delay. This is the amount of time before the vehicle will respawn. Use "-1" to prevent it from respawning. This is assuming that you are using CreateVehicle.

And you mean when the player spawns or when the player spawns a vehicle?
Reply
#3

Please help seriuosly, dude i edited my post plz read again my problem with /cars cmd its mske flood thus im trying to destroy old vehivles but now when player get vehicle after 3 seconds its gone
Reply
#4

Why are you posting the same damn problem over and over?
The answers are never gonna change. Check the respawn delay parameter, and figure it out yourself, no one is going to code anything for you, in case that's what you mean by "Please help seriously".
Reply
#5

Quote:
Originally Posted by Manyula
Посмотреть сообщение
Why are you posting the same damn problem over and over?
The answers are never gonna change. Check the respawn delay parameter, and figure it out yourself, no one is going to code anything for you, in case that's what you mean by "Please help seriously".
Wont help dont fu## post!
Reply
#6

Bump :/
Reply
#7

Well, I never see you setting CurrentSpawnedVehicle to -1 which has to be done right after each DestroyVehicle(CurrentSpawnedVehicle) and on initialising newly connected players.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)