Jump to content
Sign in to follow this  
famematt

Server side hud scripty thingy

Recommended Posts

deleted

Edited by famematt

Share this post


Link to post
Share on other sites

deleted

Edited by famematt

Share this post


Link to post
Share on other sites
Now, How do i get the distance from the Shift+Click marker?

onMapSingleClick returns the position of the click as _pos which you can then use to figure out the distance between your current position and _pos.

Share this post


Link to post
Share on other sites

Be careful with _pos wrt onMapSingleClick, as _pos select 2 gives negative output - or something. Get into the habit of using [_pos select 0, _pos select 1, 0] instead. I don't know, it's a really weird one that one...

Share this post


Link to post
Share on other sites

this is one way to track distance to shift click on map:

1: add this in unit init:

destination = [];
onMapSingleClick "if (_shift) then {destination = _pos;}; true;"

for testing purposes i placed the hint part in init aswell.

_null = [] spawn {

waitUntil {(count destination) != 0};
_showMe = true;
while {_showMe} do {
_veh = vehicle player;
_speed = round (speed _veh);
_pos = [destination select 0, destination select 1,0];
_dist = round (_veh distance _pos);
hintSilent format["speed of vehicle is %1 km/h \n distance to destination is %2 meter",_speed,_dist];
sleep 1; 
};

};

Share this post


Link to post
Share on other sites

deleted

Edited by famematt

Share this post


Link to post
Share on other sites

_localVariable = 0; // this can only be acessed from within its script. underscore in front.

globalVariable = 0; // this can be acessed from anywhere, no undercore in front.

Share this post


Link to post
Share on other sites

deleted

Edited by famematt

Share this post


Link to post
Share on other sites

just a note on global variables, in MP you need to use the publicVariable command also to broadcast the variable to all clients, this ofc if clients need to "know" the variable.

for table (one similar to Sqlite or Mysql?), i dont know what you mean, sorry.

for finding a string in a array use in command:

_myArray_With_Strings = ["hello","mom","bruce"];
if ("hello" in _myArray_With_Strings) then {
  hint "its there";
} else {
  hint "its not there";
};

you can also find its position in the array like this with find command:

_myArray_With_Strings = ["hello","mom","bruce"];
if ("hello" in _myArray_With_Strings) then {
  _sel = _myArray_With_Strings find "hello";
  hint format["string is number %1 in the array",_sel];
};

note that find command gives the select number so first one will be 0, second one 1, unlike count wich will use 1 for 1 and 2 for 2.

Edited by Demonized

Share this post


Link to post
Share on other sites

deleted

Edited by famematt

Share this post


Link to post
Share on other sites

much easier to keep the info written in threads, also its good for others looking for same issue.

you should give the guide in my signature a read, it will give you alot of info on how to, and especially give you many ways and examples of doing various things.

i think you are asking for a way to add something to a existing array.. ?

_myArray = ["apple","oranges"];
_myArray = _myArray + ["bananas","lollipops"];
// now _myArray will contain this in this order:
// _myArray = ["apple","oranges","bananas","lollipops"];

thats what you meant?

more info on working with arrays:

http://community.bistudio.com/wiki/Array

Share this post


Link to post
Share on other sites

deleted

Edited by famematt

Share this post


Link to post
Share on other sites

deleted

Edited by famematt

Share this post


Link to post
Share on other sites
Thanks....

What is another way to identify a player other than the player syntax thing... because its not working for what i want to do...?

alright, what do you want to do? :rolleyes:

there is isPlayer perhaps, but hard to guess like this.

Share this post


Link to post
Share on other sites

deleted

Edited by famematt

Share this post


Link to post
Share on other sites

look at my post in page 1 for correct usage of onMapSingleClick

you simply do nothing when clikking on map with your code, you cant assign it a handle, you need it to perform a task.

ant whats this? doesnt make any sense.

_math = _distance / _distance;
_output = Format["%1 Meters Away",_math];

info from distance wiki.

Returns the distance in meters between two Objects, Positions

Share this post


Link to post
Share on other sites

deleted

Edited by famematt

Share this post


Link to post
Share on other sites

if you read up on onMapSingleCLick on wiki youll see that _pos is a hardcoded handle in the command.

_pos will always be the position you click on.

you can for example run a script and give it the _pos, like this:

onMapSingleClick "_null = [_pos] execVM 'somescript.sqf'; true;"

now the script (somescript.sqf) will have this:

_position_clicked_on_map = _this select 0;

Share this post


Link to post
Share on other sites

deleted

Edited by famematt

Share this post


Link to post
Share on other sites

this is from my page one post btw :j:

onMapSingleClick "[b][size="4"]if (_shift) then {[/size][/b]destination = _pos;[b][size="4"]};[/size][/b] true;"

edit: ifits not clear, do your code or run your script instead of destination = _pos; part

Edited by Demonized

Share this post


Link to post
Share on other sites

deleted

Edited by famematt

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  

×