#I seem to have problems deleting an
1 messages ยท Page 1 of 1 (latest)
Yes, on mobile but give me ~5 min
Ideally, when deleting a Replicated entity it's better to use DeleteRplEntity method from the RplComponent
ah I think I know why then, I just used: ```c
RplComponent.DeleteRplEntity(toolkit, false);
https://enfusionengine.com/api/redirect?to=enfusion://ScriptEditor/Scripts/Game/Helpers/SCR_EntityHelper.c;47 use that so you do not need to worry about the game maybe replacing the default replication delete method, but that does just call what you have right now anyway. Never had problems with deleting there
RplComponent rplComp = RplComponent.Cast(toolkit.FindComponent(RplComponent));
rplComp.DeleteRplEntity(toolkit, false);
``` does not seem to work either
let me post the whole file maybe
toolkit is the extinguisher, I was lazy in changing variable names when duplicating scripts. XD
works fine in workbench (SP & peer tool), but not in mp once i publish ๐คทโโ๏ธ
Im thinking there must be a replication issue somewhere. Works 100% fine in workbench, upload and put it on a real server and I get null pointers to the object to be deleted.
Ive also had a couple failed uploads today where its fine in workbench again but as soon as I publish and upload, the server wont start, freezes on compiling scripts. Change nothing and re-publish and it compiles fine... ๐คฆโโ๏ธ ๐คทโโ๏ธ
Could i be hitting the script memory limit having only 8 action script files? Im at a loss here... https://reforger.armaplatform.com/workshop/5DD62B37771477C0 If anyone wants to have a look
The other thing that is very puzzling, my refuel vehicle action does not even show in the mp server and works no problem in workbench.
and I think I should get the RplComponent from the entity Im deleting first?
DeleteRplEntityis static function, you don't need to call it on anRplComponentinstance. It can be used for entities which are not replicated at all as well.
put it on a real server and I get null pointers to the object to be deleted.
Which one? If entity is null, then it obviously won't delete anything. If your search forRplComponentreturns null but entity itself is replicated, it means that this particular entity cannot be deleted on it's own, because it's part ofRplComponentof one of the ancestor entities and you have to pass that ancestor (and you will obviously delete this ancestor and all its children). Truly robust search forRplComponentwould be walking up the entity hierarchy, but most code just requiresRplComponentto be present on particular entity it works with and doesn't actually do that.
which one? IEntity toolkit; I'm not passing it correctly to the PerformAction part apparently.
I added a print and toolkit is indeed returning null
so I was trying to pass toolkit from CanBeShownScript to PerformAction, but ended up with issues, so I just found the item in the players inventory again when the action is performed and that works fine! Dont know why I didnt think to do that before, but I didnt think it would be so complicated to send a variable to another function in an action. Oh well, at least I figured out a way to get it done even if not the best way or "correct." ๐คทโโ๏ธ
you cant use IEntity toolkit because its not initialized on server
you need get the toolkit entity for performaction too and make sure performaction runs only on server
i suggest use if (m_rplComponent && m_rplComponent.IsProxy()) return; on performaction and get the toolkit there (server side)
i use this:
https://github.com/HTomJMW/htCTI-Arma-Reforger/blob/main/Scripts/Game/Actions/SCR_CTI_RemoveDefenseAction.c
im not sure maybe inventory items need delete on client, inventory things bit different
InventoryStorageManager :: TryDeleteItem() but in that case enough on localeffect (if its in your inventory)