Jump to content
gc8

Remote function readiness

Recommended Posts

Hi

I should probably know this by now after all working with few MP missions but I am unsure how to deal with function readiness when it comes to remoteExecCall

 

For example I can have function defined in init.sqf for client ("TestFn") and then server calling that function from init.sqf. This actually only seems to work when JIPing. And if I put any sleep before declaring the test function  ("TestFn") then by the time server tries to call that function it wont be ready (non-existent). So maybe lag (on client) can cause function to not be ready?

 

So I'm thinking I should put all these client functions that the server calls at startup to some preinit file

 

Test code:

targetClients =
{
 ([0,-2] select isdedicated)
};

if(isServer) then
{
 remoteExecCall ["testFn",call targetClients,true];
};



if(hasinterface) then
{

// sleep 5;
testFn =
{
 diag_log "<<< TEST FN CALLED! 123 >>>";
};
};

 

what do you guys think is the best way to setup your loading/remote calling?

 

thx!

Share this post


Link to post
Share on other sites

Yes put it in some preinit file, either CfgFunctions - or just a single script that runs at preinit - to define the needed functions.

 

I would not think of these issues in terms of latency (lag) or time (sleep). Instead think of it based on ordering - what (needs to) happen before something else? It is also the reason I see no need for all these other event scripts initPlayerLocal initPlayerServer, initServer and just use init.sqf; then I don't have to worry about any ordering issues between commands in those files.

  • Thanks 1

Share this post


Link to post
Share on other sites
4 hours ago, gc8 said:

I should probably know this by now

4 hours ago, gc8 said:

So I'm thinking I should put all these client functions that the server calls at startup to some preinit file

You should yes. Use the function library as that is what it is there for, then your functions are compiled and ready before any of the event scripts are called( init, intServer, initPlayerLocal etc )

Functions Library

 

  • Thanks 1

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

×