SA-MP Forums Archive
Vehicles disappearing after a few seconds - 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)
+--- Thread: Vehicles disappearing after a few seconds (/showthread.php?tid=663245)



Vehicles disappearing after a few seconds - KevTheJoker - 26.01.2019

There is a bug that I'm unable to fix within the script that I'm using. When I spawn a temporary vehicle or buy a vehicle from a dealership, it de-spawns. In order to get back to that vehicle, if it's a temporarily spawned one, I have to check for it's ID with the /oldcar cmd and teleport to it and if it's a purchased vehicle, I have to enter my vehicle storage,respawn and teleport to it. It's extremely annoying.

How to fix this bug/glitch or whatever it's known as?


Re: Vehicles disappearing after a few seconds - KevTheJoker - 26.01.2019

Does anyone have a fix for this problem?


Re: Vehicles disappearing after a few seconds - d3Pedro - 26.01.2019

Provide your vehicle code, this is the only way to get help so we can figure out the "glitch".
Check around your script where SetVehicleToRespawn is used and how do you create the vehicle when player purchase/spawn it.


Re: Vehicles disappearing after a few seconds - KevTheJoker - 27.01.2019

Found 9 codes that includes 'SetVehicleToRespawn' with the aid of Notepad++:

Code One:
Code:
CancelActiveCheckpoint(playerid)
{
    if(PlayerInfo[playerid][pDrivingTest])
	{
	    SetVehicleToRespawn(PlayerInfo[playerid][pTestVehicle]);
	}
	if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_CARRY)
	{
	    SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
	    RemovePlayerAttachedObject(playerid, 9);
    }

    DisablePlayerCheckpoint(playerid);

	PlayerInfo[playerid][pCP] = CHECKPOINT_NONE;
	PlayerInfo[playerid][pPizzas] = 0;
	PlayerInfo[playerid][pSmuggleMats] = 0;
	PlayerInfo[playerid][pSmuggleDrugs] = 0;
	PlayerInfo[playerid][pDrivingTest] = 0;
	PlayerInfo[playerid][pTestVehicle] = INVALID_VEHICLE_ID;
	PlayerInfo[playerid][pTestCP] = 0;
    PlayerInfo[playerid][pMiningRock] = 0;
    PlayerInfo[playerid][pShipment] = -1;
}
Code Two:
Code:
PlayerInfo[playerid][pTestCP]++;

	        if(PlayerInfo[playerid][pTestCP] < sizeof(drivingTestCPs))
	        {
	            if(!(testVehicles[0] <= GetPlayerVehicleID(playerid) <= testVehicles[4]))
	            {
					SendClientMessage(playerid, COLOR_LIGHTRED, "** You failed the test as you left your vehicle.");
	                DisablePlayerCheckpoint(playerid);
		    		SetVehicleToRespawn(PlayerInfo[playerid][pTestVehicle]);

				    PlayerInfo[playerid][pCP] = CHECKPOINT_NONE;
		            PlayerInfo[playerid][pDrivingTest] = 0;
				}
				else
				{
		            SetPlayerCheckpoint(playerid, drivingTestCPs[PlayerInfo[playerid][pTestCP]][0], drivingTestCPs[PlayerInfo[playerid][pTestCP]][1], drivingTestCPs[PlayerInfo[playerid][pTestCP]][2], 3.0);
				}
			}
			else
Code Three:
Code:
 new
			        Float:health;

				GetVehicleHealth(PlayerInfo[playerid][pTestVehicle], health);

			    if(health < 900.0)
			    {
			        GameTextForPlayer(playerid, "~r~Failed", 5000, 1);
			        SendClientMessage(playerid, COLOR_LIGHTRED, "** You brought back the vehicle damaged and therefore failed your test.");
			    }
			    else
			    {
                    GameTextForPlayer(playerid, "~w~Passed!~n~~r~-$500", 5000, 1);
			        SendClientMessage(playerid, COLOR_AQUA, "You successfully passed your drivers test and received your license!");

			        GivePlayerCash(playerid, -500);
			        PlayerInfo[playerid][pCarLicense] = 1;

			        mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "UPDATE users SET carlicense = 1 WHERE uid = %i", PlayerInfo[playerid][pID]);
			        mysql_tquery(connectionID, queryBuffer, "", "");
			    }

	    		DisablePlayerCheckpoint(playerid);
	    		SetVehicleToRespawn(PlayerInfo[playerid][pTestVehicle]);

			    PlayerInfo[playerid][pCP] = CHECKPOINT_NONE;
	            PlayerInfo[playerid][pDrivingTest] = 0;
	        }
