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



How to... - w00tNew - 16.05.2010

how do i make on player spawn enter the car nearby them?


Re: How to... - MafiaGuy™ - 16.05.2010

Код:
stock GetClosestVehicle(playerid)
{
  new vehicle = -1, Float:dis = 2000.0;
  for(new i = 0; i < MAX_VEHICLES; i++)
  {
  new Float:dis2 = GetPlayerDistanceToVehicle(playerid, i);
  if(dis2 > dis)
  {
  dis = dis2;
  vehicle = i;
  }
  }
  return vehicle;
}
Use putplayerinvehicle function.


Re: How to... - w00tNew - 16.05.2010

thanks!!!!!!!!!!!!! you saved my life


Re: How to... - w00tNew - 16.05.2010

so on
OnPlayerSpawn

i add

PutPlayerInVehicle(playerid, 411, 0); right?


Re: How to... - MafiaGuy™ - 16.05.2010

Код:
public OnPlayerSpawn(playerid)
{
	new vehicle = GetClosestVehicle(playerid);
  PutPlayerInVehicle(playerid, vehicle, 0);
}
and add this somewhere too:

Код:
stock Float:GetPlayerDistanceToVehicle(playerid, vehicleid)
{
  new Float:pos[3];
  GetVehiclePos(vehicleid, pos[0], pos[1], pos[2]);
  return GetPlayerDistanceToPoint(playerid, pos[0], pos[1], pos[2]);
}