57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
using GTANetworkAPI;
|
|
using reallife_gamemode.Server.Entities;
|
|
using reallife_gamemode.Server.Extensions;
|
|
using System.Collections.Generic;
|
|
|
|
namespace reallife_gamemode.Server.Managers
|
|
{
|
|
class TuningManager : Script
|
|
{
|
|
private static List<ColShape> tuningGarages = new List<ColShape>();
|
|
|
|
/// <summary>
|
|
/// Fügt eine Tuning-Garage zum Spiel hinzu
|
|
/// </summary>
|
|
/// <param name="pos">Die Position der Garage</param>
|
|
public static void AddTuningGarage(Vector3 pos)
|
|
{
|
|
ColShape colShape = NAPI.ColShape.CreateSphereColShape(pos, 10, 0);
|
|
|
|
colShape.OnEntityEnterColShape += (cs, c) =>
|
|
{
|
|
if(c.IsInVehicle)
|
|
{
|
|
Vehicle v = c.Vehicle;
|
|
if(v.GetServerVehicle() is FactionVehicle fV && fV.GetFaction().StateOwned)
|
|
{
|
|
return;
|
|
}
|
|
c.TriggerEvent("showTuningInfo");
|
|
}
|
|
};
|
|
|
|
colShape.OnEntityExitColShape += (cs, c) =>
|
|
{
|
|
c.TriggerEvent("hideTuningInfo", true);
|
|
};
|
|
|
|
tuningGarages.Add(colShape);
|
|
}
|
|
|
|
[RemoteEvent("startPlayerTuning")]
|
|
public void StartPlayerTuning(Client player)
|
|
{
|
|
if (!player.IsInVehicle) return;
|
|
|
|
player.TriggerEvent("showTuningMenu");
|
|
}
|
|
|
|
[RemoteEvent("setVehicleMod")]
|
|
public void SetVehicleMod(Client player, int slot, int index)
|
|
{
|
|
if (index == 0) index--;
|
|
player.Vehicle.SetMod(slot, index - 1);
|
|
}
|
|
}
|
|
}
|