Jump to content
Sign in to follow this  
1para{god-father}

another JIP addaction issue !

Recommended Posts

OK I am spawning a Ammo crate and need to add the VAS addaction back to it, and yep the Addaction does not work for JIP - No idea why i cannot seem to get any addaction working for JIP - does anyone have anything that works for JIP on a dedi ?

my INIT.sqf



////create a function///////
God_fnc_addAction = {
   private["_object","_script"];
   _object = _this select 0;
   _script = _this select 1;

   _object addAction _script;

};

then this is part of the create.sqf (it loads from a db)


_obj = createVehicle [_class,_pos, [], 0, "CAN COLLIDE"];
_obj setPosASL _pos;
_obj setVectorDirAndUp _dir;
[[_obj, ["<t color='#ff1111'>Virtual Ammobox</t>", "VAS\open.sqf"]], "God_fnc_addAction", nil, true] spawn BIS_fnc_MP;

It all works when I reload the mission i get the crate where it last was and the Option but if I leave and join again i no longer get the Addaction i thought the BIS_fnc_MP would work for JIP!?

Share this post


Link to post
Share on other sites

With BIS_fnc_MP you basically made it where the ammobox would be persistant(JIP) but only to no one.

[params, functionName, target, isPersistent] spawn BIS_fnc_MP;

You just specified the wrong target that is all.

Share this post


Link to post
Share on other sites

ok changed it to

[[_obj, ["<t color='#ff1111'>Virtual Ammobox</t>", "VAS\open.sqf"]], "God_fnc_addAction", true, true] spawn BIS_fnc_MP;

But if i leave and come back in i no longer get the addaction ?

Share this post


Link to post
Share on other sites

I think some guys on the forums were saying the persistent function of BIS_fnc_MP has some issues. But syntax looks correct so it may be a game engine problem.

Share this post


Link to post
Share on other sites

Just out of interest, have you tried something like this:

[[_obj, "if working in JIP, then client sees this"], "God_fnc_testFnc", true, true] spawn BIS_fnc_MP; 

God_fnc_testFnc = 
{
   _ob = _this select 0;
   _mess = _this select 1;

   diag_log format ["%1, %2, %3", _ob, _mess, time];
};

So if client can see message in rpt on connection, then BIS_fnc_MP is working ok and the problem lies elsewhere (in the addAction part).

EDIT: Thinking about it, this probably won't work either. I think the problem is where and when you are defining your function.

Off the top of my head, init.sqf is only fired at mission init. Therefore, anyone who joins later won't have access to the function you defined in it.

Try saving your functon elsewhere (like onPlayerConnected.sqf)

Edited by Das Attorney

Share this post


Link to post
Share on other sites

Ok can see the message in .rpt so why would this not work just tested it works fine when i start the mission i get the addaction , if i leave and rejoin i do not get the addaction ?

temprescue.sqf

if(not isServer) exitWith{};

AO_locations = nearestLocations [getPosATL player, ["StrongpointArea","FlatArea","NameLocal","Mount","NameVillage","Strategic","Hill","FlatAreaCity"], 25000];
_location = AO_locations call BIS_fnc_selectRandom;
_pos = (position _location);

_grp = createGroup WEST;
_TAG_pilot = _grp createUnit ["B_Helipilot_F", _pos, [], 0, "FORM"];
_TAG_pilot setCaptive true;
_TAG_pilot allowDamage false;
_TAG_pilot setHit ["hands",1];
_TAG_pilot setHit ["head_hit",0.4];
_TAG_pilot setHit ["body",0.5];
//_TAG_pilot playMoveNow "AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon";
_TAG_pilot disableAI "MOVE";
_TAG_pilot disableAI "ANIM";
removeAllWeapons _TAG_pilot;
[[_TAG_pilot, ["<t color='#ff1111'>Rescue</t>", "script\capture.sqf"]], "God_fnc_addAction", true, true] spawn BIS_fnc_MP;  

INIT.sqf

God_fnc_addAction = {
   private["_object","_script"];
   _object = _this select 0;
   _script = _this select 1;

   _object addAction _script;

}; 

[] execVM "temprescue.sqf"; 

Share this post


Link to post
Share on other sites
With BIS_fnc_MP you basically made it where the ammobox would be persistant(JIP) but only to no one.

[params, functionName, target, isPersistent] spawn BIS_fnc_MP;

BIS_fnc_MP says target: Object - function will be executed only where unit is local [default: everyone] - the default can be set by nil, example 2 shows that usage with the claim that it executes on all players+jip

--

@1PARA, i think whats going on is this:

