hmm|?

Komrad

Member
Member
May 14, 2017
89
4
6
30
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
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
Might be possible to catch the tree hack with a plugin, But I'm sure RustBuster will catch it
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
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
 
  • Agree
Reactions: salva

Komrad

Member
Member
May 14, 2017
89
4
6
30
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
And how to get all the trees? ge.ResourceTarget.transform.position?
 

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
612
63
i thing using OverlapSphere...
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
And how to get all the trees? ge.ResourceTarget.transform.position?
Probably 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
 
  • Agree
Reactions: salva

Komrad

Member
Member
May 14, 2017
89
4
6
30
Probably 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
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
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
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# or Python?
 

Komrad

Member
Member
May 14, 2017
89
4
6
30
Code:
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;
            }
        }
I turn on the cheat, pick up a stone - the cheat automatically extracts 1 piece of wood - and the console spams a bug

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
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
Code:
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;
            }
        }
I turn on the cheat, pick up a stone - the cheat automatically extracts 1 piece of wood - and the console spams a bug

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
remove 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
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
if none of those 3 work,
Try this
C#:
Player.Inventory.RemoveItem(ge.ResourceTarget.ResourceItemDataBlock.Ident.name, ge.Quantity);
instead of ge.Quantity = 0;
 

Komrad

Member
Member
May 14, 2017
89
4
6
30
remove 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
The fact is that these trees can not be defined as Gameobject - that's the mistake - that's what treesrust_legacy___facepunch_studios___dusk__4_by_gt4tube-d73sj1y.jpg
And where did you get ResourceItemDataBlock.Ident.name?
 
Last edited:

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
612
63
Or maybe you could stop the farms of the trees using this method:

C#:
        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 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 wood

What do you think??? regards!!
 

Komrad

Member
Member
May 14, 2017
89
4
6
30
Or maybe you could stop the farms of the trees using this method:

C#:
        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 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 wood

What do you think??? regards!!
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-CSharp