Jump to content
Sign in to follow this  
{USI}_Zombie

tweaking an old script

Recommended Posts

Maybe a timing prob.

The following version is with larger breaks:

private ["_vlc","_startgl","_landlogic","_action"];

_startgl = objNull;_landlogic = objNull;mDistance = -1;_action = true;_vcl = objNull;mDriver = "";

if(typeName _this == "ARRAY") then {_vcl = _this select 0} else {_vcl = _this};

if(isServer) then
{
_startgl = "logic" createvehiclelocal [0,0];
_landlogic = "logic" createvehiclelocal [0,0];
while{_action} do
{
	sleep 0.01;
	if((position _vcl select 2) > 1) then
	{
		if(local player) then {player sidechat "measuring jump distance"};
		_startgl setpos position _vcl;
		waituntil{((position _vcl select 2) < 1)};
		_landlogic setpos position _vcl;
		mDriver = str(name driver _vcl);publicvariable "mDriver";
		mDistance = round(_startgl distance _landlogic);
		publicvariable "mDistance";publicvariable "mDriver";
		if(local player) then
		{
			player sidechat format	[
										"%2  jumped %1 meters!!!",
										mDistance,
										mDriver
									];
		};
		sleep 2;
	}
	else
	{
		if((getdammage _vcl) == 1) then
		{
			_action = false;
			if(local player) then {player sidechat "vehicle destroyed"};
			deletevehicle _startgl;deletevehicle _landlogic;
		};
	};
};
}
else
{
while{_action} do
{
	waituntil{(mDistance > 0) || ((getdammage _vcl) == 1)};
	if(mDistance > 0) then
	{
		sleep 1;
		player sidechat "measuring jump distance";
		player sidechat format	[
									"%2  jumped %1 meters!!!",
									mDistance,
									mDriver
								];
		mDistance = -1;mDriver = "";
		sleep 0.5;
	}
	else
	{
		player sidechat "vehicle destroyed";_action = false;
	};
};
};

:j: try it

Share this post


Link to post
Share on other sites

no more spam hints for either of us.

zombie reports hints working properly for him everytime

distances synched

however...

I see the number hint with a distance value followed by a name hint with a -1 value.

Zombie thinks the distance is not correctly measured, he jumps farther than hint suggests. I think the same.

reminder, he is host and I am joining.

jump4.jpg

Share this post


Link to post
Share on other sites

ok, last try for today :p

private ["_vlc","_pos1","_pos2","_action1","_action2"];

_pos1 = [];_pos2 = [];mDistance = -1;_action1 = true;_action2 = true;_vcl = objNull;mDriver = "";

if(typeName _this == "ARRAY") then {_vcl = _this select 0} else {_vcl = _this};

waituntil{time > 2};

if(isServer) then
{
while{_action1} do
{
	waituntil{((_vcl emptyPositions "driver") == 0)};
	sleep 0.1;
	if(!(58 in toArray(name driver _vcl))) then
	{
		mDriver = str(name driver _vcl);publicvariable "mDriver";
		while{_action2} do
		{
			sleep 0.01;
			if((position _vcl select 2) > 1) then
			{
				if(local player) then {player sidechat "measuring jump distance"};
				_pos1 = format["%1",position _vcl];
				sleep 0.2;
				waituntil{((position _vcl select 2) < 1)};
				_pos2 = format["%1",position _vcl];
				mDistance = call compile format["round(%1 distance %2)",_pos1,_pos2];
				if(mDistance > 1) then
				{
					publicvariable "mDistance";
					if(local player) then
					{
						player sidechat format	[
													"%2  jumped %1 meters!!!",
													mDistance,
													mDriver
												];
					};
				};
				sleep 2;
			}
			else
			{
				if((getdammage _vcl) == 1) then
				{
					_action2 = false;_action1 = false;
					if(local player) then {player sidechat "vehicle destroyed"};
				}
				else
				{
					if((_vcl emptyPositions "driver") == 1) then {_action2 = false};
				};
			};
		};
	};
};
}
else
{
while{_action1} do
{
	waituntil{(mDistance > 0) || ((getdammage _vcl) == 1)};
	if(mDistance > 0) then
	{
		sleep 1;
		player sidechat "measuring jump distance";
		player sidechat format	[
									"%2  jumped %1 meters!!!",
									mDistance,
									mDriver
								];
		mDistance = -1;mDriver = "";
		sleep 0.5;
	}
	else
	{
		player sidechat "vehicle destroyed";_action1 = false;
	};
};
};

