foreach (var chair in chairs)
{
int obj = RAGE.Game.Object.GetClosestObjectOfType(Player.LocalPlayer.Position.X, Player.LocalPlayer.Position.Y, Player.LocalPlayer.Position.Z, 2.0f, RAGE.Game.Misc.GetHashKey(chair.prop), false, true, true);
Vector3 objCoord = RAGE.Game.Entity.GetEntityCoords(obj, false);
var dist = RAGE.Game.Misc.GetDistanceBetweenCoords(Player.LocalPlayer.Position.X, Player.LocalPlayer.Position.Y, Player.LocalPlayer.Position.Z, objCoord.X, objCoord.Y, objCoord.Z, true);
if (dist < 1.5f)
{
var can_seat = true;
foreach (var player in Entities.Players.All)
{
var targetDist = RAGE.Game.Misc.GetDistanceBetweenCoords(Player.LocalPlayer.Position.X, Player.LocalPlayer.Position.Y, Player.LocalPlayer.Position.Z, objCoord.X, objCoord.Y, objCoord.Z, true);
if (targetDist < 1.0f)
{
can_seat = false;
}
}
if (sitting == false)
{
if (can_seat == false)
{
return;
}
Display_Subtitle(chair.prop + " Press ~b~E~w~ to sit!", 200);
sitting = true;
Player.LocalPlayer.Position = new Vector3(objCoord.X, objCoord.Y + chair.forwardOffset, objCoord.Z + chair.verticalOffset);
Player.LocalPlayer.SetHeading(RAGE.Game.Entity.GetEntityHeading(obj) + chair.angularOffset);
RAGE.Game.Ai.TaskStartScenarioAtPosition(Player.LocalPlayer.Handle, Convert.ToString(chair.scenario), Player.LocalPlayer.Position.X, Player.LocalPlayer.Position.Y, Player.LocalPlayer.Position.Z + 0.9f, RAGE.Game.Entity.GetEntityHeading(obj) + 180.0f, 0, true, true);
}
else
{
Player.LocalPlayer.ClearTasks();
sitting = false;
}
}
}