Hello, how to use second paramether from OnItemDeployed hook in lua? It return System.Object[] and i have no idea what to do with it... I want use this hook to remove deployed item if spawn it in -nobuild zone (r-zones plugin).
Solved OnItemDeployed System.Object[] lua
Discussion in 'Rust Development' started by AlexALX_[rus-ua], Mar 11, 2015.
-
As mentioned in the documentation:
Code:OnItemDeployed(Assembly-CSharp/Deployer deployer, Assembly-CSharp/BaseEntity deployedentity)Assembly-CSharp/Deployer No return behavior Called right after an item has been deployed
A pull request was made to the repository to fix the hook so it should get fixed soon -
As this is bug, ok, then i'll wait.
Thank you.
[DOUBLEPOST=1426098806,1426088552][/DOUBLEPOST]Are you sure that it is fixed? Because it seems like your pull request was approved but with latest oxide i'm still getting System.Object[]... Server already restarted two times and nothing changes. -
Wulf Community Admin
-
Yes of course.
1. I have automatic script what downloads from https://raw.githubusercontent.com/OxideMod/Snapshots/master/Rust/OxideRust.zip and unpacking to server directory.
2. Also i have fully working mono what compiles oxide sources from git (with automatic update git) and placing compiled files to server.
So i never download from regular download page, in most cases compile myself before it compiled by travis.
In both variants issue still here. Also i right now tried manually download latest snapshot and unpack - still same result...
[DOUBLEPOST=1426100305][/DOUBLEPOST]Also just checked - in souces from what i'm compiling i have already ""ArgumentString": "this, l3"," in Rust.opj, so something still wrong. -
)
I've attached my patched Assembly-CSharp.dll to this post for you to use for the time being.Attached Files:
-
-
Wulf Community Admin
-
[DOUBLEPOST=1426105407][/DOUBLEPOST]Sadly, it seems like i cannot get owner of deployer if spawn only one entity (in slot). For example if i get 100 camp fire in one slot and place it, in function OnItemDeployed it returning .ownerPlayer without problems, but if only one camp fire was in slot - this not work. It seems like rust problem so my idea can't be done right now
Anyway - thank you for help.
[DOUBLEPOST=1426261594,1426103945][/DOUBLEPOST]Is there way to call hook OnItemDeployed before "base.UseItemAmount(1);"? Because after this it looses entity owner because of this:
Code:protected void UseItemAmount(int iAmount) { Item ownerItem = this.GetOwnerItem(); if (ownerItem == null) { this.DestroyThis(); return; } Item item = ownerItem; item.amount = item.amount - iAmount; ownerItem.MarkDirty(); if (ownerItem.amount <= 0) { this.DestroyThis(); } } }
Probably i can try combine OnEntitySpawn + OnItemDeployed hooks as workaround to get my idea to work, going to do some tests... -
-
Yes, you ar right, i can't get owner inside OnEntitySpawn or OnItemDeployed hooks... So for now this is impossible at all get owner of deployed items if in slot is only one item.
-
-
Last edited by a moderator: Mar 13, 2015
-
-
-
-
-
I really glad that developers of oxide (or persons like your) fixes issues) Again thank you for help.
[DOUBLEPOST=1426333562,1426288377][/DOUBLEPOST]Can you also move OnItemDeployed inside DoDeploy_Slot to be before "base.UseItemAmount(1);" please? I'm not sure when it used but still. Just for case...
As for DoDeploy_Regular - now it works perfect! Thank you.Last edited by a moderator: Mar 14, 2015 -