SA-MP Forums Archive
setvehicletorespawn - 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: setvehicletorespawn (/showthread.php?tid=381007)



setvehicletorespawn - PaulDinam - 27.09.2012

i have another problem after it happend the vehicle does not respawn...

Код:
if(newstate == PLAYER_STATE_ONFOOT && isDelivering[playerid] == 1)
	{
		new playerveh = GetPlayerVehicleID(playerid);
		SendClientMessage(playerid, COLOR_NEWS, "You left your bike, and failed the mission");
		DisablePlayerCheckpoint(playerid);
		isDelivering[playerid] = 0;
		LCP[playerid] = 0;
		KillTimer(pizzatimer[playerid]);
		TextDrawSetString(Textdraw38[playerid], "");
		TogglePlayerControllable(playerid, 1);
		TextDrawHideForPlayer(playerid,Textdraw38[playerid]);
		
		
		PutPlayerInVehicle(playerid, playerveh, 0);
		TogglePlayerControllable(playerid,1);
		SetVehicleToRespawn(playerveh);
	}



Re: setvehicletorespawn - zDevon - 27.09.2012

You're trying to respawn 'playerveh' which you've defined using GetPlayerVehicleID. Great, except you're calling that code once the player is already on foot (so they aren't in a vehicle anymore) and 'playerveh' is returning as zero.


Re: setvehicletorespawn - Vince - 27.09.2012

Well, what do you expect? OnPlayerStateChange is called AFTER the state is changed thus GetPlayerVehicleID will just return 0. Use OnPlayerExitVehicle instead.
Edit: Slightly too slow.