fn_Quiksilver 1636 Posted January 16, 2015 (edited) Any ideas guys? I have seen some workarounds but I find they are unstable since the 1.32 update which changes some ways a client disconnects. This results in situations where the workaround fails when a client quickly disconnects and reconnects. Such workarounds as looping through playableUnits and passing name/uid through it. Looking for a good clean solution. onPlayerConnected provides us 3 default vars: _id _uid _name When I join a session this produces something like: ************ ID - 1.23289e+009 *********** UID - 76599430343034104 *********** Name - Quiksilver ************" onPlayerConnected {diag_log format ["************ ID - %1 *********** UID - %2 *********** NAME - %3 ************",_id,_uid,_name];} So how are we to cleanly derive a player object from this or derivative vars? Does _id have any use at all? I have seen attempts using: _player = objectFromNetId (_this select 0); https://community.bistudio.com/wiki/objectFromNetId https://community.bistudio.com/wiki/netId http://killzonekid.com/arma-scripting-tutorials-get_friends-check_player-logic/ However netId looks more like: "2:1308" than "1.23289e+009" hint str netID player; // "2:1308" hint str (objectFromNetID "2:1308"); // B Alpha 1-1:1 (Quiksilver) hint str player // s19 Edited January 16, 2015 by MDCCLXXVI Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted January 16, 2015 (edited) How about you waitUntil {!isNull player && {player == player}} and then pushBack the player into a global array which you then publicVariableServer? Of course you'd still need to manage to take that player from that array again as soon as he disconnects, but I'm wondering if that would fit your needs at all. Edited January 16, 2015 by Heeeere's Johnny! Share this post Link to post Share on other sites
Linker Split 0 Posted January 16, 2015 If I understand it right, you are trying to spawn a player in an MP environment with given id, UID and name, but you don't know how to do this? Share this post Link to post Share on other sites
dreadedentity 278 Posted January 17, 2015 (edited) I'm not sure there is a clean solution, I believe the objectFromNetID command became useless after gamespy shut down. Something like this might work though: getUnitFromName = { _temp = ""; { _temp = _x; if (isPlayer && {name _x == _this}) exitWith {_temp}; }forEach playableUnits; _temp; }; onPlayerConnected.sqf (or function) _object = _name call getUnitFromName; Edited January 17, 2015 by DreadedEntity Share this post Link to post Share on other sites
fn_Quiksilver 1636 Posted January 17, 2015 Hmm ... Yea, onPlayerConnected appears to have limited effectiveness if we cannot easily get the player object. Cycling through playableUnits works most of the time, but can be unstable, particularly if a player exits to lobby and reconnects very quickly. For things that have to work every time, that isn't suitable. The only way I have found to increase the stability is to use handleDisconnect to immediately delete the old player object when a player disconnects, although this can cause other issues downstream, and I don't necessarily want a players body and ground weapon holder to disappear the moment he DCs. ---------- Post added at 12:32 ---------- Previous post was at 12:30 ---------- If I understand it right, you are trying to spawn a player in an MP environment with given id, UID and name, but you don't know how to do this? Simply trying to return the player object when the player joins. At the moment the only clean method I have for this is via 'initPlayerServer.sqf' Share this post Link to post Share on other sites
samatra 85 Posted January 17, 2015 (edited) onPlayerConnected's _id is dpnid which is not the same as network identity's playerid that owner command returns. Host's dpnid is always 2 which is equal to server's playerid being 2 but these are two completely different entities. Basically onPlayerConnected's _id is useless and was always useless since its introduction, you can't do anything with it script-wise. (Correction, the only scripted way to use dpnid from onPlayerConnected's _id is https://community.bistudio.com/wiki/allMapMarkers command where user-defined markers use dpnid in marker name) Cycling through playableUnits\allUnits is bad approach because these arrays are generated from groups, which get bugged over time in MP and exclude some units and players as well as never include dead units so if player is in respawn they will not be in array. Personally I use scripted approach to solve this issue, whenever player finishes loading (player == player) or respawns ("Respawn" EH), I send a public variable onto server and update their actual unit deleting old record by comparing UID with server array, same when they leave, onPlayerDisconnected walks through array and deletes the record by uid of player that left. Each time script walks through array it also removes units that are not alive (either null or really dead), so quick leaving to lobby and joining back still maintains proper array of player units. This way you can manage precise array of player units on server as well as to send them to clients in public variable. Edited January 17, 2015 by SaMatra Share this post Link to post Share on other sites