hanf vielleicht fertig
This commit is contained in:
@@ -47,6 +47,14 @@ namespace ReallifeGamemode.Server.Events
|
||||
return;
|
||||
}
|
||||
|
||||
if(player.HasData("IsCarryingPlant") || player.GetData<bool>("IsCarryingPlant"))
|
||||
{
|
||||
var currentModel = player.GetData<int>("HoldingCannabisPlant");
|
||||
|
||||
player.AddAttachment("CannabisPlantInHand" + currentModel, true);
|
||||
player.ResetData("IsCarryingPlant");
|
||||
}
|
||||
|
||||
using var dbContext = new DatabaseContext();
|
||||
|
||||
User user = player.GetUser(dbContext);
|
||||
|
||||
@@ -41,6 +41,14 @@ namespace ReallifeGamemode.Server.Events
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.HasData("IsCarryingPlant") || player.GetData<bool>("IsCarryingPlant"))
|
||||
{
|
||||
var currentModel = player.GetData<int>("HoldingCannabisPlant");
|
||||
|
||||
player.AddAttachment("CannabisPlantInHand" + currentModel, true);
|
||||
player.ResetData("IsCarryingPlant");
|
||||
}
|
||||
|
||||
var logEntry = new LoginLogoutLogEntry()
|
||||
{
|
||||
LoginLogout = false,
|
||||
|
||||
@@ -21,6 +21,8 @@ using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.WeaponDeal;
|
||||
using ReallifeGamemode.Server.Log;
|
||||
using ReallifeGamemode.Server.Inventory.Items;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ReallifeGamemode.Server.Wanted;
|
||||
|
||||
/**
|
||||
@@ -217,9 +219,61 @@ namespace ReallifeGamemode.Server.Events
|
||||
[RemoteEvent("keyPress:E")]
|
||||
public void KeyPressE(Player player)
|
||||
{
|
||||
if (!player.IsLoggedIn() || player.GetData<bool>("isDead") || player.IsInVehicle) return;
|
||||
if (!player.IsLoggedIn() || player.GetData<bool>("isDead")) return;
|
||||
var user = player.GetUser();
|
||||
|
||||
if (player.IsInVehicle
|
||||
&& player.VehicleSeat == 0
|
||||
&& player.Vehicle.Model == (uint)VehicleHash.Riot
|
||||
&& (user.FactionId == 1 || user.FactionId == 3)
|
||||
&& player.Position.DistanceTo(HanfManager.ASSERVATENKAMMER_POSITION) <= 3
|
||||
/*&& player.IsDuty()*/)
|
||||
{
|
||||
using var dbContext = new DatabaseContext();
|
||||
GTANetworkAPI.Vehicle veh = player.Vehicle;
|
||||
ServerVehicle serverVehicle = veh.GetServerVehicle(dbContext);
|
||||
|
||||
List<VehicleItem> items = InventoryManager.GetVehicleItems(veh);
|
||||
if (items.Count() == 0)
|
||||
{
|
||||
player.SendNotification("Der Riot ist leer");
|
||||
return;
|
||||
}
|
||||
|
||||
IIllegalItem cannabisItem = InventoryManager.GetItem<Cannabis>();
|
||||
IIllegalItem cannabisSeedItem = InventoryManager.GetItem<CannabisSeeds>();
|
||||
|
||||
VehicleItem vehicleCannabisItem = items.Where(i => i.ItemId == cannabisItem.Id).FirstOrDefault();
|
||||
VehicleItem vehicleCannabisSeedItem = items.Where(i => i.ItemId == cannabisSeedItem.Id).FirstOrDefault();
|
||||
|
||||
int cannabisAmount = vehicleCannabisItem?.Amount ?? 0;
|
||||
int cannabisSeedAmount = vehicleCannabisSeedItem?.Amount ?? 0;
|
||||
|
||||
InventoryManager.RemoveVehicleItem(serverVehicle, vehicleCannabisItem, cannabisAmount, player);
|
||||
InventoryManager.RemoveVehicleItem(serverVehicle, vehicleCannabisSeedItem, cannabisSeedAmount, player);
|
||||
|
||||
var price = cannabisSeedAmount * cannabisSeedItem.PriceForConfiscation + cannabisAmount * cannabisItem.PriceForConfiscation;
|
||||
|
||||
logger.LogInformation("Player {0} unloaded the riot truck with {1} cannabis and {2} cannabis seed and the faction got {3}", player.Name, cannabisAmount, cannabisSeedAmount, price);
|
||||
|
||||
var factions = dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 1 || f.Id == 3);
|
||||
foreach (var faction in factions)
|
||||
{
|
||||
faction.BankAccount.Balance += price;
|
||||
}
|
||||
|
||||
player.SendNotification("~g~Der Riot wurde erfolgreich entladen");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.IsInVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.HasData("nearATM"))
|
||||
{
|
||||
ATMManager.ShowAtmUi(player, player.GetData<int>("nearATM"));
|
||||
@@ -245,6 +299,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
JailPoint nearestjailPoint = PositionManager.jailPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5);
|
||||
bool isNearCannabisSeedBuyPoint = HanfManager.IsPlayerNearSeedBuyPoint(player);
|
||||
bool isNearJointManufacturerPoint = HanfManager.IsPlayerNearJointManufacturer(player);
|
||||
bool isNearCannabisSellPoint = HanfManager.IsPlayerNearCannabisSellPoint(player);
|
||||
|
||||
if (user?.FactionId != null)
|
||||
{
|
||||
@@ -766,7 +821,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
|
||||
if (isNearCannabisSeedBuyPoint)
|
||||
{
|
||||
player.TriggerEvent("SERVER:Hanf_BuySeed", HanfManager.SEED_PRICE);
|
||||
HanfManager.ShowPlayerBuySeedMenu(player);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -775,6 +830,39 @@ namespace ReallifeGamemode.Server.Events
|
||||
HanfManager.BuildJointsFromCannabis(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isNearCannabisSellPoint)
|
||||
{
|
||||
HanfManager.PlayerSellCannabis(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.HasData("IsCarryingPlant") || player.GetData<bool>("IsCarryingPlant") && (user.FactionId == 3 || user.FactionId == 1) && player.IsDuty())
|
||||
{
|
||||
using var dbContext = new DatabaseContext();
|
||||
FactionVehicle riot = dbContext.FactionVehicles.Where(f => f.Model == VehicleHash.Riot).ToList().Where(f => f.GetOwners().Contains(3)).FirstOrDefault();
|
||||
if (riot == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GTANetworkAPI.Vehicle riotVehicle = VehicleManager.GetVehicleFromServerVehicle(riot);
|
||||
if (riotVehicle.Position.DistanceTo(player.Position) > 3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var currentModel = player.GetData<int>("HoldingCannabisPlant");
|
||||
|
||||
player.AddAttachment("CannabisPlantInHand" + currentModel, true);
|
||||
player.ResetData("IsCarryingPlant");
|
||||
|
||||
var cannabisItem = InventoryManager.GetItem<Cannabis>();
|
||||
var cannabisSeedsItem = InventoryManager.GetItem<CannabisSeeds>();
|
||||
int itemIdToGive = currentModel == 3 ? cannabisItem.Id : cannabisSeedsItem.Id;
|
||||
int amountToGive = currentModel == 3 ? new Random().Next(4, 10) + 1 : 1;
|
||||
|
||||
InventoryManager.AddItemToVehicleInventory(riotVehicle, itemIdToGive, amountToGive);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:I")]
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using GTANetworkAPI;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.WeaponDeal;
|
||||
using ReallifeGamemode.Server.Log;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Vehicle : Script
|
||||
{
|
||||
private static readonly ILogger logger = LogManager.GetLogger<Vehicle>();
|
||||
|
||||
[RemoteEvent("VehicleMenu_ToggleEngine")]
|
||||
public void VehicleMenuToggleEngineEvent(Player player)
|
||||
{
|
||||
@@ -271,6 +275,8 @@ namespace ReallifeGamemode.Server.Events
|
||||
sV.PositionZ = pos.Z;
|
||||
sV.Heading = v.Heading;
|
||||
|
||||
logger.LogInformation("Player {0} parked the car {1} at x:{2}, y:{3}, z:{4}", player.Name, sV.Id, pos.X, pos.Y, pos.Z);
|
||||
|
||||
|
||||
player.SendNotification("~g~Das Fahrzeug wurde geparkt.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user