Jump to content
  • 0

Variables called over Server?


FragZ

Question

10 answers to this question

Recommended Posts

  • 0

In your explanation it states that both server_whitelist.sqf and admintools_main.sqf are both serverside, but your one line question at the top states one is serverside one is clientside. That's confused me somewhat. I'm gonna assume that you made an error in your explanation and just go from your one line at the top.

 

Yes, you can. Once you have initialised your variables serverside you can use publicVariable "my_variable"; to broadcast that to all clients.

Clientside you can just put them in a hold, waitUntil {!isNil "my_variable"}; then a quick if statement to work out if the player UID is inside the 'my_variable' array. I hope that answered your question properly.

Link to comment
Share on other sites

  • 0

In your explanation it states that both server_whitelist.sqf and admintools_main.sqf are both serverside, but your one line question at the top states one is serverside one is clientside. That's confused me somewhat. I'm gonna assume that you made an error in your explanation and just go from your one line at the top.

 

Yes, you can. Once you have initialised your variables serverside you can use publicVariable "my_variable"; to broadcast that to all clients.

Clientside you can just put them in a hold, waitUntil {!isNil "my_variable"}; then a quick if statement to work out if the player UID is inside the 'my_variable' array. I hope that answered your question properly.

Updated post, my bad.

So once I define my variables over the server side, I would then need to put publicVariable "thevariablethatisinServerpbo"; somewhere in the client file? Or in the actual file needing the variable check?

And I don't get your part about the waitUntil

Link to comment
Share on other sites

  • 0

This is a part of my variable file I am talking about:

 

/****************************************************************************************************************/
//Super admin and Dev testing whitelisting 
FZ_SuperLovers = ["xxxUIDsxxx"];
Mod_list = ["000"];
FZ_Admins = ["0"];

Would I just execVM that file from the server_functions.sqf ?

And then, what to do next? (Sorry a bit hangover)

 

Edit:

So the server side file would have this:
publicVariable "FZ_SuperLovers";

publicVariable "Mod_List";

publicVariable "FZ_Admins";

 

At the end so it broadcasts the variable globally?
 

Link to comment
Share on other sites

  • 0

You would use the publicVariable command serverside, as you're wanting to send it from the server to the clients.

The waitUntil{!isNil "my_var"}; command in the clientside files will stop the script proceeding until the client has received your variable from the server.

This command will halt progress of the file it is in until the code inside the braces returns true. In this case it checks that the variable you send from your server using publicVariable command has been received by the client. Using this is important to prevent errors relating to your variable being undefined.

 

Yes! Just like that.

/****************************************************************************************************************/
//Super admin and Dev testing whitelisting
FZ_SuperLovers = ["xxxUIDsxxx"];
Mod_list = ["000"];
FZ_Admins = ["0"];
publicVariable "FZ_SuperLovers";
publicVariable "Mod_List";
publicVariable "FZ_Admins";

That would do the trick just fine. ExecVm that from anywhere serverside and those variable will go to all clients.

Link to comment
Share on other sites

  • 0

You would use the publicVariable command serverside, as you're wanting to send it from the server to the clients.

The waitUntil{!isNil "my_var"}; command in the clientside files will stop the script proceeding until the client has received your variable from the server.

This command will halt progress of the file it is in until the code inside the braces returns true. In this case it checks that the variable you send from your server using publicVariable command has been received by the client. Using this is important to prevent errors relating to your variable being undefined.

Oh I get you.

So I would need to use publicvariable in the server file just like I posted above, and then use *waitUntil {!isNil "FZ_SuperLovers"}; at the top of my admintools file, so it prevents the file from continuing execution if the said variable is returning an empty array. I get it.

But if I have multiple public variables in the same file, would I need to make like... 3 waitUntil commands if I have 3 variables from server side?

Thank you very much for your help btw!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...