n00b feelings...
Guys, when you find a namespace with a decompiler on Assembly-CSharp, how do we "read" that namespace in order to know if we could use it with a hook? I hate to disturb you all with my inquiries, so I want to understand that process...
Understanding "namespaces" in Assembly-CSharp and how to use them
Discussion in 'Rust Development' started by TheRotAG, Feb 14, 2015.
-
Have similar question. For example i want to understand what i can do with hook "OnGather", there is "Assembly-CSharp/Item item", how to understand what is inside this variable? Right now by looking inside other plugins i found only "item.amount" and "item.info.displayname", but how to look everything what i have? Same goes to other options like "Assembly-CSharp/ResourceDispenser dispenser, Assembly-CSharp/BaseEntity entity".
Can someone help with this? I know lua/python/php but don't know C# and can't find any documentation about "what is inside this variables". -
There are multiple programs available that you can use, some paid, some for free. Telerik JustDecompile is a good free one.
-
@Mughisi
Thank you very much! Going to learn this) -
@Mughisi how would I manage to search for a specifc item in a player inventory for example?
We have BasePlayer class that calls the class PlayerInventory to check the object Inventory. Using this info, how could we call the PlayerInventory from BasePlayer to print it in the console for instance?
I know that we have our Rust hooks stated here: https://github.com/OxideMod/Oxide/blob/master/Oxide.Ext.Rust/hooks.txt
But the most acceptable hooks there IMO is OnPlayerLoot, but that would make me create a data file to store the player inventory while I want only to detect a single Item in this inventory.
[DOUBLEPOST=1424130097][/DOUBLEPOST]I supose that I have to create a new Hook to work with that then? -
Get a reference to BasePlayer and the rest comes easy..
Code:foreach (var item in basePlayer.inventory.AllItems()) { Puts(item.info.displayname); }
-
Seems like in C# its sooo easy. -
Code:local items = player.inventory:AllItems() for i=0, items.Length - 1, 1 do local item = items[i] print(item.info.displayname) end
-
I know that basePlayer is simply player on LUA, and the inventory continues to be inventory, also AllItems continues the same from C# to LUA with the diference that we use colon ":" in LUA and dot "." in C#. Just dont get how LUA needs to read "player" and not "BasePlayer" as in C# (AFAIK C# can read the Type Names from the dlls and its Members easily without conversion). -
:
Code:function PLUGIN: cmdViewInventory( player, cmd, args ) local inventory = player.inventory end
Code:function PLUGIN:cmdViewInventory( someRandomBasePlayerDude, theCommand, someStupidArgumentsThatWeDontUse ) local inventory = someRandomBasePlayerDude.inventory end
-
How about:
function PLUGIN:OnEntityAttacked( foo, bar ) -- foo would be Entity and bar HitInfo then? What means that the variables set within ( ) are exactly the same from the Hooks. -