Jump to content
Sign in to follow this  
Norbak

Load the same variables for a concrete player when disconnected and connected again.

Recommended Posts

Anyone know how to save some variable for a specific player before logging out from a multiplayer mission and load the same when connecting again?. The same variables assigned for a specific player. It could be something like this?:

 

 

  • Variable1 = player setVariable ["Car",1,false];
  • Variable1 setVariable ["ownerUid", getPlayerUID player, True];    PublicVariableServer "Variable1";

 

It'd be nice if the variable1 is different for a player than other. So Variable1 [Car]  is "1" for player1 ,but it's "0" for player2, and so.

 

Any idea to load those stats like an inventory in DayZ but in Arma 2 using variables?. Thanks!

Share this post


Link to post
Share on other sites

On the server at game start, create an array for storing player data when they disconnect.
 

JoinedPlayersData = [];

As players disconnect, have onPlayerDisconnected run code to store their information as an array within the array.
 

// After three players disconnected
JoinedPlayersData = [[_uid,_name,_funds1,_property1],[_uid,_name,_funds2,_property2],[_uid,_name,_funds3,_property3]];
As players join, have onPlayerConnected run code to check whether the uid in one of the arrays is a match.
 
If no match, it's a new player and they don't get assigned values from the array.
 
If one matches, they have rejoined.  Assign the values from the matching array to the player.   Then remove the matching array from the list:
// After player #2 has reconnected
JoinedPlayersData = [[_uid,_name,_funds1,_property1],[_uid,_name,_funds3,_property3]];

When they disconnect (again), onPlayerDisconnected stores their information in the array (again).

// After player #2 disconnected again
JoinedPlayersData = [[_uid,_name,_funds1,_property1],[_uid,_name,_funds3,_property3],[_uid,_name,_funds2,_property2]];

Share this post


Link to post
Share on other sites

No idea what that means. Im sorry. I know to use Onplayerdisconnected but not in that way. It's more advanced than what i know

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  

×