I'm using JavaScript to get some info on player death.
OnEntityDeath: function(entity, info) {}
I'm curious as to how I get a list of the available properties for each of entity & info in JavaScript? Specifically I want the attackers name and the victims name. But a full list or a means of getting the properties myself would be great.
Thanks in advance,
Tony.
OnEntityDeath - getting entity & info properties...?
Discussion in 'Rust Development' started by Rebajas, Jun 27, 2016.
-
Wulf Community Admin
Grab JustDecompile or another .NET decompiler, then open Rust's Assembly-CSharp.dll. You'll be able to fine everything you need there.
To convert and check for what type of entity it is, you'd need to cast to the type you want, and check if it is null or not. -
Cool - I'll do this when I'm on a Windows PC later.
Thanks again
-
I downloaded JustDecompile and I think I opened the right file on my local machine - all I find in there is 7 lines of code.
The file I opened was at steamapps/common/Rust/RustClient_Data/Managed - is that right? What should I expect to see? -
Wulf Community Admin
You'd should use the server's Assembly-CSharp.dll ideally, not the client's. -
Okay - I've found a ton of stuff now, didn't see I had to toggle the file structure.
[DOUBLEPOST=1467202833][/DOUBLEPOST]Oh okay
[DOUBLEPOST=1467203312][/DOUBLEPOST]What's the easiest ay to get that file - FTPing to my server and trying to download just complained that I didn't have privileges
-
use the version bundled with the oxide download if you can't dl from your server
-
Ahh, cool. So I've done that and I've got the dll open - what am I looking for because there is tons of stuff in here.
For example, I searched in JustDecompile for OnEntityDeath but I don't see anything that gives me a clue on what properties are available in my plugin under entity and info e.g shortname.
On a separate note, I had been using entity.name.indexOf without any problems but that stopped working recently - is that a common thing in Oxide development or was I just unlucky there? -
Wulf Community Admin
The entity.name.indexOf isn't from Oxide, that's from Rust (entity.name) and the C# (indexOf) language. If you are having troubles using it, we'd need to see logs, code, etc.
To find things in the code, you can browse to the class you'd like or use the search box. -
Hmm, I've gone to OnEntityDeath and it's not really very clear what I am looking for. For instance I don't see what properties are available to me in the JS plugin on entity and info.
I'm not familiar with C# so maybe that is the bigger problem
-
Wulf Community Admin
You'd have to browse to BaseEntity (or whatever argument it uses) to see what is available in that hook. -
I still don't get it - can you give me an example?
I'm looking at the Die() method in BaseCombatEntity, which contains the only reference to OnEntityDeath in the .dll. I can see 18 lines of code and none of them seem to obviously tell me what properties are available to the entity or info object passed into OnEntityDeath.
I've also just noticed that in OnExplosiveThrown entity is returning 5 rather than the prefab name that it had previously been returning
Returns:Code:OnExplosiveThrown: function(player, entity) { var debug = player.displayName + ' > ' + entity; }
entity.name which had been working now returns undefined.Code:Rebajas > 5
-
Wulf Community Admin
The player arg is BasePlayer, which is based on BaseCombatEntity. The entity arg is BaseEntity. -
Okay - I'll have a look in those a bit later.
Thanks for you help btw - much appreciated as always.
