beta 0 Posted April 15, 2008 So, I have a problem. I need to have a file and a few commands run on any new players (JIP players). I took a look at sickboy's MP scripting wiki page. ( http://community.bistudio.com/wiki/6thSense.eu:EG ) I used the code to determine what type of machine the connection is. I then made a nested if set to run some code depending on the machine type (client, dedi server, etc.). Here is the relevant part of the init.sqf: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> //determine machine type // from sickboy's multiplayer scripting wiki page T_INIT = false; T_Server = false; T_Client = false; T_JIP = false; if (isServer) then { T_Server = true; if (!(isNull player)) then { T_Client = true }; T_INIT = true; } else { T_Client = true; if (isNull player) then { T_JIP = true; [] spawn { waitUntil { !(isNull player) }; T_INIT = true }; } else { T_INIT = true; }; }; //dedicated server if ((T_Server && !T_Client) && T_INIT) then { [] execVM "scripts\main_thread_server.sqf"; } else { //JIP client if (T_JIP && T_INIT) then { setViewDistance param2; [] execVM "scripts\main_thread_client.sqf"; } else { //client if ((T_Client && !T_Server) && T_INIT) then { setViewDistance param2; [] execVM "scripts\main_thread_client.sqf"; } else { //client server if (T_Client && T_INIT) then { [] execVM "scripts\main_thread_server.sqf"; setViewDistance param2; [] execVM "scripts\main_thread_client.sqf"; }; }; }; }; This is what the main_thread_client.sqf file looks like (the server one is blank for now): <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> //Written by beta //Main thread for the client //remove enemy markers if (side player == WEST) then { //player on BLUFOR deleteMarkerLocal "defensive_minefield"; deleteMarkerLocal "defensive_minefield_area1"; deleteMarkerLocal "defensive_minefield_area2"; deleteMarkerLocal "defensive_minefield_area3"; deleteMarkerLocal "defensive_line"; deleteMarkerLocal "hardpoint1"; deleteMarkerLocal "hardpoint2"; deleteMarkerLocal "hardpoint3"; deleteMarkerLocal "hardpoint4"; deleteMarkerLocal "hardpoint5"; deleteMarkerLocal "hardpoint6"; deleteMarkerLocal "hardpoint7"; deleteMarkerLocal "hardpoint8"; deleteMarkerLocal "REDFOR area"; deleteMarkerLocal "REDFOR armour staging area"; deleteMarkerLocal "respawn_east"; } else { //player on REDFOR deleteMarkerLocal "enemy_defenses1"; deleteMarkerLocal "enemy_defenses2"; deleteMarkerLocal "enemy_defenses3"; deleteMarkerLocal "enemy_defenses4"; deleteMarkerLocal "enemy_minefield"; deleteMarkerLocal "enemy_defensive_line"; deleteMarkerLocal "BLUFOR area"; deleteMarkerLocal "BLUFOR staging area"; deleteMarkerLocal "respawn_west"; }; skipTime param1; //set time to param1 sleep 0.5; [] execVM "scripts\spawn_arm.sqf"; //arm the player [] execVM "scripts\player_death.sqf"; //listen for the player's death if (true) exitWith {}; Now, the problem is: It doesn't work. More specifically, the JIP players do not have their time adjusted, nor do they get the proper weapons loadouts (on spawn or respawn), and they have all the markers on their maps. The players who were there from the beginning however DO have all these things. I am sure I've done something wrong, I just can't seem to find what it is. Any help would be MUCH appreciated, as I've been struggling with this for the better part of 3 weeks now. Share this post Link to post Share on other sites
UNN 0 Posted April 15, 2008 This isn't the way I've done it in the past, so I can't say for sure. But your condition to launch the JIP script is this line: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">//JIP client if (T_JIP && T_INIT) then However T_INIT is set to true with this line: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[] spawn { waitUntil { !(isNull player) }; T_INIT = true }; Because that line is executed with a spawn command, there may be some delay in T_INIT being set to true. So T_INIT could still be set to False when it hits your JIP check? If you used this line instead: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">waitUntil {!(isNull player)}; T_INIT = true; Then you can guarantee T_INIT has been set to the correct value before it executes the rest of the script. Not sure that will solve your problem, just something I noticed. Share this post Link to post Share on other sites
Rommel 2 Posted April 15, 2008 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if (isServer) then { [] execVM "scripts\main_thread_server.sqf"; } else { waitUntil {!(isNull player)}; setViewDistance param2; [] execVM "scripts\main_thread_client.sqf"; }; Surely that works, with JIP secure aswell, however your main_thread_client.sqf is flawed, it doesn't allow for timepassed? Share this post Link to post Share on other sites
sickboy 13 Posted April 15, 2008 waitUntil {T_INIT}; Â would simply suffice Share this post Link to post Share on other sites
beta 0 Posted April 15, 2008 Thanks for the replies. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">waitUntil {!(isNull player)}; T_INIT = true; I'll give this a try, I wasn't completely clear on why it was in a spawned function either. Quote[/b] ]... however your main_thread_client.sqf is flawed, it doesn't allow for timepassed? I was under the impression that time passed since the mission has started was something that was automatically synced at the mission start, as explained here. So, <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if (isServer) then { [] execVM "scripts\main_thread_server.sqf"; } else { waitUntil {T_INIT}; setViewDistance param2; [] execVM "scripts\main_thread_client.sqf"; }; should run the needed scripts on all players (JIP or otherwise)? I'll try it out. Thanks again! Share this post Link to post Share on other sites
Rommel 2 Posted April 15, 2008 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if (isServer) then { [] execVM "scripts\main_thread_server.sqf"; } else { waitUntil {!(isNull player)}; setViewDistance param2; [] execVM "scripts\main_thread_client.sqf"; }; T_INIT isn't defined in the one I wrote, Sickboy was simply stating what you could do to fix the code you were using. And yes, sorry your right timepassed is synced on join, it just doesn't sync the actual time , hence the skipTime. Share this post Link to post Share on other sites
beta 0 Posted April 15, 2008 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if (isServer) then { [] execVM "scripts\main_thread_server.sqf"; } else { waitUntil {!(isNull player)}; setViewDistance param2; [] execVM "scripts\main_thread_client.sqf"; }; One question about the code you posted: What about client-servers? From my understanding, the client-server would not run any of the client scripts. Would adding a check to see if the server is also a player work? Such as <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if (isServer) then { [] execVM "scripts\main_thread_server.sqf"; if (!(isNull player)) then { setViewDistance param2; [] execVM "scripts\main_thread_client.sqf"; }; } else { waitUntil {!(isNull player)}; setViewDistance param2; [] execVM "scripts\main_thread_client.sqf"; }; I would like this mission to be able to be run (properly) on as many configurations as possible. Thanks again for the help, still trying to wrap my head around this network scripting Share this post Link to post Share on other sites
Rommel 2 Posted April 16, 2008 Yeh mate that will work, I just wasn't sure what was in main_thread_server.sqf, and you seem to understand how it all works now. Share this post Link to post Share on other sites
beta 0 Posted April 17, 2008 Thanks for all the help guys! Looks like its working now, thanks again! Share this post Link to post Share on other sites