Home   Help Search Login Register  

Author Topic: Saving an Array on the Server  (Read 1518 times)

0 Members and 1 Guest are viewing this topic.

Offline ModestNovice

  • Members
  • *
Saving an Array on the Server
« 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?
« Last Edit: 05 Aug 2008, 01:16:46 by DaChevs »
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Saving an Array on the Server
« Reply #1 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";
};
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline ModestNovice

  • Members
  • *
Re: Saving an Array on the Server
« Reply #2 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?
« Last Edit: 05 Aug 2008, 01:47:57 by DaChevs »
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Saving an Array on the Server
« Reply #3 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.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline ModestNovice

  • Members
  • *
Re: Saving an Array on the Server
« Reply #4 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.
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley