Programmatically get worldspace position?

Jrb

New Member
Hi all,

Does anyone know the code or algorithm to gather a player's worldspace position? Before you throw it out, I know a player's worldspace can be found in the SQL database.

I'm looking to write a small script that will add an action for a player to copy the current worldspace to the clipboard using Arma's copyToClipboard function.

Any help will be appreciated.
 
What format are you looking to see it in? The same format it shows in the DB, or will any format do?

This may work, depending on what position you are looking for:
http://community.bistudio.com/wiki/getPos

There are several other getPos's referenced in that article that get slightly different vertical positions. Check them out and see which one matches the DB.

It returns [x, y, z]
 
What format are you looking to see it in? The same format it shows in the DB, or will any format do?

This may work, depending on what position you are looking for:
http://community.bistudio.com/wiki/getPos

There are several other getPos's referenced in that article that get slightly different vertical positions. Check them out and see which one matches the DB.

It returns [x, y, z]

I'm looking for the Database format, which I believe the only difference is it shows the direction you're facing.
 
You'd need getdir to pull the direction, then format it and the coords appropriate to the DB format and then send it to clipboard.

I don't know if there is a function that gives you both, in the same call, in the same format as the DB.
 
  • Like
Reactions: Jrb
fnc_mypos = {

private ["_pos","_obj","_dir","_mypos"];

_obj = _this select 0;
_pos = getPos _obj;
_dir = getDir _obj;

_mypos = [ _dir,_pos];

_mypos;

};


call it with e.g.

_dbpos = [player] call fnc_mypos;

untested, but should work.

Sarge
 
fnc_mypos = {

private ["_pos","_obj","_dir","_mypos"];

_obj = _this select 0;
_pos = getPos _obj;
_dir = getDir _obj;

_mypos = [ _dir,_pos];

_mypos;

};


call it with e.g.

_dbpos = [player] call fnc_mypos;

untested, but should work.

Sarge

Thanks, I'll let you know if it works.
 
Sarge's method technically works, but isn't formatted properly.

For all those wanting to get the worldspace in DayZ, just use this:

copyToClipboard format ["%1 %2", [getdir player,getposatl player]];


Tested & works. Will copy the database format to your Windows clipboard.
 
well, depending on what you want with the entry, you can still format it. My function returns an array, if you need a string out of that just run it through a format statement.

Good call on the getPosATL though, i always forget that getPos is 3 times slower than getPosATL and should due to that be avoided :)

Keep in mind both solutions above will only work on the clienside, on a server they will fail (no player object there)

Sarge
 
  • Like
Reactions: Jrb
Back
Top