Jump to content
Sign in to follow this  
NGagedFX

MarkerGPS stops after respawn

Recommended Posts

I have this marker called gps, and then I have a unit (with no name) controlled by the player. In the player's init: nul = [this] execVM "GPS.sqf"

GPS.sqf:

_this = _this select 0;

while {true} do
{
"gps" setMarkerPos getPos _this;
sleep 1;
};

This works fine, until I die and respawn. I know this works when you give the unit a name, and use a name in the script. But since I want to keep it nameless and learn something about the way these scripts and ArmA work, I want to try it this way.

I was bussy with a somewhat larger script, but this first bit gets me stuck already, so I'm trying to solve this first. :)

Share this post


Link to post
Share on other sites

When you respawn you become a new entity on the map. The dead you still exist on the map, so the script continues to set the position based on your dead version. Or put another way, _this is never updated to a new entity after your death, it still points to the dead entity.

Although better methods exists, a quick fix would be to replace while {true} ... with while {alive _this} ..., and then restart the script in your respawn code. When you die, the old script stops running, but you have to restart it. One way to do this is to waitUntil {alive player}, followed by a restart of the same script but with [player] as parameter. So basically, the script keeps updating the marker until you die, then waits for you to respawn, and then it restarts itself with the "new you" sent into it.

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  

×