Code Four:
Code:
else if(oldstate == PLAYER_STATE_DRIVER)
	{
     	if(PlayerInfo[playerid][pDrivingTest])
	    {
         	PlayerInfo[playerid][pDrivingTest] = 0;
         	SetVehicleToRespawn(PlayerInfo[playerid][pTestVehicle]);
         	SendClientMessage(playerid, COLOR_LIGHTRED, "** You have left the vehicle and therefore failed the test.");
		}

	    PlayerTextDrawHide(playerid, PlayerInfo[playerid][pText][1]);
	    PlayerTextDrawHide(playerid, PlayerInfo[playerid][pText][2]);
	}
Code Five:
Code:
if(!strcmp(option, "job", true))
	{
		for(new i = 1; i < MAX_VEHICLES; i ++)
		{
	    	if(IsValidVehicle(i) && !IsVehicleOccupied(i) && !adminVehicle{i})
		    {
		        if((pizzaVehicles[0] <= i <= pizzaVehicles[5]) || (courierVehicles[0] <= i <= courierVehicles[6]) || (sweeperVehicles[0] <= i <= sweeperVehicles[3]) || (taxiVehicles[0] <= i <= taxiVehicles[3]) || (VehicleInfo[i][vJob] != JOB_NONE))
		        {
	        		SetVehicleToRespawn(i);
				}
	 		}
		}

		SendClientMessageToAllEx(COLOR_LIGHTRED, "AdmCmd: %s respawned all unoccupied job vehicles.", GetPlayerRPName(playerid));
	}
Code Six:
Code:
for(new i = 1; i < MAX_VEHICLES; i ++)
		{
	    	if(IsValidVehicle(i) && !IsVehicleOccupied(i) && !adminVehicle{i} && VehicleInfo[i][vFactionType] == type)
	    	{
				SetVehicleToRespawn(i);
			}
		}
Code Seven:
Code:
else if(!strcmp(option, "nearby", true))
	{
		for(new i = 1; i < MAX_VEHICLES; i ++)
		{
	    	if(IsValidVehicle(i) && !IsVehicleOccupied(i) && !adminVehicle{i} && IsVehicleStreamedIn(i, playerid))
		    {
				SetVehicleToRespawn(i);
			}
		}

		SendClientMessageToAllEx(COLOR_LIGHTRED, "AdmCmd: %s respawned all unoccupied vehicles in %s.", GetPlayerRPName(playerid), GetPlayerZoneName(playerid));
	}
Code Eight:
Code:
else if(!strcmp(option, "all", true))
	{
		for(new i = 1; i < MAX_VEHICLES; i ++)
		{
	    	if(IsValidVehicle(i) && !IsVehicleOccupied(i) && !adminVehicle{i})
		    {
				SetVehicleToRespawn(i);
			}
		}

		SendClientMessageToAllEx(COLOR_LIGHTRED, "AdmCmd: %s respawned all unoccupied vehicles.", GetPlayerRPName(playerid));
	}
Code Nine:
Code:
 for(new i = 1; i < MAX_VEHICLES; i ++)
	{
	    if(IsValidVehicle(i) && VehicleInfo[i][vID] > 0 && VehicleInfo[i][vGang] == PlayerInfo[playerid][pGang] && !IsVehicleOccupied(i))
	    {
	        SetVehicleToRespawn(i);
		}
	}



Re: Vehicles disappearing after a few seconds - d3Pedro - 27.01.2019

You're using a leaked script which is not allowed to do. I will not help you, make your own.


Re: Vehicles disappearing after a few seconds - Bolex_ - 27.01.2019

Quote:
Originally Posted by ConnorW
View Post
You're using a leaked script which is not allowed to do. I will not help you, make your own.
A non-resident post as you have such materials so no one has made any noise and in the end it has helped you. If so category scripting help wouldn't make sense, right ?


Re: Vehicles disappearing after a few seconds - Nyzenic - 27.01.2019

I guess you're using Limitless Roleplay.
Under FuelTimer, find the DestroyVehicle function and remove it.


Re: Vehicles disappearing after a few seconds - KevTheJoker - 28.01.2019

Quote:
Originally Posted by ConnorW
View Post
You're using a leaked script which is not allowed to do. I will not help you, make your own.
Uhm... if you're not gonna help me, I suggest that you don't reply. It only builds your post count and that's basically farming. And, I can use any script I want, since it won't be bothering you. Get a life, jerk.


Re: Vehicles disappearing after a few seconds - KevTheJoker - 28.01.2019

Quote:
Originally Posted by zerruv
View Post
I guess you're using Limitless Roleplay.
Under FuelTimer, find the DestroyVehicle function and remove it.
Oh sweet, thanks for the assistance. It worked! +1 Rep from me btw.