Is there a hook that checks the item was added to the inventory of the player? It was in the inventory, not in the box and so on - P.S came out a new cheat on the server ddos + Suber Bow
So no hook for catching the addition of things in the inventory ....
And how to get all the trees? ge.ResourceTarget.transform.position?E.G; Get all X/Y/Z of trees and load into dictionary
if using Hatchet
If player.location is 5m or more away from X/Y/Z
Don't give wood
It is the tall trees that do not get it - and they really need mei thing using OverlapSphere...
Probably don't even need to get the tree locations and store in a Dict (Just assumed server didn't know they were there)And how to get all the trees? ge.ResourceTarget.transform.position?
On_Playergathering(Fougerite.Player Player, GatherEvent ge)
{
float distance = Vector3.Distance(ge.ResourceTarget.transform.position, Player.Location);
if (distance > 5.0)
{
Player.MessageFrom("AntiHack", "You are too far away from this object!");
ge.Quantity = 0;
}
}
def On_PlayerGathering(self, Player, GatherEvent):
distance = Vector3.Distance(GatherEvent.ResourceTarget.transform.position, Player.Location)
if distance > 5.0:
Player.MessageFrom("AntiHack", "You are too far away from this object!")
GatherEvent.Quantity = 0
Listen, do not you know how to add 1 line with the activation of the function in Assembly-CSharp? - then I can complete the anti-cheat and put it here for those who can not or do not want to use RustBusterProbably don't even need to get the tree locations and store in a Dict (Just assumed server didn't know they were there)
This would probably work, nice and light weight:
C#:On_Playergathering(Fougerite.Player Player, GatherEvent ge) { float distance = Vector3.Distance(ge.ResourceTarget.transform.position, Player.Location); if (distance > 5.0) { Player.MessageFrom("AntiHack", "You are too far away from this object!"); ge.Quantity = 0; } }Python:def On_PlayerGathering(self, Player, GatherEvent): distance = Vector3.Distance(GatherEvent.ResourceTarget.transform.position, Player.Location) if distance > 5.0: Player.MessageFrom("AntiHack", "You are too far away from this object!") GatherEvent.Quantity = 0
C# or Python?Listen, do not you know how to add 1 line with the activation of the function in Assembly-CSharp? - then I can complete the anti-cheat and put it here for those who can not or do not want to use RustBuster
C # - by the way the code with distance check does not work - I also get 1 piece of tree from large treesC# or Python?
Did you use the hack to get the wood?C # - by the way the code with distance check does not work - I also get 1 piece of tree from large trees
private void Hooks_OnPlayerGathering(Fougerite.Player player, GatherEvent ge)
{
float distance = Vector3.Distance(ge.ResourceTarget.transform.position, player.Location);
if (distance > 5.0)
{
player.MessageFrom("AntiHack", "You are too far away from this object!");
ge.Quantity = 0;
}
}
PlayerGatherWoodEvent Error: System.NullReferenceException: Object reference not set to an instance of an object (Fougerite.Player player, Fougerite.Events.GatherEvent ge) [0x00000] in <filename unknown>:0
at Fougerite.Hooks.PlayerGatherWood (IMeleeWeaponItem rec, .ResourceTarget rt, .ItemDataBlock& db, System.Int32& amount, System.String& name) [0x00000] in <filename unknown>:0
remove the ge.Quantity = 0 line, See if the message pops upI turn on the cheat, pick up a stone - the cheat automatically extracts 1 piece of wood - and the console spams a bugCode:private void Hooks_OnPlayerGathering(Fougerite.Player player, GatherEvent ge) { float distance = Vector3.Distance(ge.ResourceTarget.transform.position, player.Location); if (distance > 5.0) { player.MessageFrom("AntiHack", "You are too far away from this object!"); ge.Quantity = 0; } }
Code:PlayerGatherWoodEvent Error: System.NullReferenceException: Object reference not set to an instance of an object (Fougerite.Player player, Fougerite.Events.GatherEvent ge) [0x00000] in <filename unknown>:0 at Fougerite.Hooks.PlayerGatherWood (IMeleeWeaponItem rec, .ResourceTarget rt, .ItemDataBlock& db, System.Int32& amount, System.String& name) [0x00000] in <filename unknown>:0
The fact is that these trees can not be defined as Gameobject - that's the mistake - that's what treesremove the ge.Quantity = 0 line, See if the message pops up
You could try return true; or return false; instead of ge.Quantity but I don't think On_PlayerGathering can be returned true/false

public void OnPlayerGathering(Fougerite.Player player ,GatherEvent GatherEvent)
{
if (GatherEvent.Item == "Wood")
{
if (GatherEvent.Quantity == 1)
{
if (player.Inventory.HasItem("Wood"))
{
player.Inventory.RemoveItem("Wood",1);
}
}
}
}
I think it's not suitable - I found a way to catch such a cheater, but for this I need to replace the code in IMeleeWeaponItem - but I do not understand how to unpack Assembly-CSharpOr maybe you could stop the farms of the trees using this method:
I have not tried it but it should work ..... I imagine the only condition for the code to work would be only if the trees give x1 of woodC#:public void OnPlayerGathering(Fougerite.Player player ,GatherEvent GatherEvent) { if (GatherEvent.Item == "Wood") { if (GatherEvent.Quantity == 1) { if (player.Inventory.HasItem("Wood")) { player.Inventory.RemoveItem("Wood",1); } } } }
What do you think??? regards!!