Jump to content
Sign in to follow this  
Espectro (DayZ)

Onmapsingleclick in MP

Recommended Posts

Hi there

I can't make the following command work using dedicated server:

onmapsingleclick "grp move _pos"

It works fine when I just preview in the editor... But for some reason nothing happends when I connect to my server.

Any known issues with this?

Cheers

Share this post


Link to post
Share on other sites

onmapsingleclick is only ran local, so you will need a system that sends the position to the server while the server executes the move to pos I think, as the command need to be executed on the pc where the units are local...

You could try using my network services lite for that:

http://www.flashpoint1985.com/cgi-bin....t=56464

If you have questions about the package though... please use that thread, thank you

Share this post


Link to post
Share on other sites

OMSC is executed locally. If group is AI, it is local on server and "move" probably only works on local units. wink_o.gif

Share this post


Link to post
Share on other sites

Solution that should work (with the NS-Lite):  smile_o.gif

In some init script, mission, later scripting moment:

unit_that_needs_the_action Addaction ["Move Group", "scripts\mapclick.sqf"];

scripts\mapclick.sqf:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">onMapSingleClick "[_pos,nameoftheunit] exec ""scripts\sendmapclick.sqs""";

scripts\sendmapclick.sqs:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">call compile format["[0,""[%1,%2] execVM """"scripts\moveunit.sqf""""""] call six_fn_Netsend",_this select 0,_this select 1];

scripts\moveunit.sqf:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">(_this select 1) domove (_this select 0);

To execute the script on server and client, change the [0,   to [2,

and use the six_isServer boolean in the moveunit.sqf script to determine if it should execute the move, or in case of client... don't execute the move but do a hint of somesorts smile_o.gif

You can also remove the moveunit.sqf and make scripts\sendmapclick.sqs:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">call compile format["[0,""%2 doMove %1""] call six_fn_Netsend",_this select 0,_this select 1];. But then ur missing an easy and readable possibility to execute different things on client and server if you wish smile_o.gif

Please let me know if it works btw as it's written from mind without test smile_o.gif

Share this post


Link to post
Share on other sites

call format should be call compile format. wink_o.gif

My solution:

grpMove.sqf:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (local (leader _this)) then {

while {true} do {

MoveToPos = "";

waitUntil {MoveToPos != ""};

_this move call compile MoveToPos;

};}

init.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">grp execVM "grpMove.sqf";

onMapSingleClick 'MoveToPos = str(_pos); publicVariable MoveToPos'

But also untested.

Share this post


Link to post
Share on other sites
call format should be call compile format. wink_o.gif

Already edited that one out a few mins ago wink_o.gif)

But nice and compact btw smile_o.gif Nice way to 'pack' and 'unpack' arrays into strings and visa versa biggrin_o.gif

btw you write init.sqf... I simply thought there would not be a init.sqf as the missions still work on init.sqs, nice if you can also use the init.sqf!

Share this post


Link to post
Share on other sites
Nice way to 'pack' and 'unpack' arrays into strings and visa versa biggrin_o.gif

Yep, but you have to take care, as the strings can get pretty long very fast. In this case you could eg remove all digits after the comma, as it is absolutely useless bandwidth useage wink_o.gif

Share this post


Link to post
Share on other sites
Nice way to 'pack' and 'unpack' arrays into strings and visa versa biggrin_o.gif

Yep, but you have to take care, as the strings can get pretty long very fast. In this case you could eg remove all digits after the comma, as it is absolutely useless bandwidth useage wink_o.gif

Thanks, that init.sqf was not a typo, yes?

BTW just figured out that execVM is not allowed within onmapsingleclick... haven't seen that in the BIKI yet, guess I should get into BIKI-editing biggrin_o.gif

Share this post


Link to post
Share on other sites
Nice way to 'pack' and 'unpack' arrays into strings and visa versa biggrin_o.gif

Yep, but you have to take care, as the strings can get pretty long very fast. In this case you could eg remove all digits after the comma, as it is absolutely useless bandwidth useage wink_o.gif

Thanks, that init.sqf was not a typo, yes?

BTW just figured out that execVM is not allowed within onmapsingleclick... haven't seen that in the BIKI yet, guess I should get into BIKI-editing biggrin_o.gif

Yep, it was not a typo.

Why is execVM not allowed? Did you try<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">dummy = [...] execVM ...As execVM returns the script handle...

Share this post


Link to post
Share on other sites
Why is execVM not allowed? Did you try<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">dummy = [...] execVM ...
As execVM returns the script handle...

It gave: Type script, expected bool... I wasn't able to check it myself yet, will do tonight smile_o.gif

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  

×