diff --git a/ReallifeGamemode.Client/drugs/hanf.ts b/ReallifeGamemode.Client/drugs/hanf.ts index 4c5339c1..8498db66 100644 --- a/ReallifeGamemode.Client/drugs/hanf.ts +++ b/ReallifeGamemode.Client/drugs/hanf.ts @@ -333,9 +333,15 @@ export default function hanfSystem(globalData: IGlobalData) { let hanfDataIdToObjectMap: Map = new Map(); let hanfDataIdToTextLabelMap: Map = new Map(); - mp.events.add("SERVER:Hanf_UpdateHanfData", dataJson => { - mp.console.logInfo(dataJson); + mp.events.addDataHandler("hanfData", (entity: EntityMp, value) => { + mp.gui.chat.push("neue hanf data"); + if (entity.type == 'player' && entity.remoteId == mp.players.local.remoteId) { + mp.gui.chat.push("eigener user"); + updateHanf(value); + } + }); + function updateHanf(dataJson: string) { var data: Array = >JSON.parse(dataJson) var newPlants = data.filter(d => currentHanfData.filter(x => x.Id === d.Id).length == 0); @@ -378,7 +384,7 @@ export default function hanfSystem(globalData: IGlobalData) { }); currentHanfData = data; - }); + } function getPlantModel(plant: CannabisData): number { var diff = Date.now() - Date.parse(plant.Time); diff --git a/ReallifeGamemode.Server/Managers/HanfManager.cs b/ReallifeGamemode.Server/Managers/HanfManager.cs index 2ea69f0e..e76f95eb 100644 --- a/ReallifeGamemode.Server/Managers/HanfManager.cs +++ b/ReallifeGamemode.Server/Managers/HanfManager.cs @@ -289,7 +289,8 @@ namespace ReallifeGamemode.Server.Managers { cannabisData ??= _currentCannabisData; await NAPI.Task.WaitForMainThread(); - player.TriggerEvent("SERVER:Hanf_UpdateHanfData", JsonConvert.SerializeObject(cannabisData)); + player.SetSharedData("hanfData", JsonConvert.SerializeObject(cannabisData)); + //player.TriggerEvent("SERVER:Hanf_UpdateHanfData"); } [RemoteEvent("CLIENT:Hanf_BuySeeds")]