Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
Vegatry

Question: isServer and isDedicated, local v. global

Recommended Posts

I do try community wikis about local, global, isServer, isDedicated.

But I'm still very confused...

What is the different between a Server and Dedicated Server? Perhaps an example?

Like Shacktac server is a dedicated server or a host?

When should i use local variables and when should i use global variables?

Plus what does this code do?

if (!isServer) exitWith {}

Share this post


Link to post
Share on other sites

Listen vs Dedicated

There are two ways to host a server in ARMA: as a "listen" server, or as a "dedicated" server. A listen server is one you host from right within your client: your computer will be acting as the host for all players in game, while you would also be presumably playing in game. A dedicated server is one you launch, usually on a separate machine in a datacenter, with no player in the same client. This server doesn't need to share any processing power with the graphics, user interface, or other features the player would interact with, so they are what you'd use for bigger servers.

isServer vs isDedicated

isDedicated: Returns true when client it runs on is hosting the game, and is a dedicated server. In practice, this will mostly means that there is no player being controlled by this client, so you would use this if you have code that should only run on a dedicated server, not a listen server.

isServer: Returns true when the client it runs on is hosting the game. This is true on both listen servers and dedicated servers, so anything that needs to be run only on one client (for example, a global command for setting up the mission, ie spawning in vehicles).

You basically need to get an understanding on when and where your code needs to be run, be it on every client, just the server, or some combination of the two. To list a few examples:

Does it run on every client that has is connected to the server, but not the server? Then contain it within a:

if (!isDedicated) then {...}; //Note the !

Does it run on only the server?:

if (isServer) then {...};

etc.

Global vs. Local

There's another use of these terms for describing multiplayer locality, however that's a headache of its own for another time. Instead, I think Killzone Kid does a pretty good job of explaining this topic, so I'm going to simply point you to his tutorials:

http://killzonekid.com/arma-scripting-tutorials-variables-part-1/

I'd say read that and the following articles, and you hopefully will get a good idea of how the different types of variables work.

exitWith

Finally, an if (...) exitWith {...}; statement will execute the code within the {}, then break out of the current scope. So as an example:


//Your init.sqf

//Anything that will happen on all clients, including the server, would go here

if (isServer) exitWith {}; //If this computer is the server, stop executing this code.

//Now anything after this will only be executed on computers that are not the server.

If anyone sees anything wrong, misleading, or omitted, please tell me and I'll correct it. Rather tired while writing this so some of my points may be a bit off.

Share this post


Link to post
Share on other sites
Listen vs Dedicated

There are two ways to host a server in ARMA: as a "listen" server, or as a "dedicated" server. A listen server is one you host from right within your client: your computer will be acting as the host for all players in game, while you would also be presumably playing in game. A dedicated server is one you launch, usually on a separate machine in a datacenter, with no player in the same client. This server doesn't need to share any processing power with the graphics, user interface, or other features the player would interact with, so they are what you'd use for bigger servers.

isServer vs isDedicated

isDedicated: Returns true when client it runs on is hosting the game, and is a dedicated server. In practice, this will mostly means that there is no player being controlled by this client, so you would use this if you have code that should only run on a dedicated server, not a listen server.

isServer: Returns true when the client it runs on is hosting the game. This is true on both listen servers and dedicated servers, so anything that needs to be run only on one client (for example, a global command for setting up the mission, ie spawning in vehicles).

You basically need to get an understanding on when and where your code needs to be run, be it on every client, just the server, or some combination of the two. To list a few examples:

Does it run on every client that has is connected to the server, but not the server? Then contain it within a:

if (!isDedicated) then {...}; //Note the !

Does it run on only the server?:

if (isServer) then {...};

etc.

Global vs. Local

There's another use of these terms for describing multiplayer locality, however that's a headache of its own for another time. Instead, I think Killzone Kid does a pretty good job of explaining this topic, so I'm going to simply point you to his tutorials:

http://killzonekid.com/arma-scripting-tutorials-variables-part-1/

I'd say read that and the following articles, and you hopefully will get a good idea of how the different types of variables work.

exitWith

Finally, an if (...) exitWith {...}; statement will execute the code within the {}, then break out of the current scope. So as an example:


//Your init.sqf

//Anything that will happen on all clients, including the server, would go here

if (isServer) exitWith {}; //If this computer is the server, stop executing this code.

//Now anything after this will only be executed on computers that are not the server.

If anyone sees anything wrong, misleading, or omitted, please tell me and I'll correct it. Rather tired while writing this so some of my points may be a bit off.

Thank you! ;) learned a lot from it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×