Jump to content
Sign in to follow this  
barmyarmy

JIP and init.sqf

Recommended Posts

Most of us are aware of the standard trick of placing a game logic called server onto the map, and then running the following statements;

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (local server) then { .. init server };

if (local player) then { .. init player };

This works fine for players present when the mission starts - detecting/identifying and initialising JIP clients has been a major bug bear. I've rried triggers, map-objects which call runInitScript from the init-strings, publicVariables...

And then I discovered this works wonderfully. The trick is that for JIP-clients not only is server non-local but for some bizarre reason player is NULL. ( If this is a bug I hope BIS leave it in...)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

execVM "init_common.sqf";

if ( local server ) then {

_InitState="SERVER";

if ( isnull player ) then {

_InitState="MP-SERVER";

} else {

_InitState="SP-SERVER+CLIENT/EDITOR";

[] execVM "init_client.sqf";

};

[] execVM "init_server.sqf";

} else {

_InitState="CLIENT";

if ( isnull player ) then {

// no server and no client - we must be JIP

_InitState="JIP";

[] execVM "init_jip.sqf";

} else {

_InitState="MP-CLIENT";

[] execVM "init_client.sqf";

};

};

I've set it so that there are separate script for initialising on server,clients, and JIP. Obviously either of init_jip or init_client scripts can invoke the other if necessary.

init.common is always called.

Share this post


Link to post
Share on other sites

looks like a nice find. I've been using (time > 0) to detect JIP players.

Share this post


Link to post
Share on other sites

Out of interest, if player is null, does that mean that commands like side player do not work correctly with JIP clients?

Share this post


Link to post
Share on other sites
Out of interest, if player is null, does that mean that commands like side player do not work correctly with JIP clients?

Yeah, the first lines of init_jip.sqf read:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

while {( isnull player )} do {

sleep 0.5;

};

very often after that I just call init_client.sqf

But its nice too see someone was paying attention... wink_o.gif

Share this post


Link to post
Share on other sites
Quote[/b] ]Out of interest, if player is null, does that mean that commands like side player do not work correctly with JIP clients?

You'll always have to be a little bit more cautious with the side command. As pointed out above it seems to be null at the very start, and furthermore it's civilian if the player is currently dead. Just wanted to point that one out in case you're using it in non-init scripts.

Quote[/b] ]<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">while {( isnull player )} do {

sleep 0.5;

};

I'm not quite sure, but player might always be null for dedicated servers. Perhaps you might want to tweak that one a bit. Not that it's a significant performance drain, but suspending unneeded scripts/triggers is always a good idea IMHO ;-)

Furthermore, you might want to add your knowledge to the Biki. But iirc it's already noted somewhere in the player article.

Share this post


Link to post
Share on other sites

Personally I'm very new to ArmA scripting...

Having almost gotten used to the whole "lost in the woods" feeling, I atleast try to leave the a breadcrumb or two for everyone else when I find one!

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  

×