OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started by: cutter on 03 Oct 2009, 14:00:54

Title: Need help to located a player every 5 min.
Post by: cutter on 03 Oct 2009, 14:00:54
Thing is, i have a mission, blufor need to escort a rockstar to airport, opfor needs to eliminate him, the whole Chernarus is in use, so what i need is a small script to located the position of the rockstart everu 5 min or so, and report that to opfor, otherwise it will be to difficult for opfor to find him.

To be noted, i am noob with scripting  :confused:
Title: Re: Need help to located a player every 5 min.
Post by: tcp on 03 Oct 2009, 19:18:51
<rockstarname> is whatever you put in name field of unit.

Add this to the end of init.sqf:
Code: [Select]
sleep 1;
if(side player == east) then {rockstarname execVM "tracker.sqf"};

Code: (tracker.sqf) [Select]
if(isServer && isDedicated) exitWith {};
private ["_unit","_marker"];
_unit = _this;

_marker = createMarkerLocal [format ["%1marker", _unit], getPos _unit];
_marker setMarkerTypeLocal "mil_unknown";
_marker setMarkerColorLocal "ColorBlack";
_marker setMarkerTextLocal "Last Known Pos";
while {alive _unit} do {
_marker setMarkerPosLocal (getPos _unit);
sleep 300; //5 minutes
};

In your tasks code, you can use:
<marker name='rockstarnamemarker'>rockstarname</marker>
Title: Re: Need help to located a player every 5 min.
Post by: cutter on 03 Oct 2009, 22:16:14
I greatly appriciate this, thanks alot mate.  :good:

UPDATE.

I tryed it and it almost work  :) , but its not updating, it puts the marker right at the start and thats fine, but thats it, it isnt updating or anything, and i did exactly as writte above.
Title: Re: Need help to located a player every 5 min.
Post by: tcp on 04 Oct 2009, 01:02:03
OK, I made two mistakes:
This needs two equal signs:
if(side player == east) then {rockstarname execVM "tracker.sqf"};
Needs isDedicated to support player hosting:
if(isServer && isDedicated) exitWith {};

It works for me now, changes are made above as well.

Also, interval is set to 5 minutes. Change sleep <seconds>; in tracker.sqf to make it shorter.
Title: Re: Need help to located a player every 5 min.
Post by: cutter on 04 Oct 2009, 01:39:49
I love you man  :)