Jump to content
Sign in to follow this  
Svirdigor

onPlayerDisconnected - receive the list of the weapon

Recommended Posts

How in network mission at disconnection of the player from the server to receive the list of the weapon which it had?

Share this post


Link to post
Share on other sites

not sure, but by that time it is probably not possible to obtain that list.

What i would suggest is to keep track of unit loadout every time said unit accesses a weapon crate, and maintain a global variable with that information on a per player basis (uid).

Share this post


Link to post
Share on other sites

Its posible, you must search for the player on the allunits( or playable units but sometimes fails) by his name(the ondisconected event only gives you the name, UID and ID, this last i dont know what can be used for), and then get his weapons. I have done it on my revive script to save the status of someone who disconect so its posible. You can look at how i had done it, but its just a loop( normally a foreach) to search for the player by his name.

I would never recomend you to save the weapons on a global variable, unless its going to be a mission for 1-4 players. If you try to save the weapons of 20+ units on one or more globalvariables you will have desync problems.

Edited by columdrum

Share this post


Link to post
Share on other sites

Something like the following should do it:

init.sqf

onPlayerDisconnected { [_id, _name, _uid] call compile preprocessfilelinenumbers "playerDisconnected.sqf" };

playerDisconnected.sqf

_id = _this select 0; 
_pname = _this select 1; 
_puid  = _this select 2;


call saveOnQuit;

saveOnQuit = {	
if (_pname != "__SERVER__") then {

	_player = objNull;
	 {
		if (getPlayerUID _x == _puid) exitWith { _player = _x; };
	 } 
	forEach playableUnits; 

		if !(isNull _player) then {	
		    _thisweapons = str(weapons _player);
		    _thismagazines = str(magazines _player);
	        };
};
};

Edited by [KH]Jman

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×