OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: ModestNovice on 05 Aug 2008, 00:10:31

Title: Saving an Array on the Server
Post by: ModestNovice on 05 Aug 2008, 00:10:31
Hello  :)

How would I go about saving an array to the server. So I can access it again when I reconnect?

Thanks

-DaChevs


EDIT:
Okay, since no one post, I will elaborate.

I can get an array on the server.

Code: [Select]
if (local server) then {my_array = my_array + [something]};
but now, is empty for players, but has something in it for the server.

So now how do I get that something from the array, if it hasn't been added on the client?
Title: Re: Saving an Array on the Server
Post by: Spooner on 05 Aug 2008, 01:22:13
Right. First thing is that using (local server) has been obsolete for a long time. Just use isServer, which doesn't require you to mess about with a GameLogic at all.

Just use publicVariable to broadcast the new value of the array to everyone (this will be synced on JIP, so no trouble there):
Code: [Select]
if (isServer) then
{
    my_array = my_array + [something]
    publicVariable "my_array";
};
Title: Re: Saving an Array on the Server
Post by: ModestNovice on 05 Aug 2008, 01:44:48
ahhh great to know.

Thanks for the help Spooner.  :good:

now by synced on JIP, what do you mean?

So will what was placed on the server on my computer. Be the same when i get it from the public variable? Or will everyone get the same thing? If everyone gets the same, is there a way around that?

Maybe since its an array. using the same array name for everyone, and making a variable with the players name in it? So when they rejoin it will find there variable?
Title: Re: Saving an Array on the Server
Post by: Spooner on 05 Aug 2008, 12:39:55
When something is publicVariabled, then it is updated on everyone's machine, including the server. When a new client JIPs, then the server will send them the last value that was publicVariabled (i.e. the value is synchronised on JIP).

You can't make a variable with the player's name in it, since player names aren't valid variable names ("[RGG] Spooner" is a valid name, but not a valid variable name). You could have an array arranged like this, though:
Code: [Select]
[ ["[RGG] Spooner", 27], ["*FFF* Trotsky", 45], ["Frodo97", 4555]]
Then you'd need to search through it to find the value associated with each individual player.
Title: Re: Saving an Array on the Server
Post by: ModestNovice on 05 Aug 2008, 19:33:42
ok thanks.

I'll try with this.

Thanks for note about publicVariable too. I have been having problems with time synched between players. If someone join after map started, then its night for them, and day for everyone who started map.