barmyarmy 0 Posted May 9, 2007 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
fasad 1 Posted May 10, 2007 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
fer 21 Posted May 10, 2007 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
vipermaul 246 Posted May 10, 2007 No I think the player is only null at the very start. Share this post Link to post Share on other sites
barmyarmy 0 Posted May 10, 2007 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... Share this post Link to post Share on other sites
GefrManny 0 Posted May 11, 2007 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
barmyarmy 0 Posted May 12, 2007 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