Home   Help Search Login Register  

Author Topic: help with mp tracker script  (Read 1343 times)

0 Members and 1 Guest are viewing this topic.

Offline sharkattack

  • Former Staff
  • ****
help with mp tracker script
« on: 04 Apr 2008, 19:04:22 »
hi
me again

having problems using a tracker script  in mp ..
it works fine however there is a problem ..
if another player  gets close to the player unit with the tracker the other player  also gets an option to activate it

LCD/lojack  tracker.sqf

Code: [Select]
private ["_exit","_tracker","_dir","_degree","_difference","_adjusteddiff","_beepfreq","_dis","_sound"];

_exit = false;
_dead = false;

if ("init" in _this) then
{
LCD_trackswitch = false;
LCD_lojack_tar = _this select 0;
LCD_lojack_act = (_this select 1) addaction ["Turn tracker on","LCD_lojack.sqf"];
_exit = true;
};

if (_exit) exitwith {};

if (count _this == 4) then
{
if (LCD_trackswitch) exitwith
{
LCD_trackswitch = false;
(_this select 0) removeaction LCD_lojack_act;
LCD_lojack_act = (_this select 0) addaction ["Turn tracker on","LCD_lojack.sqf"];
};

if (! LCD_trackswitch) then
{

LCD_trackswitch = true;
_tracker = _this select 0;
_tracker removeaction LCD_lojack_act;
LCD_lojack_act = (_this select 0) addaction ["Turn tracker off","LCD_lojack.sqf"];
while {LCD_trackswitch} do
{

_dir = getdir (vehicle _tracker);
_degree = ((getpos LCD_lojack_tar select 0) - (getpos _tracker select 0)) atan2 ((getpos LCD_lojack_tar select 1) - (getpos _tracker select 1));
if (_degree < 0) then {_degree = _degree + 360};

_difference = _degree - _dir;
if (_difference > 180) then {_difference = _difference - 360};
if (_difference < -180) then {_difference = _difference + 360};
_adjusteddiff = (abs _difference);

_beepfreq = ((_adjusteddiff / 50) + 0.1);

_dis = _tracker distance LCD_lojack_tar;

_sound = "beep";
if (_dis < 4000) then {_sound = "beep2"};
if (_dis < 3000) then {_sound = "beep3"};
if (_dis < 2000) then {_sound = "beep4"};
if (_dis < 1250) then {_sound = "beep5"};
if (_dis < 750) then {_sound = "beep6"};
if (_dis < 500) then {_sound = "beep7"};
if (_dis < 250) then {_sound = "beep8"};

playsound _sound;

sleep _beepfreq;
//modified by norrin
if (!alive player) exitWith {LCD_trackswitch = false; _dead = true};
};
};
};

if ("off" in _this) then
{
(_this select 0) removeaction LCD_lojack_act;
LCD_trackswitch = false;
};
//modified by norrin
if (_dead) then
{
(_this select 0) removeaction LCD_lojack_act;
waitUntil {alive player};
[] exec"online.sqs";
};

if (true) exitwith{};

executed by

bla = [tracked,tracker,"init"] execVM "LCD_lojack.sqf"

many thanks ...

"HOLY SARDINE" - see Shark-Attack meet his match

Offline Loyalguard

  • Former Staff
  • ****
Re: help with mp tracker script
« Reply #1 on: 04 Apr 2008, 23:42:44 »
I believe to limit the action to only the intended unit you need to add a condition check like this before the addAction command, so, if _this select 1 is the only unit who is supposed to get the tracer action then perhaps something like this (not a complete example and untested):

Code: [Select]
if (player == _this select 1) then
{
LCD_lojack_act = (_this select 1) addaction ["Turn tracker on","LCD_lojack.sqf"];
};

Other combinations of player, _this select 1, and possible the local command may be necessary.