mosesuk 1 Posted October 6, 2013 (edited) I've been having trouble getting my script to function in the desired manner, and after much trial, and mostly error or improper functionality, I've driven myself mad. I want to create a 'trail' behind all non-dog units, the dog's should also be the only unit that can actually see these trails. The idea is to allow Dog's to effectively 'track' players, the script will be used in multiplayer. _trail_interval_original = trail_interval; while {TRUE} do { if (isNil "trail_points") then {trail_points=[];}; if (isNil "trail_maxPoints") then {trail_maxPoints = 200;}; _player = (vehicle player); _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; _inWater = ((surfaceIsWater (position player)) || (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "swimming")) == 1); _isMoving = (speed _player > 0.1 || speed _player < -4); _inVehicle = (_player != player); _isDog = (_player isKindOf "Pastor" || _player isKindOf "Fin"); _isSlow = (speed _player >= 1.5 && speed _player <= 8); _trailPoint = objNull; if(_isMoving && !_inWater && !_onLadder && !_inVehicle) then { trail_zAxis = ((getPosATL _player) select 2); if ((damage player) > 0.5) then {trail_object = "Sign_sphere25cm_EP1";}else{trail_object = "Sign_sphere10cm_EP1";}; if (trail_zAxis < 0) then {trail_zAxis = 0;}; if (_isSlow) then {if (trail_interval == _trail_interval_original) then {trail_interval = trail_interval * trail_slow_multiplier;};} else {trail_interval = _trail_interval_original;}; { _xDog = (_x isKindOf "Pastor" || _x isKindOf "Fin"); if (_xDog) then { _pos = (position _player); _trailPoint = trail_object createVehicleLocal [(_pos select 0), (_pos select 1), -2]; _trailPoint setPos [(_pos select 0), (_pos select 1), trail_zAxis]; if (debug > 0) then {_msg = ["TRAIL :: CREATE :: INTERVAL: %1",trail_interval]; if (debug == 2) then {_msg = ["TRAIL :: CREATE :: INTERVAL: %1 :: COUNT %4 :: currUnitSide: %2 playerSide: %3",trail_interval, _xSide, _unitSide,(count trail_points)];};(vehicle player) globalChat format _msg;}; }; } forEach (playableUnits); _trailPoint hideObject true; trail_points = (trail_points + [_trailPoint]) - [objNull]; if (count trail_points > trail_maxPoints) then { if (debug > 0) then {_msg = ["TRAIL :: REMOVE"]; if (debug == 2) then {_msg = ["TRAIL :: REMOVE :: %1",(trail_points select 0)];};(vehicle player) globalChat format _msg;}; deleteVehicle (trail_points select 0); trail_points = trail_points - [(trail_points select 0)]; }; }; sleep trail_interval; }; I can't seem to get things straight in my head anymore, so if anyone could help me get this working properly, it would be GREATLY appreciated. ---------- Post added at 23:32 ---------- Previous post was at 23:31 ---------- The script so far can be found on GitHub here. Edited October 6, 2013 by MosesUK Share this post Link to post Share on other sites
cobra4v320 27 Posted October 7, 2013 (edited) Looks like your if () then {} else {} command is messed up, go through it again line by line. Look at your if (_isSlow) then { line. _trail_interval_original = trail_interval; while {TRUE} do { if (isNil "trail_points") then {trail_points=[]}; if (isNil "trail_maxPoints") then {trail_maxPoints = 200}; _player = (vehicle player); _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; _inWater = ((surfaceIsWater (position player)) || (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "swimming")) == 1); _isMoving = (speed _player > 0.1 || speed _player < -4); _inVehicle = (_player != player); _isDog = (_player isKindOf "Pastor" || _player isKindOf "Fin"); _isSlow = (speed _player >= 1.5 && speed _player <= 8); _trailPoint = objNull; if (_isMoving && !_inWater && !_onLadder && !_inVehicle) then { trail_zAxis = ((getPosATL _player) select 2); if ((damage player) > 0.5) then {trail_object = "Sign_sphere25cm_EP1"} else {trail_object = "Sign_sphere10cm_EP1"}; if (trail_zAxis < 0) then {trail_zAxis = 0}; if (_isSlow) then { if (trail_interval == _trail_interval_original) then { trail_interval = trail_interval * trail_slow_multiplier; } else { trail_interval = _trail_interval_original; }; { _xDog = (_x isKindOf "Pastor" || _x isKindOf "Fin"); if (_xDog) then { _pos = (position _player); _trailPoint = trail_object createVehicleLocal [(_pos select 0), (_pos select 1), -2]; _trailPoint setPos [(_pos select 0), (_pos select 1), trail_zAxis]; if (debug > 0) then { _msg = ["TRAIL :: CREATE :: INTERVAL: %1",trail_interval]; if (debug == 2) then { _msg = ["TRAIL :: CREATE :: INTERVAL: %1 :: COUNT %4 :: currUnitSide: %2 playerSide: %3",trail_interval, _xSide, _unitSide,(count trail_points)]; }; (vehicle player) globalChat format _msg; }; }; } forEach (playableUnits); _trailPoint hideObject true; trail_points = (trail_points + [_trailPoint]) - [objNull]; if (count trail_points > trail_maxPoints) then { if (debug > 0) then {_msg = ["TRAIL :: REMOVE"]; if (debug == 2) then { _msg = ["TRAIL :: REMOVE :: %1",(trail_points select 0)]; }; (vehicle player) globalChat format _msg; }; deleteVehicle (trail_points select 0); trail_points = trail_points - [(trail_points select 0)]; }; }; sleep trail_interval; }; Edited October 7, 2013 by cobra4v320 Share this post Link to post Share on other sites
mosesuk 1 Posted October 7, 2013 Really? On which line did you spot an issue? I didn't think I had any sintax issues. Share this post Link to post Share on other sites
cobra4v320 27 Posted October 7, 2013 I posted above but it should be your if (_isSlow) line ---------- Post added at 00:42 ---------- Previous post was at 00:39 ---------- actually now that I look at it again I might have messed it up myself and left out a bracket. ---------- Post added at 00:45 ---------- Previous post was at 00:42 ---------- Where are you running this script from, the init.sqf? What is _trail_interval_original ---------- Post added at 00:49 ---------- Previous post was at 00:45 ---------- trail_interval = trail_interval * trail_slow_multiplier; trail_slow_multiplier isnt defined anywhere besides on this line. Share this post Link to post Share on other sites
mosesuk 1 Posted October 7, 2013 Any undefined variables are defined in the config.sqf which can be found on github. The script produces no script errors. Share this post Link to post Share on other sites
mosesuk 1 Posted October 7, 2013 Anyone got a solution for me? I've thinned out the code a little, to make it a little more readable. trail_interval = 2; while {TRUE} do { if (isNil "trail_points") then {trail_points=[];}; if (isNil "trail_maxPoints") then {trail_maxPoints = 200;}; _player = (vehicle player); _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; _inWater = ((surfaceIsWater (position player)) || (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "swimming")) == 1); _isMoving = (speed _player > 0.1 || speed _player < -4); _inVehicle = (_player != player); _isDog = (_player isKindOf "Pastor" || _player isKindOf "Fin"); _trailPoint = objNull; if(_isMoving && !_inWater && !_onLadder && !_inVehicle) then { trail_zAxis = ((getPosATL _player) select 2); if (trail_zAxis < 0) then {trail_zAxis = 0;}; trail_object = "Sign_sphere10cm_EP1"; { _xDog = (_x isKindOf "Pastor" || _x isKindOf "Fin"); if (_xDog) then { _pos = (position _player); _trailPoint = trail_object createVehicleLocal [(_pos select 0), (_pos select 1), -2]; _trailPoint setPos [(_pos select 0), (_pos select 1), trail_zAxis]; }; } forEach (playableUnits); _trailPoint hideObject true; trail_points = (trail_points + [_trailPoint]) - [objNull]; if (count trail_points > trail_maxPoints) then { deleteVehicle (trail_points select 0); trail_points = trail_points - [(trail_points select 0)]; }; }; sleep trail_interval; }; Share this post Link to post Share on other sites