From 50fb50f9f0a8512e7658a46bb13b158a565b6ee4 Mon Sep 17 00:00:00 2001 From: hydrant Date: Thu, 27 May 2021 23:41:30 +0200 Subject: [PATCH 1/4] rvtl fix hanf --- ReallifeGamemode.Client/drugs/hanf.ts | 8 ++++++-- ReallifeGamemode.Server/Managers/HanfManager.cs | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ReallifeGamemode.Client/drugs/hanf.ts b/ReallifeGamemode.Client/drugs/hanf.ts index 4c5339c1..ac37a8d3 100644 --- a/ReallifeGamemode.Client/drugs/hanf.ts +++ b/ReallifeGamemode.Client/drugs/hanf.ts @@ -333,9 +333,13 @@ 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) => { + if (entity == mp.players.local) { + } + }); + + mp.events.add("SERVER:Hanf_UpdateHanfData", dataJson => { var data: Array = >JSON.parse(dataJson) var newPlants = data.filter(d => currentHanfData.filter(x => x.Id === d.Id).length == 0); diff --git a/ReallifeGamemode.Server/Managers/HanfManager.cs b/ReallifeGamemode.Server/Managers/HanfManager.cs index 2ea69f0e..d70c9adf 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")] From acb2cbc9ba5c3884fda5c1c640ebebec4b7b9976 Mon Sep 17 00:00:00 2001 From: hydrant Date: Thu, 27 May 2021 23:50:21 +0200 Subject: [PATCH 2/4] evtl fix hanf --- ReallifeGamemode.Client/drugs/hanf.ts | 6 +++--- ReallifeGamemode.Server/Managers/HanfManager.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ReallifeGamemode.Client/drugs/hanf.ts b/ReallifeGamemode.Client/drugs/hanf.ts index ac37a8d3..d40f50b7 100644 --- a/ReallifeGamemode.Client/drugs/hanf.ts +++ b/ReallifeGamemode.Client/drugs/hanf.ts @@ -335,11 +335,11 @@ export default function hanfSystem(globalData: IGlobalData) { mp.events.addDataHandler("hanfData", (entity: EntityMp, value) => { if (entity == mp.players.local) { - + updateHanf(value); } }); - mp.events.add("SERVER:Hanf_UpdateHanfData", dataJson => { + function updateHanf(dataJson: string) { var data: Array = >JSON.parse(dataJson) var newPlants = data.filter(d => currentHanfData.filter(x => x.Id === d.Id).length == 0); @@ -382,7 +382,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 d70c9adf..e76f95eb 100644 --- a/ReallifeGamemode.Server/Managers/HanfManager.cs +++ b/ReallifeGamemode.Server/Managers/HanfManager.cs @@ -289,8 +289,8 @@ namespace ReallifeGamemode.Server.Managers { cannabisData ??= _currentCannabisData; await NAPI.Task.WaitForMainThread(); - //player.SetSharedData("hanfData", JsonConvert.SerializeObject(cannabisData)); - player.TriggerEvent("SERVER:Hanf_UpdateHanfData"); + player.SetSharedData("hanfData", JsonConvert.SerializeObject(cannabisData)); + //player.TriggerEvent("SERVER:Hanf_UpdateHanfData"); } [RemoteEvent("CLIENT:Hanf_BuySeeds")] From ac48387b4c1aa6cd21117d8355741eb966e68eba Mon Sep 17 00:00:00 2001 From: hydrant Date: Thu, 27 May 2021 23:52:46 +0200 Subject: [PATCH 3/4] debug --- ReallifeGamemode.Client/drugs/hanf.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/ReallifeGamemode.Client/drugs/hanf.ts b/ReallifeGamemode.Client/drugs/hanf.ts index d40f50b7..cc2b28b1 100644 --- a/ReallifeGamemode.Client/drugs/hanf.ts +++ b/ReallifeGamemode.Client/drugs/hanf.ts @@ -334,6 +334,7 @@ export default function hanfSystem(globalData: IGlobalData) { let hanfDataIdToTextLabelMap: Map = new Map(); mp.events.addDataHandler("hanfData", (entity: EntityMp, value) => { + mp.gui.chat.push("neue hanf data"); if (entity == mp.players.local) { updateHanf(value); } From 099f322fa9631976185683182bcead93e9aec514 Mon Sep 17 00:00:00 2001 From: hydrant Date: Thu, 27 May 2021 23:55:47 +0200 Subject: [PATCH 4/4] debug --- ReallifeGamemode.Client/drugs/hanf.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ReallifeGamemode.Client/drugs/hanf.ts b/ReallifeGamemode.Client/drugs/hanf.ts index cc2b28b1..8498db66 100644 --- a/ReallifeGamemode.Client/drugs/hanf.ts +++ b/ReallifeGamemode.Client/drugs/hanf.ts @@ -335,7 +335,8 @@ export default function hanfSystem(globalData: IGlobalData) { mp.events.addDataHandler("hanfData", (entity: EntityMp, value) => { mp.gui.chat.push("neue hanf data"); - if (entity == mp.players.local) { + if (entity.type == 'player' && entity.remoteId == mp.players.local.remoteId) { + mp.gui.chat.push("eigener user"); updateHanf(value); } });