sorry for my bad mp skill :(

Share this post


Link to post
Share on other sites

no need to say sorry...you have been a big help. This script has been kicking my butt for 3 days. The 1st version I posted, the sqs, anyway. Will try your latest and let you know...If I knew about sqf's this may be easier because MP is all I do...

Share this post


Link to post
Share on other sites

Hi :)

I think we must start a script for each player, and not for each vehicle.

That's the main problem.

I will write a new script and will see how it works ;)

Two little questions:

- The name of the script is still "jumpdistance.sqf" ?

- The script is stored in the main folder of your mission ?

cu later

Silola

Share this post


Link to post
Share on other sites
Hi :)

I think we must start a script for each player, and not for each vehicle.

That's the main problem.

Didn't think of that, it wasn't necessary in OFP:R , I guess localities have changed since then

I will write a new script and will see how it works ;)

Two little questions:

- The name of the script is still "jumpdistance.sqf" ?

- The script is stored in the main folder of your mission ?

cu later

Silola

yes, but then name can be changed to whatever

yes again, I rarely use subfolders

appreciate you help :)

Share this post


Link to post
Share on other sites

Hello :)

since OFP:R the behavior in MP has changed alot. Some things have changed only in detail but have a large impact in the area of MP.

But anyway, maybe u can try the new version to see what happens?

Hint: The best way to start the script, put this in your init.sqf:

[0] execVM "jumpdistance.sqf"

Don't forget to delete the old script calls from vehicle init.

New script:

private ["_vcl","_val","_pos1","_pos2","_action1","_action2","_dist"];

_val = _this select 0;_pos1 = [];_pos2 = [];_dist = 0;_action1 = true;_action2 = true;mString = "";_vcl = objNull;

waituntil{time > 2};

if(isServer && (!(local player)) then
{
//exit;
}
else
{
if(_val == 0) then
{
	[1] execVM "jumpdistance.sqf";
	while{_action1} do
	{
		sleep 1;
		if(!(alive player)) then
		{
			_action1 = false;
		}
		else
		{
			if((player != vehicle player) && (player == driver (vehicle player))) then
			{
				_vcl = vehicle player;
				while{_action2} do
				{
					sleep 0.01;
					if((position _vcl select 2) > 1) then
					{
						_pos1 = format["%1",position _vcl];
						sleep 0.2;
						waituntil{((position _vcl select 2) < 1)};
						_pos2 = format["%1",position _vcl];
						_dist = call compile format["round(%1 distance %2)",_pos1,_pos2];
						if(_dist > 1) then
						{
							mString = format["%2  jumped %1 meters!!!",_dist,name player];
							publicvariable "mString";
						};
						sleep 2;
					}
					else
					{
						if(!(alive player)) then
						{
							_action2 = false;_action1 = false;
						}
						else
						{
							if((player == vehicle player) || ((player != vehicle player) && (player != driver (vehicle player)))) then
							{
								_action2 = false;
							};
						};
					};
				};
			};
		};
	};
}
else
{
	while{alive player} do
	{
		sleep 0.1;
		if(format["%1",mString] != "") then
		{
			player sidechat _string;
			mString = "";
			sleep 1;
		};
	};
};
};

Greeting

Silola

Share this post


Link to post
Share on other sites

thanks, will try it. I have time today because the base closed due to the Nor'Easter and they told us all to go home. It is good to work for the government!

---------- Post added at 10:06 AM ---------- Previous post was at 09:44 AM ----------

ok, it doesn't work...the rpt shows some syntax errors but I can't find them:

Error in expression <tring;
mString = "";
sleep 1;
};
};
};
};>
 Error position: <;>
 Error Missing )
File E:\Documents and Settings\Dave\My Documents\ArmA 2 Other Profiles\Zombie\mpmissions\stuntman.Chernarus\jumpdistance.sqf, line 83
Error in expression <tring;
mString = "";
sleep 1;
};
};
};
};>
 Error position: <;>
 Error Missing )
