rimblock 0 Posted March 19, 2015 Hi, So I have a unit that is created on the server, passed to the client (setownergroup) and the player is put in to the unit. The unit is then placed at a specific location (setpos). So far, all good. Now, The server is also running a script to monitor the position of all playable units that are players (currently only this one player) but using getpos (or getposATL etc) only seems to be returning the original setpos position of the unit. getdir is also only returning 0. Any ideas why that would be ?. Code to get position run on the server. private ["_scriptname","_allPlayers","_charLocation","_playerCharacterID","_charData","_playerDirection","_playerLocation","_locationsDontMatch","_charLocSave","_lastLocation","_locationElement","_oldLocationElement"]; _scriptname = __FILE__; diag_log format["[%1] Started.", _scriptname]; waitUntil {var_g_serverInitComplete}; diag_log format["[%1] Server load complete.", _scriptname]; // Sleep to give a chance for players to join. diag_log format["[%1] Pause %2 seconds to allow player to connect.", _scriptname, var_s_playerMonitorWait]; uisleep var_s_playerMonitorWait; diag_log format["[%1] Pause completed.", _scriptname]; While {true} do { { diag_log format["[%1] New cycle started.", _scriptname]; if (isPlayer _x) then { diag_log format["[%1] Playable unit found: %2.", _scriptname, _x]; _playerLocation = [_x] call fnc_g_getpos; _playerDirection = getdir _x; diag_log format["[%1] %2 unit found at %3 facing %4.", _scriptname, _x, _playerLocation, _playerDirection]; }; } forEach playableUnits; diag_log format["[%1] Waiting %2 seconds for next cycle.", _scriptname, var_s_playerMonitorWait]; uisleep var_s_playerMonitorWait; }; Log file output (same output repeats regardless of if I move the player unit). 20:26:23 "[fnc_s_playerMonitor.sqf] New cycle started." 20:26:23 "[fnc_s_playerMonitor.sqf] Playable unit found: R Alpha 2-1:1 (RimBlock) REMOTE." 20:26:23 "[fnc_g_GetPos.sqf] Started." 20:26:23 "[fnc_g_GetPos.sqf] Parameters received: [R Alpha 2-1:1 (RimBlock) REMOTE]." 20:26:23 "[fnc_s_playerMonitor.sqf] R Alpha 2-1:1 (RimBlock) REMOTE unit found at [9023.66,914.016,0] facing 0." 20:26:23 "[fnc_s_playerMonitor.sqf] Waiting 60 seconds for next cycle." Note: fnc_g_getpos just dows a getposASL and then converts if not over water. THe same result occurs with a plain "_playerLocation = getpos _x;" var_s_playerMonitorWait = 60 The map is a custom map not yet publicly released. Running the code in global or local scope in the debug console works fine. Running it under server scope returns nothing for playableunits. Thanks. Share this post Link to post Share on other sites
ussrlongbow 115 Posted March 19, 2015 Have you tried this script on a stock map? same result? Try to call it from initPlayerServer.sqf event script (it will fire for every connecting player and you will have a good referebce to player's unit) https://community.bistudio.com/wiki/Event_Scripts Share this post Link to post Share on other sites
rimblock 0 Posted March 19, 2015 The script is called currently from the servers init.sqf (called from the mission init.sqf). I want it as a single source for tracking players to enable various actions to be performed by the server rather than the clients using PVS calls to tell the server to perform those actions. I may have to put one of the stock maps back in and try it on those. Share this post Link to post Share on other sites
ussrlongbow 115 Posted March 19, 2015 initPlayerServer is executed only on server after init.sqf and after player connects - sounds more reasonable than to query all playable units, no? Share this post Link to post Share on other sites
rimblock 0 Posted March 20, 2015 initPlayerServer is executed only on server after init.sqf and after player connects - sounds more reasonable than to query all playable units, no? Not wishing to stray to far away from the original question but... The server side script I have will be used to perform server side actions on each player at set times (it will be running from server start until the server is stopped). This is one script doing so for all players for the life of the players character(s) until they logoff. If I tried to do the same thing using the initPlayerServer then I could have 80 scripts all running, each tracking only one player. One script checking 80 players seems to be a better solution to me. Now, I could use initPlayerServer, MPKilled, MPRespawn and HandleDisconnect event handlers to manage a server side global array of players for the single, server side, script to monitor rather than the single script using playableUnits and isPlayer to find players units. That may work out more efficient but would need to test it. How to fire the script doesn't answer the question as to why the getpos is not working as expected though. The issue persists on the Straits map as well. I am leaning towards the change unit process prior to this script running being the root cause. 1. When a player logs in they get assigned the 'default unit" by ARMA <-- anyway to not assign a unit until scripts create one and then assign the player to it ??. 2. The unit is then made invisible, enablesimulationGlobal false, made invincible <-- unit remains visible etc for around 2 seconds before being locked in place and switched only for JIP players. Spawns work fine. 3. A new unit is then created on the server and equiped depending on details loaded from the backend DB. 4. The new unit is then passed to the client and the player is moved in to it. 5. The new unit is then enablesimulationGlobal true, made visible and made non-invincible. I am wondering if the enablesimulationGlobal, even though it is set to true, is stopping the server from seeing any client units position updates. I do use a reveal but need to check the code when home to see where. Most of the work is done server side, deliberately. Share this post Link to post Share on other sites
rimblock 0 Posted March 22, 2015 Ok, disabling the enablesimulation false resolved the issue. Unfortunately enableSimulation true seems not to enable the server to get updated location data of objects within a reasonible amount of time (15+ minutes). Share this post Link to post Share on other sites