hanf wachstum
This commit is contained in:
@@ -3391,6 +3391,19 @@ namespace ReallifeGamemode.Server.Commands
|
||||
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Die Türen wurden erfolgreich neugeladen.");
|
||||
}
|
||||
|
||||
[Command("reloadhanf", "~m~Benutzung: ~s~/reloadhanf")]
|
||||
public void CmdAdminReloadHanf(Player player)
|
||||
{
|
||||
if (!player.GetUser().IsAdmin(AdminLevel.HEADADMIN))
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
HanfManager.UpdateHanfWorldData(new DatabaseContext());
|
||||
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Die Hanfpflanzen wurden erfolgreich neugeladen.");
|
||||
}
|
||||
|
||||
//[Command("house", "~m~Benutzung: ~s~/house [add / remove / price / type / reloadhouses]", GreedyArg = true)]
|
||||
//public void CmdAdminHouse(Player player, string option1 = null, string option2 = null)
|
||||
//{
|
||||
|
||||
@@ -88,8 +88,6 @@ namespace ReallifeGamemode.Server.Events
|
||||
NAPI.World.RequestIpl("ferris_finale_Anim"); // Riesenrad
|
||||
NAPI.World.RequestIpl("Carwash_with_spinners"); // Carwash
|
||||
|
||||
HanfManager.UpdateHanfForPlayer(player);
|
||||
|
||||
TimeSpan currentTime = TimeManager.CurrentTime;
|
||||
bool disableLightMode = currentTime > LightModeTimeFrom && currentTime < LightModeTimeTo;
|
||||
|
||||
|
||||
@@ -115,6 +115,8 @@ namespace ReallifeGamemode.Server.Events
|
||||
ChatService.BroadcastGroup(msg, user.Group);
|
||||
}
|
||||
|
||||
HanfManager.UpdateHanfForPlayer(player);
|
||||
|
||||
string message = string.Empty;
|
||||
|
||||
if (GlobalHelper.CustomJoinMessages.ContainsKey(player.SocialClubName))
|
||||
|
||||
@@ -7,6 +7,7 @@ using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System;
|
||||
using ReallifeGamemode.Database.Entities.Logs;
|
||||
using ReallifeGamemode.Server.Managers;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Event Register (Register.cs)
|
||||
@@ -29,7 +30,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
player.TriggerEvent("SERVER:Login_Error", "Das Passwort muss aus mindestens 6 Zeichen bestehen.");
|
||||
return;
|
||||
}
|
||||
if (dbContext.Users.Where(u => u.SocialClubName == player.SocialClubName).Count()!= 0)
|
||||
if (dbContext.Users.Where(u => u.SocialClubName == player.SocialClubName).Count() != 0)
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Es ist schon ein Konto mit dieser Socialclub-ID registriert.");
|
||||
return;
|
||||
@@ -79,10 +80,12 @@ namespace ReallifeGamemode.Server.Events
|
||||
currentPlayerCreatorDimension++;
|
||||
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
|
||||
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
player.TriggerEvent("toggleCreator",false);
|
||||
player.TriggerEvent("toggleCreator", false);
|
||||
player.SafeTeleport(new Vector3(402.8664, -996.4108, -99.00027));
|
||||
//player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ);
|
||||
|
||||
HanfManager.UpdateHanfForPlayer(player);
|
||||
|
||||
if (GlobalHelper.CountdownUntil > DateTime.Now)
|
||||
{
|
||||
player.TriggerEvent("countdown", (GlobalHelper.CountdownUntil - DateTime.Now).TotalSeconds, GlobalHelper.CountdownText);
|
||||
|
||||
@@ -53,11 +53,23 @@ namespace ReallifeGamemode.Server.Managers
|
||||
/// </summary>
|
||||
private const string PLAYER_CURRENTLY_PLANTING_DATA_KEY = "isPlantingCannabis";
|
||||
|
||||
/// <summary>
|
||||
/// Ab welcher Zeit Pflanzen verwelken
|
||||
/// </summary>
|
||||
private static readonly TimeSpan MAX_PLANT_TIME = TimeSpan.FromHours(6);
|
||||
|
||||
private static readonly TimeSpan MIN_PLANT_TIME_TO_HARVEST = TimeSpan.FromHours(4);
|
||||
|
||||
/// <summary>
|
||||
/// Timer der den Status des Verarbeiters zurücksetzt
|
||||
/// </summary>
|
||||
private static Timer _manufacturerDoneTimer = new Timer(TimeSpan.FromSeconds(10).TotalMilliseconds);
|
||||
|
||||
/// <summary>
|
||||
/// Zufallsgenerator für weibliche Pflanze und erhaltenes Cannabis
|
||||
/// </summary>
|
||||
private static Random _random = new Random();
|
||||
|
||||
private static List<CannabisData> _currentCannabisData = new List<CannabisData>();
|
||||
|
||||
static HanfManager()
|
||||
@@ -99,8 +111,13 @@ namespace ReallifeGamemode.Server.Managers
|
||||
|
||||
private static void OnSeedBuyRangeColShapeEnter(ColShape colShape, Player player)
|
||||
{
|
||||
if (!player.IsLoggedIn())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var user = player.GetUser();
|
||||
if (user.Faction.StateOwned)
|
||||
if (user?.Faction?.StateOwned == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -245,6 +262,93 @@ namespace ReallifeGamemode.Server.Managers
|
||||
player.SendNotification($"Du hast {amount} Hanfsamen gekauft");
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:Hanf_HarvestHanf")]
|
||||
public void HanfManagerHarvestHanf(Player player, long hanfId)
|
||||
{
|
||||
if (!player.IsLoggedIn())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var dbContext = new DatabaseContext();
|
||||
|
||||
User user = player.GetUser(dbContext);
|
||||
CannabisPlant plant = dbContext.CannabisPlants.Find(hanfId);
|
||||
if (plant == null)
|
||||
{
|
||||
logger.LogError("Player {0} tried to harvest cannabis plant {1} but it was not found in database", player.Name, hanfId);
|
||||
}
|
||||
|
||||
if (user.Faction?.StateOwned == true && !(user.FactionId == 3 && player.IsDuty()))
|
||||
{
|
||||
player.SendNotification("~r~Du kannst kein Hanf ernten");
|
||||
return;
|
||||
}
|
||||
|
||||
if (plant.Harvested)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
plant.Harvested = true;
|
||||
|
||||
if (user.FactionId != 3) // Zivi / Gangmember erntet ab
|
||||
{
|
||||
bool isPlantRotten = DateTime.Now - plant.PlantDate > MAX_PLANT_TIME;
|
||||
if (isPlantRotten)
|
||||
{
|
||||
player.SendNotification("~r~Die Pflanze ist leider verrottet");
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isPlantReadyToHarvest = DateTime.Now - plant.PlantDate > MIN_PLANT_TIME_TO_HARVEST;
|
||||
if (!isPlantReadyToHarvest) // Wenn die Pflanze noch nicht ausgewachsen ist
|
||||
{
|
||||
bool getSeedBack = _random.Next(0, 2) == 1; // 50% Chance
|
||||
if(getSeedBack)
|
||||
{
|
||||
IItem cannabisSeedItem = InventoryManager.GetItem<CannabisSeeds>();
|
||||
InventoryManager.AddItemToInventory(player, cannabisSeedItem.Id, 1);
|
||||
player.SendNotification("~g~Du konntest den Samen wieder ausgraben");
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SendNotification("~r~Du konntest den Samen leider nicht wieder ausgraben");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isFemalePlant = _random.Next(0, 10) + 1 <= 8; // 80% Chance dass es eine weibliche Pflanze ist
|
||||
if (isFemalePlant)
|
||||
{
|
||||
int cannabisAmount = _random.Next(4, 10) + 1; // zwischen 5 und 10g Cannabis
|
||||
IItem cannabisItem = InventoryManager.GetItem<Cannabis>();
|
||||
var newWeight = cannabisAmount * cannabisItem.Gewicht;
|
||||
if (!InventoryManager.CanPlayerHoldMoreWeight(player, newWeight))
|
||||
{
|
||||
int restWeightPlayerCanHold = InventoryManager.MAX_USER_INVENTORY - InventoryManager.GetUserInventoryWeight(player);
|
||||
cannabisAmount = restWeightPlayerCanHold / cannabisItem.Gewicht;
|
||||
player.SendNotification("~o~Warnung:~s~ Du hast nicht das komplette Cannabis der Pflanze erhalten, da dein Inventar voll ist");
|
||||
}
|
||||
player.SendNotification("~g~" + cannabisAmount + "g Cannabis geerntet");
|
||||
InventoryManager.AddItemToInventory(player, cannabisItem.Id, cannabisAmount);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SendNotification("~r~Du hast die falschen Samen eingesät und keinen Ertrag aus dieser Pflanze erhalten");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else // FIB erntet ab
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
UpdateHanfWorldData(dbContext);
|
||||
}
|
||||
|
||||
internal static void BuildJointsFromCannabis(Player player)
|
||||
{
|
||||
if (player.HasAnimation(_manufacturerAnim) || _manufacturerCurrentlyUsed)
|
||||
|
||||
Reference in New Issue
Block a user