Jump to content
Sign in to follow this  
Vardym

Save variables server-side with JIP?

Recommended Posts

Hi all!

I'm excited to begin scripting in Armed Assault. With the new Join in Progress, and continuous server features, I feel like we're way less limited. I'm not very good at scripting, and I do have a few questions. I am very sorry if these have been asked before. I've found some information on some of these, but I just don't get it.

1. I am trying to add money to my game. I've been thinking about describing a private variable in an initialization script, say "Personalmoney", that I want to start out as 0. Each soldier runs the same script, call it soldierinit.sqs. Could I say

Private personalmoney = 0 ?

If I did, and made Personalmoney = 5 for player 1, and Personalmoney = 10 for player 2, would Arma see that as 2 seperate variables? If so, in a seperate script, say buycar.sqs, how would I make sure that if Player1 is executing buycar.sqs, it executes it with his personalmoney? [this] exec buycar.sqs? That's always been a bit confusing to me.

2. Dialogs are also a bit confusing. I'm using the wonderful, but bit archaic dialog maker: "OPERATION FLASHPOINT DIALOG MAKER". It works pretty well after changing font names. I'm just receiving a few errors with my working dialogs that I don't know how to avoid. Here is a copy of a dialog example from my description.ext file:

class BuyCar : RscButton

{

x = 0.35625

y = 0.24704

idc = -1

w = 0.2

h = 0.03004

style = ST_CENTER

colorBackground[] = {0, 0, 0, 0};

colorText[] = {0, 0, 0, 1};

font = "TahomaB"

SizeEX = 0.025

text = "Buy Car"

action = "[Car1] exec ""PurchaseCars.sqs""";

default = false

};

When running the overall dialog, I get the following error:

No entry: ....Buycar.colorDisabled

So I added:colorDisabled[] = {0.3, 0.3, 0.3, 1};

That gets rid of that error, but a bunch of other noentry errors come up:

No entry: ... Buycar.BackgroundActive

So I added: colorBackgroundActive[] = {0, 0, 0, 0};

... To make a long story short, these errors continued.. I am wondering if there is a way to let Arma use default values, or let it know that default values are okay.

3. With the persistent server, I wanted to make variables save themselves. Is this a server side thing? I wanted to use the new saveVar thing on the BIS wiki. For example.. Could I have "OnPlayerDisconnected........... saveVar Player PersonalMoney" or something? And then "OnPlayerconnected.... loadVar Player PersonalMoney"? I know it'd be quite more complicated than that, but I can try to find more about that out myself after learning if such a thing is even possible so that the server can save specific variables and recall them for specific/unique players.

If this scripting language is as powerful as I think it is.. We're in for a lot of really cool Arma maps in the upcoming years...

Share this post


Link to post
Share on other sites

1. & 3. I think there is a way to add ID dependent variables to an Object (like a server logic). serverlogic setvariable [playerID,"###"];

#### being the money count

2. From Mapfact.net:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">//Standard button.

class RscButton

{

// common control items

access = ReadAndWrite;

type = CT_BUTTON;

style = ST_LEFT;

x = 0;

y = 0;

w = 0.3;

h = 0.1;

// text properties

text = "";

font = FontMAIN;

sizeEx = Size_Text_Default;

colorText[] = Color_Black;

colorDisabled[] = Color_Gray;

// background properties

colorBackground[] = Color_GrayLight;

colorBackgroundDisabled[] = Color_GrayLight;

colorBackgroundActive[] = {0.84,1,0.55,1};

offsetX = 0.004; // distance of background from shadow

offsetY = 0.004;

offsetPressedX = 0.002; // distance of background from shadow when button is pressed

offsetPressedY = 0.002;

colorFocused[] = Color_Black; // color of the rectangle around background when focused

You need every entry

Share this post


Link to post
Share on other sites

Ah yeah this also.

Please search for an older thread dealing with dialogs. I remember that there was another one with that problem.

Share this post


Link to post
Share on other sites
Quote[/b] ]If I did, and made Personalmoney = 5 for player 1, and Personalmoney = 10 for player 2, would Arma see that as 2 seperate variables?

Each client would treat them as seperate variables. But if you tried to broadcast them to the server or other clients, then they would overwrite each other.

Quote[/b] ]3. With the persistent server, I wanted to make variables save themselves. Is this a server side thing? I wanted to use the new saveVar thing on the BIS wiki. For example.. Could I have "OnPlayerDisconnected........... saveVar Player PersonalMoney" or something? And then "OnPlayerconnected.... loadVar Player PersonalMoney"? I know it'd be quite more complicated than that, but I can try to find more about that out myself after learning if such a thing is even possible so that the server can save specific variables and recall them for specific/unique players.

Not possoble without using an external program, unless you intend to keep the server running. As soon as you shut it down, you will loose your variables.

See this thread:

Data Storage

Share this post


Link to post
Share on other sites

Well, i have to say one thing only in the concept you wanting to 'save' some info when a player is disconnecting, and again reconnecting.

Still in development (is one of the final piece of scripts) so i can't give some 'real' examples.

I wrote in papers this concept.

Declare an array per 'army' (side?) where you will be putting inside names of players, just as

BLUFORdogs = ["Serclaes","UNN","Wardym","LynxEye"...]

How to get these names?

In a 'Init.sqs' oriented way, you will declare another script to process some instances just to publicvariable this text:

"ROOKIE"

And the next PublicVariable, your name.