https://community.bistudio.com/wiki/Functions_Library_(Arma_3) - Initialization Order (1/2 way down)

Persistent JIP functions are executed before init.sqf is loaded in multiplayer. So its calling "god_fnc_addaction", but it doesn't exist yet.

Perhaps you could use bis_fnc_mp and bis_fnc_call to compile preprocess a file with your functions in it, or just the script itsself for the addaction

In testing at home, 90% of the time it would load the action jip with the code as you typed, i can only imagine its a race to the finish interms of executing the mp function and finishing the init.sqf compile. thus the seemingly randomness of it....imho

Edited by dr_strangepete

Share this post


Link to post
Share on other sites

The persistent param does seem broken for me at least, as I had some JIP addactions that worked perfectly in 2 separate missions then there was a patch that broke them, they no longer worked for JIP players after it and I was never able to fix it.

Edited by clydefrog

Share this post


Link to post
Share on other sites

Ahhhhh thank god I thought it was just me !

This is driving me mad ! - Why o Why do BIS not make these things easy / or STOP breaking things that work!

well i have spent over a week trying to sort this out with still no Joy - so if anyone out there could kindly solve the issue please can you post the code as i think i will pull my last hair out if i try again :)

:)

Edited by 1PARA{God-Father}

Share this post


Link to post
Share on other sites

The one and only time I tried the persistent parameter, it didn't work either.

Share this post


Link to post
Share on other sites
I see no reason why the persistent functions are called before init.sqf in MP, it there a reason?

Anyway I guess a solution is to compile your function from description.ext

https://community.bistudio.com/wiki/Functions_Library_(Arma_3)#Adding_a_Function

My guess is thats what they intended

...

When writing a script, consider registering it into the Functions Library.

Main benefits uncludes:

-Automatic compilation upon mission start into a global variable - no need to remember direct paths to files.

-Anti-hack protection using compileFinal

-Optional immediate execution upon mission start,

.....

this all could be part of a security lockdown (ex, setVehicleInit), prevent someone from sideloading code maybe? im not too keen in that dept, but it looks awfully determined to be just a whoops.

doesn't seem like too big a deal tho, in most circumstances you would only really need one or two functions to init your other stuff.

@1PARA - personally i think its an issue of a huge amount of information, and no real structured way to learn all the details and ins-n-outs. Arma really needs a comprehensive cover-to-cover 'this is how it works' in a unified format - the community and wiki are great, don't get me wrong, but the information is just too fragmented for those who dont have the time to dig-try-dig-try-dig-try. there is plenty of information out there, but like they say, you can't find something if you didn't know it existed in the first place.

---------- Post added at 15:02 ---------- Previous post was at 14:53 ----------

so if anyone out there could kindly solve the issue please can you post the code as i think i will pull my last hair out if i try again :)

if you take a look at that page i linked to, on functions, read up near the top about adding functions :

File Path

The easiest and the most transparent way is to set path for each function.

class CfgFunctions

{

class myTag

{

class myCategory

{

class myFunction {file = "myFile.sqf";};

};

};

};

This will try to compile function myTag_fnc_myFunction from the following file:

%ROOT%\myFile.sqf

Where %ROOT% is either mission root (where mission.sqm file is)

Essentially, you would take the code from in your current function, and put it in a file called "addAction.sqf". just the code goes inside, not the function name nor its { brackets }

And add the code above to your description.ext file, making the changes necessary.

As a reminder: myTag_fnc_myFunction

Share this post


Link to post
Share on other sites

Here's an example I made for another fellow, of the best way to use cfgFunctions (IMO!)

Edited by Iceman77

Share this post


Link to post
Share on other sites
Thanks but still no Joy on this - Addaction > JIP = no hair left !

MP strikes again!!! ***Damn MP shenanigans!!! But try this

init.sqf

waitUntil {!isNull player}; // Wait until the player object has been initialized for the join in progress player's machine
_id = player addAction ["The Action", {hint "hahahaha";}];

If you're paranoid:

waitUntil {!isNull player && {player == player && {time > 1}}}; 
_id = player addAction ["The Action", {hint "hahahaha";}];

Edited by Iceman77

Share this post


Link to post
Share on other sites

