Jump to content
Sign in to follow this  
Icaruk

Placing and removing objects with the same script (actions).

Recommended Posts

When I call this script, I have one box, I can place it, then remove it, via actions.

The problem is when I place one box, I call the script again, then I try to remove the first box, nothing happens, I can just remove the last box I've created.

private ["_box"];


_box = "Land_CargoBox_V1_F" createVehicle [0,0,0];
_box attachTo [player, [0,1,1]];


box = _box;
ACTION_Place = player addAction ["Place", {detach box; player removeAction ACTION_Place; ACTION_Place = nil;},"",999,false,false,"",'!isNull box'];

ACCION_Remove = _box addAction ["Remove", {if ((player distance box) < 3) then {deleteVehicle box;}; },"",999,false,false,"", ''];

Any ideas?

Share this post


Link to post
Share on other sites

because box only represents the last box you made

each time you reference box = _box ; each _box get overridden

in the computers memory you are pointing to the last box you made (so to speak) box

delete vehicle - needs to point to this (the current box)

Edited by Mikie boy

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×