So, the server can 'catch' it under global variables, checking if already existing, and then, the server publishing (as example) the word "DONE", so, the scripts you (as a player) running, will wait always for some 'special words' or just like your new ArmA commands, just these new commands for Communications.

Well... even in the case that 60 players is connecting JUST IN THE SAME MICROSECOND... the server script have to detect only 2 at time, not those 60 players, then the server will publicvariable the word "WAIT". Then all those 60 players will start a random timer (just less than 500 mS (or the number that we consider the baddest ping), to allow again, all players 'trying' to request 'attention of the server'.

If no more publicvariables at same time, then each player will send that 'rookie' status, his name, and a few more.

Then, your script, will never more send your name, while inside the server (playing i hope!wink_o.gif and the server, will add it to the BLUFORdogs array.

Then, if you disconnecting, nothing it will occur, just you, out of the server, and if you disconnecting before server restarting or closing, you will run again that "Init.sqs", and again that script, and again "ROOKIE", and again your name... and again the server checking if your name in the VIP array... and... wait a moment, that array is still remembering you... right?

Of course, all the people here knowing how long can be a mission (i played more than one time some missions during 3 hours...  crazy_o.gif ) and then... how long can be that BLUFORdogs? no matter, but... each time a new player being added to the array, probably, when server having to check it, each time the server will spend a few few few few few... a few more time to reach the final position. Keep on mind too.

Well, not only the name of a player can be remembered in an array... or more arrays...his 'money', the name of his girlfriend... etc etc etc

'catching' the concept?

I hope, this system not too resource-eater is. At least, i didnt designed it to lower servers and players CPU's.

So basically, the concept is what i call: making a WARnet.

It's just one piece of the scripts being ran by players, is like modems doing, and the server , like your neighbour, yeah, put him another modem... neighbours... pistols.gif

So, the concept is more or less good... if not making so complicated 'modems'.

One way i noticed too, is like make certain 'not-known-yet' variables only related to vehicles... with

http://community.bistudio.com/wiki/setVariable

I did it in that form to keep special ammo from special weapons from certain vehicles.

That command can be helpful sometimes with still-not-known variables with some info from vehicles.

Just all vehicles has to be a name (or at least, those vehicles you interested in).

Of course, you will need more commands-based-scripts to ensure you are doing one of your bests efforts in this kind of 'modems'.

Well, maybe i have old info about publicvariable about wich kind of variables you can publish (string,structured text,array, number... etc).

One method that i tried (only in 'papers', not tested yet) is about numbers.

Think on this:

In your client-scripts, you have some arrays with some info.

In the server-scripts, you have another arrays that is matching his size with the arrays of clients.

How to publish some different variables in only one Publicvariable?

I thinked that, if array was possible, it can cause lack of bandwitdh in the server, and then, in 'clients'.

So... you can collect 'fixed' info of that arrays, converting it to 'numbers'. I think that ArmA can publish 'numbers' in a faster way than 'strings' as example (maybe i'm in a very big mistake).

Then if this last is true, how can convert array content as numbers? So easy, just his positions, because those arrays, in server and in clients, having the same content, just a copy.

Why? if you have 2 arrays, you can think that you have 2 axis, X and Y. And then X (position inside array 1) and Y (position inside array 2) is returning 2 values (1st, from array1, and 2nd, from array2).

So, crossing arrays (maybe 3D arrays... 4D... etc), you can create thousand of different information to communicate with server, and in the same way, server with you.

Now how to convert that positions in numbers.

This is the easiest part of the method.

as example: 4 arrays. 40 positions each.

You can have this 'positions':

Array 1 - Array 2 - Array 3 - Array 4

-------   --------  --------  --------

23           12           8            37

Then you can create the number 2312.0837

Note that '8' i had to convert it to '08' to make perfect this 'number'.

This number will be the number that will be published by PublicVariable.

Then, at the same time, you are publishing 'your name' of player. So, server can know WHO is sending WHAT.

Then, the server now only have to say you "Roger", and start to 'decrypt' that number.

2312.0837 in 23, 12, 8, 37, this is so 'easy-meal' to our brain.

So server will 'request' to himself that 23 in Array1, 12 in Array2.... etc and the server will know the same info that you wanted to send it.

Only with 4 arrays... powerful tables...

Well, at this moment i have to say one 'truth' of my future scripts in this issues.

I was declaring, one .sqs file as a 'full-duplex' channel.

So if i need more 'channels' i have to open, more files.

Then, the server and all clients, is having the same quantity of 'channels'.

Some channels for some purposes... some channels for some others...

I hope this 'WARnet' not so complicated to understand.

And still i'm thinking that this system (and a lot of systems like this) can save a lot of bandwidth if we want to publicvariabling (and not too many).

Well, good nights, and good dreams on it.

goodnight.gif

Well still not too slept because i forgot this:

Parsing strings as numbers and again parsing numbers as strings can help a lot in this method just to make another 'pro' use of those arrays.

Parsing strings to numbers:

- "2381.1456" ---> 2381.1456

- broadcasting

- 2381.1456 ----> "2381.1456" to be saved in a string variable for future 'maths' or just putting it inside other arrays.

This kind of 'easy-algorithms' has to be declared in other scripts. I'm afraid only (because still without tests) if ArmA in each client, can handle between 5 and 10 mini-scripts in parallel (just launched from start of a mission... init.sqs based) and not noticing some CPU-resources-leakage.

Thx, moderator  wink_o.gif

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  

×