Author Topic: [Solved] unmountImage doesn't work  (Read 976 times)

I'm making an item that unmounts itself upon mounting and makes the player use the spray can instead (it's a long story).

unmountImage doesn't seem to be working though.

I didn't parent it because this is the only thing I want onMount to do.


Code: [Select]
function sprayCanImage::onMount(%this,%obj,%slot) {
%obj.unMountImage(%slot);
serverCmdUseSprayCan(findClientByName(%obj.client.name));
Parent::onMount(%this,%obj,%slot)
}
« Last Edit: October 15, 2012, 11:27:29 PM by Electrk »

You have to parent it otherwise mods that modify that function get broken.

You have to parent it otherwise mods that modify that function get broken.

okay
unmountImage still doesn't work
« Last Edit: October 15, 2012, 11:27:39 PM by Electrk »

My problem was fixed!

I modified the item's onPickup so it removes it from the player's inventory upon picking it up

Apparently serverCmdUseSprayCan calls onMount
« Last Edit: October 17, 2012, 04:27:53 PM by Electrk »

Code: [Select]
function sprayCanImage::onMount(%this,%obj,%slot) {
%obj.unMountImage(%slot);
serverCmdUseSprayCan(findClientByName(%obj.client.name));
Parent::onMount(%this,%obj,%slot)
}
I could be wrong here, but I'm pretty sure that's an infinite loop of remounting. serverCmdUseSprayCan would call onMount again from inside onMount, which would thus call onMount from inside that one, which would call onMount from inside that one, etc, etc. Be careful for recursivity.

I could be wrong here, but I'm pretty sure that's an infinite loop of remounting. serverCmdUseSprayCan would call onMount again from inside onMount, which would thus call onMount from inside that one, which would call onMount from inside that one, etc, etc. Be careful for recursivity.

Yes, it calls onMount again. I said that it re-mounts it but that was terrible wording.
Fixed.