The addaction will be attached to a Spawned Ammo crate or Pilot in a script run later during the mission so adding it to Player will not work for me. :(

i.e I run a randon Rescue mission

_grp = createGroup WEST;
_TAG_pilot = _grp createUnit ["B_Helipilot_F", _pos, [], 0, "FORM"];
_TAG_pilot setCaptive true;
_TAG_pilot allowDamage false;
_TAG_pilot setHit ["hands",1];
_TAG_pilot setHit ["head_hit",0.4];
_TAG_pilot setHit ["body",0.5];
//_TAG_pilot playMoveNow "AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon";
_TAG_pilot disableAI "MOVE";
_TAG_pilot disableAI "ANIM";
removeAllWeapons _TAG_pilot;
[ [_TAG_pilot], "fncMP_Action", true, true] spawn BIS_fnc_MP;  /// does not work for JIP Ahhhhhhhhhhhhhhhhhhhhhhhh

Share this post


Link to post
Share on other sites
The addaction will be attached to a Spawned Ammo crate or Pilot in a script run later during the mission so adding it to Player will not work for me.

You could always ad the action to the player and set some conditions

// If the player is within 3m of the crate and is looking at the crate, then render the action
_id = player addaction ["VAS Menu","vas.sqf",nil,1,false,true,"","(_target distance myCrate < 3) && {cursorTarget == myCrate}"];

Edited by Iceman77

Share this post


Link to post
Share on other sites

your spawn script

_grp = createGroup WEST;
TAG_pilot = _grp createUnit ["B_Helipilot_F", _pos, [], 0, "FORM"];
TAG_pilot setCaptive true;
TAG_pilot allowDamage false;
TAG_pilot setHit ["hands",1];
TAG_pilot setHit ["head_hit",0.4];
TAG_pilot setHit ["body",0.5];
//_TAG_pilot playMoveNow "AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon";
TAG_pilot disableAI "MOVE";
TAG_pilot disableAI "ANIM";
removeAllWeapons TAG_pilot;
publicVariable "TAG_pilot";

init.sqf

if (!isDedicated) then {
[] spawn {
	waitUntil {!isNull "TAG_pilot"};
	_id = TAG_pilot addAction ["The Action", {hint "hahahaha";}];  
};
};

Share this post


Link to post
Share on other sites
Here's an example I made for another fellow, of the best way to use cfgFunctions (IMO!)

This worked for me, cheers. My actions finally work for JIP player again doing it this way but up until one of those patches before the final release it worked fine doing it by just initiating them from init.sqf. Anyways from now on I will do it through description.ext, I have the functions folder containing the functions.hpp and a separate file for each functions code.

e.g.

functions.hpp

class CF
{
   class CF_Functions
   {
       file = "functions";
       class addactionMP {}; 
       class removeActionMP {}; 
   };
};  

fn_addactionMP.sqf (in the functions folder)




          		 private["_object","_screenMsg","_scriptToCall"];
           		_object = _this select 0;
           		_screenMsg = _this select 1;
           		_scriptToCall = _this select 2;

           		if(isNull _object) exitWith {};

       	_object addaction [("<t color=""#DBA901"">" + (_screenMsg) + "</t>"),_scriptToCall];

fn_removeactionMP.sqf (in the functions folder)



           		private["_object","_actName"];
           		_object = _this select 0;
           		_actName = _this select 1;

           		if(isNull _object) exitWith {};

       	_object removeAction _actName;

and then finally to call the function from wherever:

[[object,"action text","action.sqf"],"CF_fnc_addactionMP",true,true] call BIS_fnc_MP;

Edited by clydefrog

Share this post


Link to post
Share on other sites
This worked for me, cheers. My actions finally work for JIP player again doing it this way but up until one of those patches before the final release it worked fine doing it by just initiating them from init.sqf. Anyways from now on I will do it through description.ext, I have the functions folder containing the functions.hpp and a separate file for each functions code.

e.g.

functions.hpp

class CF
{
   class CF_Functions
   {
       file = "functions";
       class addactionMP {}; 
       class removeActionMP {}; 
   };
};  

fn_addactionMP.sqf (in the functions folder)




           private["_object","_screenMsg","_scriptToCall"];
           _object = _this select 0;
           _screenMsg = _this select 1;
           _scriptToCall = _this select 2;

           if(isNull _object) exitWith {};

       _object addaction [("" + (_screenMsg) + ""),_scriptToCall];

fn_removeactionMP.sqf (in the functions folder)



           private["_object","_actName"];
           _object = _this select 0;
           _actName = _this select 1;

           if(isNull _object) exitWith {};

       _object removeAction _actName;

and then finally to call the function from wherever:

[[object,"action text","action.sqf"],"CF_fnc_addactionMP",true,true] call BIS_fnc_MP;

I see how you add the action to an object but how do you remove the action using this method? Also, how would you use some of the other parameters of the addAction command, like setting the distance from the object for the action to be visible. Currently I use this to add my action:

inspectAction = _this addAction ["INSPECT",{inspected = true, publicVariable "inspected"}, "",9,true,true, "","(_target distance _this) < 10"];

which only shows the action if the player is within 10 meters of the object. How could I incorporate that condition into the method you are using?

Thanks in advance for your assistance. I'm trying to resolve my own JIP addAction issues.

Edited by Zlin

Share this post


Link to post
Share on other sites

Well as I said earlier in this thread I got the JIP actions to work again by using the description.ext method. Anyways I've just started working on some editing again recently and I am having a problem with these actions duplicating after a lot of reconnecting on a dedicated server. I have a "place charge" action on an object, when it is used the action is removed and a "disarm charge" action is placed on the object. When the "disarm charge" action is used I add the "place charge" action again. I use these actions and reconnect after using each one to check it all works for JIP players, this all works fine until about the 4th time I reconnect and then the actions start to duplicate e.g. I will start to get 2 "place charge" actions on the object. Without seeing all of the code does anybody have any idea what might be causing this to happen?

Thanks

Edit: Actually here is some (the main bits) of the code so you can see what is going on:

functions first:

addAction



          		 private["_object","_screenMsg","_scriptToCall"];
           		_object = _this select 0;
           		_screenMsg = _this select 1;
           		_scriptToCall = _this select 2;

           		if(isNull _object) exitWith {};

       	_object addaction [("<t color=""#DBA901"">" + (_screenMsg) + "</t>"),_scriptToCall];

removeAction



           		private["_object","_actName"];
           		_object = _this select 0;
           		_actName = _this select 1;

           		if(isNull _object) exitWith {};

       	_object removeAction _actName;

So next I spawn an ammo box and execute the addaction script on it with BIS_fnc_MP on all clients and for JIP:

[[cargoBox1,"Place Charge","charge.sqf"],"CF_fnc_addactionMP",true,true] call BIS_fnc_MP;

Here is the script that the "Place Charge" action runs:


_object = _this select 0;
_caller = _this select 1;
_id = _this select 2;		// ID of the action to be removed


	[[cargoBox1,_id],"CF_fnc_removeactionMP",true,true] call BIS_fnc_MP;    // removes the "place charge" action

player playmove "AinvPknlMstpSnonWnonDnon_medic_1";
sleep 5;

	[[cargoBox1,"Disarm Charge","disarm.sqf"],"CF_fnc_addactionMP",true,true] call BIS_fnc_MP;    // adds the "disarm charge" action


and finally the script run by the "disarm charge" action:

_object = _this select 0;
_caller = _this select 1;
_id = _this select 2;		// ID of the action to be removed

[[cargoBox1,_id],"CF_fnc_removeactionMP",true,true] call BIS_fnc_MP;    // removes the "disarm charge" action

player playmove "AinvPknlMstpSnonWnonDnon_medic_1";
sleep 5;

[[cargoBox1,"Place Charge","charge.sqf"],"CF_fnc_addactionMP",true,true] call BIS_fnc_MP;    // adds the "place charge" action again

Edited by clydefrog

Share this post


Link to post
Share on other sites
  • Added: BIS_fnc_MP now supports scripting commands, not only functions
  • Examples:
  • [nil,"saveGame",false] call bis_fnc_mp;
  • ["Hello World","hint"] call bis_fnc_mp;
  • [[myObject,42],"setDir",myObject] call bis_fnc_mp;
  • Added: BIS_fnc_MP can now remotely execute only scripting commands defined in CfgRemoteExecCommands

why revive such an old thread D:

so basically you can ditch all the cfgFunctions and just do in your script this

_object = _this select 0;
_caller = _this select 1;
_id = _this select 2;		// ID of the action to be removed

[[cargoBox1,_id],"removeAction",true,true] call BIS_fnc_MP;    // removes the "disarm charge" action

player playmove "AinvPknlMstpSnonWnonDnon_medic_1";
sleep 5;

[[cargoBox1,["Place Charge","charge.sqf"]],"addAction",true,true] call BIS_fnc_MP;    // adds the "place charge" action again

Share this post


Link to post
Share on other sites

Because my post is "directly related to this discussion" and it's one I've posted in before, I thought it's not worth starting a new thread for it when I can post in this one.

Thanks for that I'll give it a try, can you still use the addAction conditions etc. though if you do it that way? How would I have it so I was using cargobox1 and the charge.sqf script, and then the extra parameters e.g.

[], 0, false, false, "", "_this distance _target < 4"

and also changing the colour of the text?

edit: I get an error when trying to pass more arguments, and it says it must be 0, 1 or 2. It actually says even 3 arguments is too many, so how am I supposed to specify the object for the action to be added to, the action text and the script to be run?

Edited by clydefrog

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  

×