Jump to content

Recommended Posts

Hello. I have a function, let's just call it add_addaction. Then I have another function, which is just Retriever.
The Retriever finds a city, spawns civilians and cars. For each civilian spawned, the following command is used :

[_unit] remoteExecCall ["JeyR_fnc_retrieve_addaction",0,true];

The add_addaction currently doesn't do anything special, just adds an action to the unit saying "helo". This works fine. However, for JIP players, the action is not showing up. I tried to fix the problem via this piece:

class CfgFunctions 
{
	class JeyR 
    {
        class Jey_public 
        {
            class retrieve {
                file = "functions\retrieve.sqf";        
                preInit = 1;    
            };
            class retrieve_addaction {
                file = "functions\retrieve_helper.sqf";        
                preInit = 1;    
            };           
        };
    };
};

And to avoid the scripts to give any errors (because the add_addaction requires an object/unit, it gives you an error that it couldn't find the unit to add the action), I put this command to the top of the scripts :

	_asd = missionNamespace getVariable ["running_task",0];
	if (_asd == 1) then 
{
/* The other parts of the script */
}

Now even the not JIP players can't see the add action, but the RPT log doesn't give any errors. I am totally out of ideas.
How does the functions library work?

Share this post


Link to post
Share on other sites

just create the initPlayerLocal.sqf which is an event script ready to work for any player, JIP or not.

then inside:
 

my_function = {
 player addAction ["hello", {hint "hello"}];
};

call my_function;
player addEventHandler ["respawn", {call my_function; removeAllActions (_this select 1) }];

 

Displaying the addAction or not: it's far better to use the condition parameter (8th) inside the addAction itself.

Share this post


Link to post
Share on other sites

Remove the preInit. And I would remove the part you added to the top of your script (this is the part that made it not working for everybody?). Instead just check in your script whether the argument is null or not.

Share this post


Link to post
Share on other sites

if I remove the preinit, will it initialize before the remoteexec triggers? And btw, i tried with isnil, and it give me an error like : expected string,code,etc, got: object.

Share this post


Link to post
Share on other sites

The preInit runs the file. You want to compile the file so that is is ready for execution as a function. So there is no need for preInit.

 

Tried what with isNil? My suggestion is, at the top of the script where you have something like:

params ["_unit"];

if (isNull _unit) exitWith {};

//... rest below, e.g. add action to _unit

 

6 minutes ago, JeyR said:

will it initialize before the remoteexec triggers?

I would expect it to. Because otherwise the whole scheme is basically useless. But ultimately the whole JIP part of remote execution is under documented, and nowhere, (I have found at least), it is clarified when JIP invocations occur.

Share this post


Link to post
Share on other sites

So you are saying that without preinit, the script just gets compiled and not run? That's perfect.

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

×