Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google Log In with Steam Sign In
  • Create Account
Photo

script Total Walked (like dayzMod page)

script Total Walked (like day

  • Please log in to reply
3 replies to this topic

#1
snooop87

snooop87

    100+ Post Club

  • Forum Member
  • 123 posts
  • Country: Country Flag
  • snooop1987

dear community  iwant to create an HighScore system,

it will save Kills,Streak,Deaths,PayedMoney,Money,timeplayed and 
Moved miles(Total Walked).this Highscore will only show the Best players 
with these parameter.

i only need help with the Total walked script, because there is no Command on arma to get this variable.

 

i tryed with the onKeyPress.sqf -> case 17: // W{varTW= varTW+1 * time.deltaTime;};

 





#2
Viba

Viba

    100+ Post Club

  • Forum Member
  • 165 posts
  • Country: Country Flag

Check player position in a certain intervall and calculate the travelled distance.

 

Snippet from original dayz code:

_charPos = 		getPosATL _character;

private["_debug","_distance"];
_debug = getMarkerpos "respawn_west";
_distance = _debug distance _charPos;
if (_distance < 2000) exitWith { 
	diag_log format["ERROR: server_playerSync: Cannot Sync Player %1 [%2]. Position in debug! %3",name _character,_characterID,_charPos];
};

		if (((_charPos select 0) == 0) and ((_charPos select 1) == 0)) then {
			//Zero Position
		} else {
			//diag_log ("getting position..."); sleep 0.05;
			_playerPos = 	[round(direction _character),_charPos];
			_lastPos = 		_character getVariable["lastPos",_charPos];
			if (count _lastPos > 2 and count _charPos > 2) then {
				if (!_isInVehicle) then {
					_distanceFoot = round(_charPos distance _lastPos);
				};
				_character setVariable["lastPos",_charPos];
			};
			if (count _charPos < 3) then {
				_playerPos =	[];
			};
			//diag_log ("position = " + str(_playerPos)); sleep 0.05;
		};

b_350_20_020822_0E0E11_FFFFFF_F5F5F5.png

 


#3
snooop87

snooop87

    100+ Post Club

  • Forum Member
  • 123 posts
  • Country: Country Flag
  • snooop1987

thank you Viba, i changed some and it works fine 4me.

player setVariable["lastPos",[],true];
sleep 60;
while {walked}do {
    waituntil {vehicle player == player};
_charPos = getPosATL player;
private["_debug","_distance"];

_distance = [0,0,0] distance _charPos;

if (_distance > 10000) exitWith { };
_lastPos =player getVariable"lastPos";
_distanceFoot = round(_charPos distance _lastPos);
if (_distanceFoot > 1000) exitWith {};
_y= player getvariable"highscore"; player setvariable["highscore",[_y select 0,_y select 1,_y select 2,_y select 3,_y select 4,_y select 5,_y select 6, (_y select 7)+_distanceFoot],true];
player setVariable["lastPos",_charPos,true];
sleep 10;}; 


#4
KiloSwiss

KiloSwiss

    100+ Post Club

  • Forum Member
  • 455 posts
  • Country: Country Flag

Why do you transmit the Variable "lastpos" over the network if you only use it locally?

Why do you use setVariable on the player if you can simply use a local (or maybe global if used in other scripts) variable?

 

Just some thoughts I had when I looked over your code.

 

Also this code here:

_y= player getvariable"highscore"; player setvariable["highscore",[_y select 0,_y select 1,_y select 2,_y select 3,_y select 4,_y select 5,_y select 6, (_y select 7)+_distanceFoot],true];
Could be done that way:
_y = player getVariable "highscore";
_y set [7, ((_y select 7)+_distanceFoot)];
player setVariable["highscore", _y, true];
It's three lines of code, but provides a slightly better readability, resulting in less confusion and/or possible errors when editing that Code.

 

Hope I could help you a little bit with my post.

 

Greez KiloSwiss






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users