OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: majorjustice on 05 Aug 2009, 18:35:05
-
hi im having a problem with a mission
i am trying to make a randomly placed invisible H (heli pad) give its grid location to the player through the side chat .. for exsample "base: lz is at grid loction 006029"
i have tryed using getpos but have no idea how to convert what is returned into a grid coordinate
any help is much appreciated :)
-
Maybe there are old scripts in the Editors Depot or the boards doing this for the previous games. You would have to edit them.
Also I've read in the news ArmA2 includes many functions. Who knows, maybe that's included now.
On the other hand it's just math. Find out the size of a single map grid and relate this by dividing to the getpos result which should inherit from the bottom left of the map. Then count the grids and give an output.
hint format ["base: lz is at grid loction %1",GRIDRESULT]
-
hey thanks for the reply and i have found some old scripts for arma tht would do it but they use the old grid refrence using letters aswell as numbers and now its all numbers (6 figure grid refrence) and i dont have the know how to change it :( also im not quite sure how to do what your talking about if u could break it down slightly i wud grateful :) and also here is the old sricpt if u have any idea on wat to do
private ["_result","_GrandeLettre","_PetiteLettre","_Chiffre", "_Chiffrestring","_Pos","_ArrayMajuscForGrid","_ArrayMinusForGrid " ];
_ArrayMajuscForGrid = ["A","B","C","D","E","F","G","H","I","J"];
_ArrayMinusForGrid = ["a","b","c","d","e","f","g","h","i","j"];
_Pos = _This select 0;
_Chiffrestring ="";
_result = "";
_GrandeLettre = (((_Pos select 0) - ((_Pos select 0) Mod 1280))/1280);
_PetiteLettre =((((_Pos select 0) Mod 1280)- (((_Pos select 0) Mod 1280)Mod 128))/128);
_Chiffre = (99 - ((_Pos select 1) - ((_Pos select 1) Mod 128))/128);
_Chiffrestring = Format["%1",_Chiffre];
If (_Chiffre < 10) then {_Chiffrestring = "0" + _Chiffrestring };
_result = ((_ArrayMajuscForGrid select _GrandeLettre) + ( _ArrayMinusForGrid select _PetiteLettre) +_Chiffrestring);
_result
-
This is the function used from the game. I know it works for Chenarus not sure about any other maps
private ["_x","_y","_xgrid","_ygrid","_xcoord","_ycoord","_result"];
_x = (_this select 0) select 0;
_y = (_this select 0) select 1;
_xgrid = floor (_x / 100);
_ygrid = floor ((15360 - _y) / 100);
_xcoord =
if (_xgrid >= 100) then {
str _xgrid;
} else {
if (_xgrid >= 10) then {
"0" + str _xgrid;
} else {
"00" + str _xgrid;
};
};
_ycoord =
if (_ygrid >= 100) then {
str _ygrid;
} else {
if (_ygrid >= 10) then {
"0" + str _ygrid;
} else {
"00" + str _ygrid;
};
};
_result = [_xcoord,_ycoord];
_result
I just tested it on utes and I had to rewrite the code this works on both islands
private ["_x","_y","_xgrid","_ygrid","_xcoord","_ycoord","_result"];
_x = (_this select 0) select 0;
_y = (_this select 0) select 1;
_cfg = configFile>>"CfgWorlds">>worldName;
Switch toLower (worldName) do{
case "utes": {_ygrid = floor ( (5120 - _y) / 100);};
case "chernarus": {_ygrid = floor ( (15360 - _y) / 100);};
default {_ygrid = floor ( (15360 - _y) / 100);};
};
_xgrid = floor (_x / 100);
_xcoord =
if (_xgrid >= 100) then {
str _xgrid;
} else {
if (_xgrid >= 10) then {
"0" + str _xgrid;
} else {
"00" + str _xgrid;
};
};
_ycoord =
if (_ygrid >= 100) then {
str _ygrid;
} else {
if (_ygrid >= 10) then {
"0" + str _ygrid;
} else {
"00" + str _ygrid;
};
};
_result = [_xcoord,_ycoord];
_result;
-
thanks for the input :) now how wud i get the coordinate to come up on the global chat for exsample im really new to scripting :no:
-
try out the script in the file I attached.
-
wow thanks so much jones thts a massive help just wat i wanted :)
-
The sample mission is different than the script I posted I had changed it a bit so that it would work on both islands. Just copy and past the code fromt he post obve into the pos2grid .sqf