ATGSS 0 Posted January 26, 2020 Hi, i am looking for save the last position and gear before disconnect .(DC or CRASH) I tried this and work , but only save the last position, the gear not working. I tried more script from the forums, but nothing work, Can anyone help me pls? Tanks you very much!!! Init.sqf [] execVM "PlayerEvents.sqf"; PlayerEvents.sqf TAG_fnc_loadClientData = { _this params ["_loadoutStr", "_positionASL", "_dir"]; call compile _loadoutStr; player setDir _dir; player setPosASL _positionASL; }; if(isServer) then { addMissionEventHandler [ "HandleDisconnect", { params ["_body", "_id", "_uid", "_name"]; if(!isNull _body) then { //Init storage var if(isNil "TAG_disconnectedLoadouts") then { TAG_disconnectedLoadouts = []; }; //Save loadout as script for easy broadcast private _loadoutStr = [player, "script", false] call BIS_fnc_exportInventory; { private _index = _loadoutStr find _x; if(_index > -1) then { private _strArray = toArray _loadoutStr; _strArray deleteRange [_index, count _x]; _loadoutStr = toString _strArray; }; } forEach ["// Remove existing items","// Add containers","// Add weapons", "// Add items", "// Set identity"]; //Find in storage private _uidIndex = TAG_disconnectedLoadouts find _uid; if(_uidIndex > -1) then { //Found -> update private _loadoutIndex = _uidIndex + 1; TAG_disconnectedLoadouts set [_loadoutIndex, _loadoutStr]; } else { //Not found -> Add new TAG_disconnectedLoadouts pushBack _uid; TAG_disconnectedLoadouts pushBack [_loadoutStr, getPosASL _body, getDir _body]; }; }; false } ]; addMissionEventHandler [ "PlayerConnected", { params ["_id", "_uid", "_name", "_jip", "_owner"]; if(_jip) then { private _clientData = missionNamespace getVariable ["TAG_disconnectedLoadouts", []]; private _uidIndex = _clientData find _uid; if(_uidIndex > -1) then { private _loadoutIndex = _uidIndex + 1; (_clientData select _loadoutIndex) remoteExec ["TAG_fnc_loadClientData", _owner]; }; }; } ]; }; Share this post Link to post Share on other sites
Piloto_Spyke 14 Posted March 21, 2020 (edited) hi, I think there is no way to get variables or loadouts remaining after the mission has been terminated / canceled / aborted. The code you show works as long as the mission doesn't finish. Edit: I found this, maybe it works for you:profileNamespace --> To save it to the serversaveProfileNamespace --> To make the data remain? I have never used them so I cannot help you much in how they work. Spyke. Edited March 21, 2020 by Piloto_Spyke Correction Share this post Link to post Share on other sites
Piloto_Spyke 14 Posted March 21, 2020 Hi, maybe this could be useful.init.sqf [] execVM "initSaveLoadouts.sqf"; initSaveLoadouts.sqf diag_log "initSaveLoadouts.sqf"; SPK_fnc_applyClient = { params ["_loadout", "_positionASL", "_dir"]; player setUnitLoadout _loadout; player setDir _dir; player setPosASL _positionASL; diag_log "(ClientData Load in client)"; }; SPK_fnc_resetClientData = { params["_uid"]; profileNamespace setVariable [format["Name_%1",_uid], nil]; profileNamespace setVariable [format["Loadout_%1",_uid], nil]; profileNamespace setVariable [format["Position_%1",_uid], nil]; profileNamespace setVariable [format["Direction_%1",_uid], nil]; }; SPK_fnc_saveClientData = { params["_unit","_uid","_name"]; profileNamespace setVariable [format["Name_%1",_uid], _name]; profileNamespace setVariable [format["Loadout_%1",_uid], getUnitLoadout _unit]; profileNamespace setVariable [format["Position_%1",_uid], getPos _unit]; profileNamespace setVariable [format["Direction_%1",_uid], getDir _unit]; saveprofileNamespace; diag_log format ["(ClientData Save) - ID: %1 | Name: %2 | Saved",_uid, _name]; }; SPK_fnc_loadClientData = { params["_uid","_name"]; _nameId = profileNamespace getVariable [format["Name_%1",_uid], ""]; _loadout = profileNamespace getVariable [format["Loadout_%1",_uid], []]; _position = profileNamespace getVariable [format["Position_%1",_uid], [0,0,0]]; _direction = profileNamespace getVariable [format["Direction_%1",_uid], 0]; diag_log format ["(ClientData Load) - ID: %1 | Name: %2 | Loaded",_uid, _name]; [_nameId,_loadout,_position,_direction] }; // Si esto se ejecuta en un servidor ... if(isServer) then { addMissionEventHandler [ "HandleDisconnect", { params ["_unit", "_id", "_uid", "_name"]; // Si la unidad existe ... if(!isNull _unit) then { // Guardamos la información del cliente [_unit,_uid,_name] spawn SPK_fnc_saveClientData; }; false } ]; addMissionEventHandler [ "PlayerConnected", { params ["_id", "_uid", "_name", "_jip", "_owner"]; // Si es un jugador en Join In Progres (JIP) ... if(_jip) then { // Cargamos la información que hemos guardado del cliente _loaded = [_uid,_name] spawn SPK_fnc_loadClientData; _loaded params ["_nameId","_loadout","_position","_direction"]; // Si no tenemos nada guardado de este cliente, no hacemos nada (EXIT). if(_nameId == "")exitWith{diag_log format ["Player %1 - Without saved data",_name]}; // Aplicamos el loadout, posición y dirección al jugador [_loadout,_position,_direction] remoteExec ["SPK_fnc_applyClient", _owner]; }; } ]; }; CONCLUSION after trying it: If you want to save variables: - It cannot be saved on the server unless a database is used. - They must be saved in the player's own profile with the profileNamespace or saveProfileNamespace commands. Therefore the scrip that I have put above does not serve to save remanent data. Spyke Share this post Link to post Share on other sites