File E:\Documents and Settings\Dave\My Documents\ArmA 2 Other Profiles\Zombie\mpmissions\stuntman.Chernarus\jumpdistance.sqf, line 83
Error in expression <> 2};

if(isServer && (!(local player)) then
{

}
else
{
if(_val == 0) then
{
[1>
 Error position: <then
{

}
else
{
if(_val == 0) then
{
[1>
 Error then: Type Bool, expected if
File E:\Documents and Settings\Dave\My Documents\ArmA 2 Other Profiles\Zombie\mpmissions\stuntman.Chernarus\jumpdistance.sqf, line 13

Share this post


Link to post
Share on other sites

sorry ... I found 2 errors ... my fault :mad:

a new one:

private ["_vcl","_val","_pos1","_pos2","_action1","_action2","_dist"];

_val = _this select 0;_pos1 = [];_pos2 = [];_dist = 0;_action1 = true;_action2 = true;mString = "";_vcl = objNull;

waituntil{time > 2};

if((isServer) && (!(local player))) then
{
//exit;
}
else
{
if(_val == 0) then
{
	[1] execVM "jumpdistance.sqf";
	while{_action1} do
	{
		sleep 1;
		if(!(alive player)) then
		{
			_action1 = false;
		}
		else
		{
			if((player != vehicle player) && (player == driver (vehicle player))) then
			{
				_vcl = vehicle player;
				while{_action2} do
				{
					sleep 0.01;
					if((position _vcl select 2) > 1) then
					{
						_pos1 = format["%1",position _vcl];
						sleep 0.2;
						waituntil{((position _vcl select 2) < 1)};
						_pos2 = format["%1",position _vcl];
						_dist = call compile format["round(%1 distance %2)",_pos1,_pos2];
						if(_dist > 1) then
						{
							mString = format["%2  jumped %1 meters!!!",_dist,name player];
							publicvariable "mString";
						};
						sleep 2;
					}
					else
					{
						if(!(alive player)) then
						{
							_action2 = false;_action1 = false;
						}
						else
						{
							if((player == vehicle player) || ((player != vehicle player) && (player != driver (vehicle player)))) then
							{
								_action2 = false;
							};
						};
					};
				};
			};
		};
	};
}
else
{
	while{alive player} do
	{
		sleep 0.1;
		if(format["%1",mString] != "") then
		{
			player sidechat mString;
			mString = "";
			sleep 1;
		};
	};
};
};

Greeting

Silola

Share this post


Link to post
Share on other sites

ok, now we are getting closer...it works without error...reports the same distances to deeds and me...that's the good news

bad news is it stops working if you get out of your vehicle. I got out and entered a different vehicle and it stopped...Deeds got out and re-entered the SAME vehicle and it stopped there too. Getting closer!

Share this post


Link to post
Share on other sites

ok, looks good to me too ;)

I hope we get it final today ... *lookingforsolutionnow*

---------- Post added at 07:37 PM ---------- Previous post was at 07:32 PM ----------

Ok, I've found the (my) mistake :p

Here the newest version:

private ["_vcl","_val","_pos1","_pos2","_action1","_action2","_dist"];

_val = _this select 0;_pos1 = [];_pos2 = [];_dist = 0;_action1 = true;_action2 = true;mString = "";_vcl = objNull;

waituntil{time > 2};

if((isServer) && (!(local player))) then
{
//exit;
}
else
{
if(_val == 0) then
{
	[1] execVM "jumpdistance.sqf";
	while{_action1} do
	{
		sleep 1;
		if(!(alive player)) then
		{
			_action1 = false;
		}
		else
		{
			if((player != vehicle player) && (player == driver (vehicle player))) then
			{
				_vcl = vehicle player;_action2 = true;
				while{_action2} do
				{
					sleep 0.01;
					if((position _vcl select 2) > 1) then
					{
						_pos1 = format["%1",position _vcl];
						sleep 0.2;
						waituntil{((position _vcl select 2) < 1)};
						_pos2 = format["%1",position _vcl];
						_dist = call compile format["round(%1 distance %2)",_pos1,_pos2];
						if(_dist > 1) then
						{
							mString = format["%2  jumped %1 meters!!!",_dist,name player];
							publicvariable "mString";
						};
						sleep 2;
					}
					else
					{
						if(!(alive player)) then
						{
							_action2 = false;_action1 = false;
						}
						else
						{
							if((player == vehicle player) || ((player != vehicle player) && (player != driver (vehicle player)))) then
							{
								_action2 = false;
							};
						};
					};
				};
			};
		};
	};
}
else
{
	while{alive player} do
	{
		sleep 0.1;
		if(format["%1",mString] != "") then
		{
			player sidechat mString;
			mString = "";
			sleep 1;
		};
	};
};
};

Good luck again !

Share this post


Link to post
Share on other sites

getting closer.....deeds and I both see matching distances for both of us...until....he gets out of the vehicle and then gets back in, then neither of us see distances for him. I can change vehicles and both of us see distances for me no problem. I am the host. Deeds tried disconnecting from my machine and then reconnecting and the script re-initialized and worked fine for him until he got out of the vehicle...then it stopped for him again.

Share this post


Link to post
Share on other sites

ok, now I've added some sidechats to see what happens within the script.

I've also changed the code a little bit...give it a try :p

private ["_vcl","_val","_pos1","_pos2","_action1","_action2","_dist"];

_val = _this select 0;_pos1 = [];_pos2 = [];_dist = 0;_action1 = true;_action2 = true;mString = "";_vcl = objNull;

waituntil{time > 2};

if((isServer) && (!(local player))) then
{
//exit;
}
else
{
if(_val == 0) then
{
	[1] execVM "jumpdistance.sqf";
	while{_action1} do
	{
		sleep 1;
		player sidechat format["player outside vehicle - %1",time];
		if(!(alive player)) then
		{
			_action1 = false;
		}
		else
		{
			if(!(player == vehicle player)) then
			{
				_vcl = vehicle player;_action2 = true;
				player sidechat "Player getin vehicle";
				while{_action2} do
				{
					sleep 0.01;
					if(((position _vcl select 2) > 1) && (!(player == vehicle player))) then
					{
						_pos1 = format["%1",position _vcl];
						sleep 0.2;
						waituntil{(((position _vcl select 2) < 1) || (player == vehicle player))};
						if(player == vehicle player) then
						{
							_action2 = false;
							player sidechat "Player getout vehicle";
						}
						else
						{
							_pos2 = format["%1",position _vcl];
							_dist = call compile format["round(%1 distance %2)",_pos1,_pos2];
							if(_dist > 1) then
							{
								mString = format["%2  jumped %1 meters!!!",_dist,name player];
								publicvariable "mString";
							};
							sleep 2;
							player sidechat "Player has jumped";
						};
					}
					else
					{
						if(!(alive player)) then
						{
							_action2 = false;_action1 = false;
						}
						else
						{
							if(player == vehicle player) then
							{
								_action2 = false;
								player sidechat "Player getout vehicle";
							};
						};
					};
				};
			};
		};
	};
}
else
{
	while{alive player} do
	{
		sleep 0.1;
		if(format["%1",mString] != "") then
		{
			player sidechat mString;
			mString = "";
			sleep 1;
		};
	};
};
};

Share this post


Link to post
Share on other sites

IT WORKS!!!!!!!!!!!! Deeds even disconnected and reconnected and no issues, we changed vehicles and it still worked. I like your hints for troubleshooting ;)

Thanks so much for your work on this...only minor problem is this in the rpt:

Server: Update of object 2:8766 arrived from nonowner
Client: Remote object 5:65 not found
Server: Update of object 2:8568 arrived from nonowner
Server: Update of object 2:8769 arrived from nonowner
Creating debriefing

don't know if it's the script or add-on related. We are still working on the mission where this will be used, but I will definitely mention you in the credits!

Share this post


Link to post
Share on other sites

Hey, that's really nice :bounce3:

I'm a little bit happy, because now I can get back to my little script project :p

I think u can delete the sidechats by yourself?

ok, have a nice time and good luck with your mission!

Greeting

Silola

Share this post


Link to post
Share on other sites
Hey, that's really nice :bounce3:

I'm a little bit happy, because now I can get back to my little script project :p

I think u can delete the sidechats by yourself?

ok, have a nice time and good luck with your mission!

Greeting

Silola

Thanks, yes I can get rid of the extra chats I think...once again many thanks!

Share this post


Link to post
Share on other sites

The script is working just fine and the mission is coming along nicely, but I think I know know why all the math was needed in the original script.

It does a great job of measuring strictly horizontal distances, but...if there is an elevation change, it also calculates that but not correctly, (or at least the way I want). If I land 0 meters forward but 5 meters down from my takeoff point it reports a 5 meter jump. If I land forward and lower (or higher) it calculates the distance but not correctly.

Think you can assist again Silola? Here is the orginal OFP:R script if it would help:

;;
;;  This will measure jumping distance
;; @author MI_Fred and {USI}_Zombie
;; @created 3/23/04 5:46:18 AM
;; put this line in every vehicles init: this exec "altmonitor.sqs"
;; altmonitor.sqs

#speedloop
;;(driver _veh) sidechat format ["speed:%1 ----altitude:%2",speed _veh, getpos _veh select 2]
~.3
;;criteria for starting jump distance is 1 meter as height
?((getpos _vcl select 2) < 1) : goto "speedloop"

player sidechat "measuring jump distance"
_startgl = "Logic" camcreate getpos _vcl

@ ((getpos _vcl select 2) < 1)
_dx = (getpos _startgl select 0) - (getpos _vcl select 0)
_dy = (getpos _startgl select 1) - (getpos _vcl select 1)
_dist = sqrt ((_dx * _dx) + (_dy * _dy));
deletevehicle _startgl

(driver _vcl) globalchat format ["%2  jumped %1 meters!!!",_dist, name driver _vcl]
;;~4
goto "start"

Share this post


Link to post
Share on other sites

Hi :)

sorry for the delayed response.

Below, the new version with correct distance calc ...

private ["_vcl","_val","_pos1","_pos2","_action1","_action2","_dist","_diff","_log1","_log2"];

_val = _this select 0;_pos1 = [];_pos2 = [];_dist = 0;_action1 = true;_action2 = true;
mString = "";_vcl = objNull;_log1 = objNull;_log2 = objNull;_diff = 0;

waituntil{time > 2};

if((isServer) && (!(local player))) then
{
_val = 1;
}
else
{
if(_val == 0) then
{
	[1] execVM "jumpdistance.sqf";
	_log1 = "logic" createvehiclelocal [0,0,0];
	_log2 = "logic" createvehiclelocal [0,0,0];
	while{_action1} do
	{
		sleep 1;
		player sidechat format["player outside vehicle - %1",time];
		if(!(alive player)) then
		{
			_action1 = false;
		}
		else
		{
			if(!(player == vehicle player)) then
			{
				_vcl = vehicle player;_action2 = true;
				player sidechat "Player getin vehicle";
				while{_action2} do
				{
					sleep 0.01;
					if(((position _vcl select 2) > 1) && (!(player == vehicle player))) then
					{
						_log1 setpos position _vcl;
						sleep 0.2;
						waituntil{(((position _vcl select 2) < 1) || (player == vehicle player))};
						if(player == vehicle player) then
						{
							_action2 = false;
							player sidechat "Player getout vehicle";
						}
						else
						{
							_log2 setpos position _vcl;
							_diff = ((getPosASL log1) select 2) - ((getPosASL log2) select 2);
							log2 setpos [(position log2 select 0),(position log2 select 1),_diff];
							_dist = round(_log1 distance _log2);
							if(_dist > 1) then
							{
								mString = format["%2  jumped %1 meters!!!",_dist,name player];
								publicvariable "mString";
							};
							sleep 2;
							player sidechat "Player has jumped";
						};
					}
					else
					{
						if(!(alive player)) then
						{
							_action2 = false;_action1 = false;
						}
						else
						{
							if(player == vehicle player) then
							{
								_action2 = false;
								player sidechat "Player getout vehicle";
							};
						};
					};
				};
			};
		};
	};
}
else
{
	while{alive player} do
	{
		sleep 0.1;
		if(format["%1",mString] != "") then
		{
			player sidechat mString;
			mString = "";
			sleep 1;
		};
	};
};
};
if(_val == 0) then {{deletevehicle _x}foreach [_log1,_log2]};

Greeting

Silola

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  

×