#I seem to have problems deleting an

1 messages ยท Page 1 of 1 (latest)

fluid wigeon
#

Can you please provide your script file ๐Ÿ™‚

sick stream
#

Yes, on mobile but give me ~5 min

fluid wigeon
#

Ideally, when deleting a Replicated entity it's better to use DeleteRplEntity method from the RplComponent

sick stream
#

ah I think I know why then, I just used: ```c
RplComponent.DeleteRplEntity(toolkit, false);

last linden
sick stream
#
            RplComponent rplComp = RplComponent.Cast(toolkit.FindComponent(RplComponent));
            rplComp.DeleteRplEntity(toolkit, false);
``` does not seem to work either
#

let me post the whole file maybe

#

works fine in workbench (SP & peer tool), but not in mp once i publish ๐Ÿคทโ€โ™‚๏ธ

sick stream
#

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... ๐Ÿคฆโ€โ™‚๏ธ ๐Ÿคทโ€โ™‚๏ธ

sick stream
#

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.

bold crow
#

and I think I should get the RplComponent from the entity Im deleting first?
DeleteRplEntity is static function, you don't need to call it on an RplComponent instance. 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 for RplComponent returns null but entity itself is replicated, it means that this particular entity cannot be deleted on it's own, because it's part of RplComponent of 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 for RplComponent would be walking up the entity hierarchy, but most code just requires RplComponent to be present on particular entity it works with and doesn't actually do that.

sick stream
#

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." ๐Ÿคทโ€โ™‚๏ธ

iron owl
#

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)

iron owl
#

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)