Solved Problem with some strings!

Assassin

Plugin Developer
Plugin Developer
Apr 9, 2017
190
196
43
26
Iran
Hi
Problem 1:
Python:
if GatherEvent.???== "Uber Hatchet":
what i should use instead of ??? ! ? i used WeaponName,weaponname and Weaponname but none of these worked!
Problem 2:
Uber Hunting Bow is not registered as weapon in the plugin! also in DeathMessage Plugin Uber Hunting Bow Shows as Hunting Bow! how i can fix it in python?
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
Hi
Problem 1:
Python:
if GatherEvent.???== "Uber Hatchet":
what i should use instead of ??? ! ? i used WeaponName,weaponname and Weaponname but none of these worked!
Problem 2:
Uber Hunting Bow is not registered as weapon in the plugin! also in DeathMessage Plugin Uber Hunting Bow Shows as Hunting Bow! how i can fix it in python?
You are looking for

C#:
Player.Inventory.InternalInventory.activeItem.name
Please be sure to check the active item (if its null) before use:
Python:
if Player.Inventory.InternalInventory.activeItem is not None:
    name = Player.Inventory.InternalInventory.activeItem.name

The reason why It's hunting bow, because the Rust legacy coders were lazy enough not to give weapon names programatically, therefore I had to distinguish between the weapons manually here: https://github.com/Notulp/Fougerite/blob/master/Fougerite/Fougerite/Events/HurtEvent.cs#L159

I hardly think that the uber and the hunting bow not distinguished is a big mistake, but why do you need this so much?
 
  • Informative
Reactions: Assassin

Assassin

Plugin Developer
Plugin Developer
Apr 9, 2017
190
196
43
26
Iran
You are looking for

C#:
Player.Inventory.InternalInventory.activeItem.name
Please be sure to check the active item (if its null) before use:
Python:
if Player.Inventory.InternalInventory.activeItem is not None:
    name = Player.Inventory.InternalInventory.activeItem.name

The reason why It's hunting bow, because the Rust legacy coders were lazy enough not to give weapon names programatically, therefore I had to distinguish between the weapons manually here: https://github.com/Notulp/Fougerite/blob/master/Fougerite/Fougerite/Events/HurtEvent.cs#L159

I hardly think that the uber and the hunting bow not distinguished is a big mistake, but why do you need this so much?
tnx
because i'm making Abuse Logger Plugin!and i need to check if a admin kill animals with Uber Hunting Bow or not!
 

Assassin

Plugin Developer
Plugin Developer
Apr 9, 2017
190
196
43
26
Iran
Python:
   def On_PlayerGathering(self, Player, GatherEvent):
       if Player.Inventory.InternalInventory.activeItem is not None:
           toolname = Player.Inventory.InternalInventory.activeItem.name
           if toolname == "Uber Hatchet":
               Plugin.Log("AbuseLog", GatherEvent.Player.Name + " Used Uber Hatchet For Gathering!")
               return

this error is for when i changed activeItem.name to activeItem.Name
but both activeItem.name & activeItem.Name will give error!
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
Python:
   def On_PlayerGathering(self, Player, GatherEvent):
       if Player.Inventory.InternalInventory.activeItem is not None:
           toolname = Player.Inventory.InternalInventory.activeItem.name
           if toolname == "Uber Hatchet":
               Plugin.Log("AbuseLog", GatherEvent.Player.Name + " Used Uber Hatchet For Gathering!")
               return

this error is for when i changed activeItem.name to activeItem.Name
but both activeItem.name & activeItem.Name will give error!
C#:
Player.Inventory.InternalInventory._activeItem.datablock.name
 
  • Useful
Reactions: Assassin

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
Python:
   def On_PlayerGathering(self, Player, GatherEvent):
       if Player.Inventory.InternalInventory.activeItem is not None:
           toolname = Player.Inventory.InternalInventory.activeItem.name
           if toolname == "Uber Hatchet":
               Plugin.Log("AbuseLog", GatherEvent.Player.Name + " Used Uber Hatchet For Gathering!")
               return

this error is for when i changed activeItem.name to activeItem.Name
but both activeItem.name & activeItem.Name will give error!
Correct code

Python:
def On_PlayerGathering(self, Player, GatherEvent):
    if Player.Inventory.InternalInventory._activeItem is not None:
        toolname = Player.Inventory.InternalInventory._activeItem.datablock.name
        Player.Message("Debug: " + toolname) # Delete this after determining the name
        if toolname == "Uber Hatchet":
            Plugin.Log("AbuseLog", Player.Name + " Used Uber Hatchet For Gathering!")
 
  • Informative
Reactions: Assassin

Assassin

Plugin Developer
Plugin Developer
Apr 9, 2017
190
196
43
26
Iran
Correct code

Python:
def On_PlayerGathering(self, Player, GatherEvent):
    if Player.Inventory.InternalInventory._activeItem is not None:
        toolname = Player.Inventory.InternalInventory._activeItem.datablock.name
        Player.Message("Debug: " + toolname) # Delete this after determining the name
        if toolname == "Uber Hatchet":
            Plugin.Log("AbuseLog", Player.Name + " Used Uber Hatchet For Gathering!")
it was ok!

thank you for your help <3!
 
  • Like
Reactions: DreTaX