SA-MP Forums Archive
Need help. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need help. (/showthread.php?tid=113596)



Need help. - lakierka - 14.12.2009

Hello. I'm trying to do if player exit vehicle he would be put in his last vehicle.. I do almost everything but I don't know how to but player in vehicle.. Here is the script

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(pInfo[playerid][Event][2] == true && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && pInfo[playerid][SfStuntLvl] == 1)
	{
		SetPlayerPos(StuntVeh, -1683.7195,551.2001,38.0144);
		SetPlayerFacingAngle(StuntVeh, 316.9490);
           PutPlayerInVehicle(playerid, veh.., 0);
	}
	return 1;
}
With player pos all good.. Server sets pos in these coords..


Re: Need help. - LarzI - 14.12.2009

Use this:
pawn Код:
//global
new gPrevVehicle[ MAX_PLAYERS ];
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
  gPrevVehicle[ playerid ] = vehicleid;
  return true;
}
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate) //If this code doesn't work, use the next code
{
  if( oldstate == PLAYER_STATE DRIVER && newstate == PLAYER_STATE_ONFOOT )
    PutPlayerInVehicle( playerid, gPrevVehicle[ playerid ], 0 );
  return true;
}
That should work.