Jump to content
Eblonski

Newbie need help with creating global objects

Recommended Posts

Hi there. First of all sorry for my poor English.

So, i just started "scripting" things for Arma3 and i faced with problem of creating object by client globally. Basic idea was to build the bridge by holding button, but when i hosting a server i (the server )  can make my script work, but not friend of mine (client). 

With that problem i tried many different solutions like HideObject, then making it's "false" in the body of "holdAction".

Here is my code now, holdAction :

if (!isDedicated) then 
{
if (playerSide == west) then
{
[
    planks_s, // Object
    "Construct bridge", // Title
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa", 
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa", 
    "(_this distance _target < 5)", 
    "(_this distance _target < 5)", 
    {},
    {},
    { [] spawn {[] execVM "PlankSimple_S.sqf"}}, // Code executed on completion
    {},
    [],
    3, // how long
    0,
    true,
    false
] call BIS_fnc_holdActionAdd;
};
};

And here's my file "PlankSimple_S.sqf" :

if (isServer) then 
{
	_simpleObject_0 = createSimpleObject ['a3\structures_f_exp\civilian\accessories\plank_01_8m_f.p3d', [5613.273926,4128.347168,13.888593]];
	_simpleObject_0 setVectorDirAndUp [[-0.857715,-0.499353,-0.122361],[-0.114261,-0.0469019,0.992343]];
	_simpleObject_1 = createSimpleObject ['a3\structures_f_exp\civilian\accessories\plank_01_4m_f.p3d', [5618.109863,4131.231934,14.0554686]];
	_simpleObject_1 setVectorDirAndUp [[-0.84041,-0.514142,0.171377],[0.155349,0.0744123,0.985053]];
	_simpleObject_2 = createSimpleObject ['a3\structures_f_exp\civilian\accessories\plank_01_8m_f.p3d', [5608.121094,4125.246094,13.159078]];
	_simpleObject_2 setVectorDirAndUp [[-0.854349,-0.503035,-0.130551],[-0.151054,0,0.988526]];
};

So once again. I need to make it work globally on server to every client.

Thanks in advance. And once again, sorry for my English. 

Share this post


Link to post
Share on other sites
18 minutes ago, Grumpy Old Man said:

Why the isDedicated and isServer checks?

Well i was thinking about make it work for not only one client by that.

18 minutes ago, Grumpy Old Man said:

Where are you calling those functions?

i got "planks.sqf" file were holdAction written, then i just doing [] execVM "planks.sqf"; into "init.sqf".

Share this post


Link to post
Share on other sites

PlankSimple_S.sqf must be everywhere. No matter who runs it. The effect is global (setVectorDirandUP should work also). Remove the if (isServer) cond.

On the other hand, there is no risk of duplication because your BIS_fnc_holdActionAdd runs locally on caller's PC.

you can simplify:

{ [] spawn {[] execVM "PlankSimple_S.sqf"}}

by

{ execVM "PlankSimple_S.sqf"}

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
6 hours ago, pierremgi said:

PlankSimple_S.sqf must be everywhere. No matter who runs it. The effect is global (setVectorDirandUP should work also). Remove the if (isServer) cond.

On the other hand, there is no risk of duplication because your BIS_fnc_holdActionAdd runs locally on caller's PC.

you can simplify:

{ [] spawn {[] execVM "PlankSimple_S.sqf"}}

by

{ execVM "PlankSimple_S.sqf"}

It's worked ty so much!

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

×