Jump to content
Sign in to follow this  
Rawhide

Moving markers disappear upon respawn

Recommended Posts

Hi all,

I'm using Sickboys moving marker script. It works great, but upon dead and the follow respawn via Norrins revive, it stops working. Looking at the code, that ain't hard to understand.

I'm new to .sqf scripting, and must ask for some guidance on this issue.

This script is launched via units init:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">x = [unitname] execVM "Markers\markersBlack.sqf"

The script markersBlack.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// Set local variables

private ["_obj","_marker"];

// Get Object

_obj = _this select 0;

//_marker = format["%1",group _obj];

//Changed it to work on each unit instead of group;

_marker = format["%1",_obj];

// Create marker and set marker shape, type, size and text

createMarkerLocal [_marker, position _obj];

_marker setMarkerShapeLocal "ICON";

_marker setMarkerTypeLocal "Dot";

_marker setMarkerSizeLocal [.3,.3];

_marker setMarkerColorLocal "ColorBlack";

//No text on marker wanted;

//_marker setMarkerTextLocal _marker;

while {alive _obj} do

{

  sleep 1;

  _marker setmarkerposLocal position _obj;

};

deletemarkerLocal _marker;

//Testcodes to try to restart script, but they dosen't work;

//exitWith {x = [player] execVM "Markers\markersBlack.sqf"};

//exitWith {x = ["ww6"] execVM "Markers\markersBlack.sqf"};

//exitWith {x = [_obj] execVM "Markers\markersBlack.sqf"};

Any help would be appreciated.

-Rawhide

Share this post


Link to post
Share on other sites

rough guess you could try the below in place of the while loop you have but I haven't looked at the revive script.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">while {true} do

{

 sleep 1;

 if(alive _obj)then

 {

_marker setMarkerSizeLocal [.3,.3];

_marker setMarkerColorLocal "ColorBlack";

    _marker setmarkerposLocal position _obj;

 }else{

//add here what happens to marker when unit is dead

    _marker setMarkerSizeLocal [.01,.01];

   _marker setMarkerColorLocal "ColorRed";

 };

};

Share this post


Link to post
Share on other sites

You need to set the script again when 'alive _obj'

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

// Set local variables

private ["_obj","_marker"];

// Get Object

_obj = _this select 0;

//_marker = format["%1",group _obj];

//Changed it to work on each unit instead of group;

_marker = format["%1",_obj];

// Create marker and set marker shape, type, size and text

createMarkerLocal [_marker, position _obj];

_marker setMarkerShapeLocal "ICON";

_marker setMarkerTypeLocal "Dot";

_marker setMarkerSizeLocal [.3,.3];

_marker setMarkerColorLocal "ColorBlack";

//No text on marker wanted;

//_marker setMarkerTextLocal _marker;

while {alive _obj} do

{

sleep 1;

_marker setmarkerposLocal position _obj;

};

deletemarkerLocal _marker;

waitUntil {alive _obj};

x = [unitname] execVM "Markers\markersBlack.sqf";

Share this post


Link to post
Share on other sites

Thank you for the replies guys.

It don't work though (tested on dedi). After the unit has died, the marker is gone (as it should), but don't re-appear as the soldier does.

A buddy told me that when he is dead, the _obj is also deleted instantly.

That means that the waitUntil {alive _obj} won't kick in, because _obj is nothing after the unit has died.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">waitUntil {alive _obj};

x = [unitname] execVM "Markers\markersBlack.sqf";

I wonder if it possible to rather have:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">waitUntil {alive unitname};

x = [unitname] execVM "Markers\markersBlack.sqf";

Would that work? I'm posting without testing because I don't how to write the waitUntil unitname-code...

And one more thing. With this code, I will run the markerscript again. But shouldent we stop the existing markerscript with a exitWith-command?

-Rawhide

Share this post


Link to post
Share on other sites

You wrote the waitUntil code part correctly. As to whether or not it will work, I have no idea. tounge2.gif Good luck though.

Share this post


Link to post
Share on other sites

Well the best way would be to add a Eventhandler Killed to the unit, which triggers, after the unit was killed.

You also could Try to create the markers Global, beause after the Revive your unit is created by the Server..?? I think and so it's not local any longer.

Didn't looked deep enough in Norrins script but you could try this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

// Set local variables

private ["_obj","_marker"];

// Get Object

_obj = _this select 0;

//_marker = format["%1",group _obj];

//Changed it to work on each unit instead of group;

_marker = format["%1",_obj];

// Create marker and set marker shape, type, size and text

createMarker [_marker, position _obj];

_marker setMarkerShape "ICON";

_marker setMarkerType "Dot";

_marker setMarkerSize [.3,.3];

_marker setMarkerColor "ColorBlack";

//No text on marker wanted;

//_marker setMarkerTextLocal _marker;

while {alive _obj} do

{

sleep 1;

_marker setmarkerpos position _obj;

};

deletemarker _marker;

waitUntil {alive _obj};

x = [unitname] execVM "Markers\markersBlack.sqf";

Share this post


Link to post
Share on other sites

Solved.

One solution is to run one script per person. Though, you need ten almost similar scripts if you have ten players.

I know there is better ways to solve this, but this is the only one I managed to get to work.

The script is initialized in units init (unitname = leader1):

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">x = [leader1] execVM "Markers\leader1markersGreen.sqf"

Create a folder named Marker, and name this sqf "leader1markersGreen.sqf"

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">/////////////////////////////////////////////////////////////

// ArmA - Marker Script - By Sickboy

/////////////////////////////////////////////////////////////

// Set local variables

private ["_obj","_marker"];

// Get Object

_obj = _this select 0;

/////////////////////////////////////////////////////////////

//_marker = format["%1",group _obj];

_marker = format["%1",_obj];

// Create marker and set marker shape, type, size and text

createMarkerLocal [_marker, position _obj];

_marker setMarkerShapeLocal "ICON";

_marker setMarkerTypeLocal "Dot";

_marker setMarkerSizeLocal [.3,.3];

_marker setMarkerColorLocal "ColorGreen";

//_marker setMarkerTextLocal _marker;

// If object alive loop position

while {alive _obj} do

{

  sleep 1;

  _marker setmarkerposLocal position _obj;

};

deletemarkerLocal _marker;

waitUntil {alive leader1};

_x = [leader1] execVM "Markers\leader1markersGreen.sqf";

Thanks for your help guys  smile_o.gif

-Rawhide

Share this post


Link to post
Share on other sites

It doesn't need 10 different scripts. Just make sure one script is executed on each client (putting it in the init line of a unit or calling it from the init.sqf should do) and then don't refer to the object but to the player:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

private ["_obj","_marker"];

_obj = _this select 0;

if (_obj == local player) then {

_marker = format["%1",player];

createMarker [_marker, position player];

_marker setMarkerShape "ICON";

_marker setMarkerSize [.3,.3];

_marker setMarkerColor "ColorGreen";

while {true} do {

if (alive player) then {

_marker setMarkerPos position player;

_marker setMarkerType "Dot";

} else {

_marker setMarkerType "Empty"; //Markertype "Empty" makes the marker invisible

//_marker setMarkerColor "ColorRed"; // Uncomment this line and comment the above to mark last known players position

};

sleep 1;

};

};

Share this post


Link to post
Share on other sites

Sorry to say I didn't get your solution to work Myke.

Could be something I did wrong, I'm thinking about how I start the mission via the soldiers init. I guess something can be done with that.

For now I've moved on using one script on each unit because. I have one color for each team (four teams), so it isn't that much of a difference after all. But I might pick this one up later.

Anyway thanks for your time & help so far Myke!

-Rawhide

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  

×