Jump to content
Sign in to follow this  
nazer1290

Running a script on the server.

Recommended Posts

How do I run a script on a non-dedicated server, without it running on the 'client' hosting the server?

Share this post


Link to post
Share on other sites

if (isServer) then {
   //your code here
};

This will run the encapsuled code only on server, regardless if it's dedicated or hosted.

Share this post


Link to post
Share on other sites

is putting a gamelogic on the map and name it server used anymore?

Share this post


Link to post
Share on other sites

Nope, this was a workaround since at that time there wasn't a isServer command.

Share this post


Link to post
Share on other sites

Ok thanks, haven´t made a mp mission since flashpoint

Share this post


Link to post
Share on other sites

I started a Multiplayer game with this script to test it.

It hinted "I am the server".

any ideas?

if (isServer) then {
hint("I am the server");
} else {
sleep 3;
hint("I am a client");
};

---------- Post added at 08:22 PM ---------- Previous post was at 08:20 PM ----------

Ohh, wait a sec I think I messed something up :butbut:

---------- Post added at 08:24 PM ---------- Previous post was at 08:22 PM ----------

Nope, still says Im the server.

Share this post


Link to post
Share on other sites

If you hosted the game yourself then the hint was correct since when hosting you are server and client at the same time. Only when you start a dedicated server locally and then connect to this server, then you should get the client hint.

Share this post


Link to post
Share on other sites

Hosted (started from multiplayer menu) server is both server and client. Thus, it will not show the client text as the isServer is true. Works fine on dedicated server, but if you want to get both to show on hosted server, you can't use else block like that.

Share this post


Link to post
Share on other sites

How do I tell the server from the client hosting the server?

(For some reason when I host a dedicated, then run ARMA2, it almost freezes up)

Share this post


Link to post
Share on other sites

Please keep in mind...

In a hosted environment (means starting a MP session from a running ArmA 2 game) the server is also a client.

While in a dedicated environment the dedi server is server only (ArmA 2 command isDedicated).

Executing commands like hint on a dedi server is not necessary (nobody can read it anyways :))

That's where some people start to wonder why their MP mission worked fine when trying hosted while testing and on a dedicated server nothing works anymore.

Xeno

Share this post


Link to post
Share on other sites

Can you start a dedicated server from the client game, then connect with the client? (or, are you 'allowed' or 'supposed' to?)

I did try it, but it 'lagged' horribly.

Share this post


Link to post
Share on other sites

A decent computer runs a dedi server and game client simultaneously, for mission testing at least.

Share this post


Link to post
Share on other sites

I found it only happend with one of my missions =S Not sure why.

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  

×