78 lines
2.3 KiB
C#
78 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using GTANetworkAPI;
|
|
using ReallifeGamemode.Database.Entities;
|
|
using ReallifeGamemode.Server.Extensions;
|
|
using ReallifeGamemode.Server.Types;
|
|
using ReallifeGamemode.Server.Util;
|
|
using ReallifeGamemode.Server.WeaponDeal;
|
|
|
|
namespace ReallifeGamemode.Server.Events
|
|
{
|
|
|
|
public class EnterVehicleAttempt : Script
|
|
{
|
|
[ServerEvent(Event.PlayerEnterVehicleAttempt)]
|
|
public void OnPlayerEnterVehicleAttempt(Player player, GTANetworkAPI.Vehicle vehicle, sbyte seat)
|
|
{
|
|
if ((VehicleHash)vehicle.Model == VehicleHash.Dune3)
|
|
{
|
|
if (seat == 1) seat = 0;
|
|
else if (seat == 0) seat = 1;
|
|
}
|
|
|
|
if (seat != 0) return;
|
|
|
|
User u = player.GetUser();
|
|
|
|
if (vehicle.GetServerVehicle() is FactionVehicle veh)
|
|
{
|
|
if (!veh.GetOwners().Contains(player.GetUser().FactionId ?? 0) && !(u.IsAdmin(AdminLevel.HEADADMIN) && GlobalHelper.DutyAdmins.Contains(player)))
|
|
{
|
|
if ((VehicleHash)vehicle.Model == VehicleHash.Burrito3)
|
|
{
|
|
if (WeaponDealManager.checkWeaponDbyVehicle(vehicle))
|
|
return;
|
|
}
|
|
player.StopAnimation();
|
|
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
|
return;
|
|
}
|
|
|
|
}
|
|
if (vehicle.GetServerVehicle() is SchoolVehicle sVeh)
|
|
{
|
|
if (!player.HasData("ActiveSchool"))
|
|
{
|
|
player.StopAnimation();
|
|
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
|
return;
|
|
}
|
|
if (sVeh.SchoolId != player.GetData<int>("ActiveSchool"))
|
|
{
|
|
player.StopAnimation();
|
|
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
|
return;
|
|
}
|
|
}
|
|
if (vehicle.GetServerVehicle() is NoobVehicle nVeh)
|
|
{
|
|
if (!player.IsAdminDuty())
|
|
{
|
|
if (player.GetUser().PlayedMinutes > 1800)
|
|
{
|
|
player.StopAnimation();
|
|
player.SendNotification("~r~Du hast schon über 30 Spielstunden!", true);
|
|
return;
|
|
}
|
|
}
|
|
else if (player.IsAdminDuty())
|
|
{
|
|
player.SendNotification("~g~Freie Fahrt!", true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|