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

Name of dedicated-server-player?

Recommended Posts

on a dedicated server, the server itself creates a player for executing scripts, etc.

if we know the name of this player, we can detect if a mission is running on a dedicated server.

i tried "", "SERVER", "_SERVER_", "", "", but dont found the name.

does anyone know the name of the dedicated-server-player?

Share this post


Link to post
Share on other sites

rock.gif

The server creates a player to execute scripts? dont think so, but i beleive there is already a way to detect if the mission is running on a dedicated server or not, something along the lines of...<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">If (local player AND local Server) then {Hosted = true;Dedicated = false} else {Hosted = false;Dedicated = true}

(need a GL called Server to work, and it must only be run on a server side script)

Basically if the player is local and the Server GL is local, then you know its a hosted server, since there is no player to the dedicated server

Share this post


Link to post
Share on other sites

to prove that the server is also executing scripts, you can write this line in the init.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"M113" createvehicle [5000,5000,0]

if only one human player is connected to the server, you will get 2 tanks created - one for the human player and one for the server.

Share this post


Link to post
Share on other sites

On a dedicated server the "player" variable is not set, so using that it should be possible to detect the use of dedicated server. for example something like this might work:

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

? !isNull player : exit

dedicatedServer = true

publicvariable "dedicatedServer"

The first if statement won't evaluate on the dedicated server at all because the player variable is not set and it wont exit, while on all clients it will.

Share this post


Link to post
Share on other sites

tried

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

and it works.

THX. biggrin_o.gif

Share this post


Link to post
Share on other sites

So what you want. The server to run or not to run scripts??

(!local server) : exit

(?!local server) : exit

you need a game logic called "Server" (no quotations). and the scripts detect if it is on the server. That is for example for your m113

in MP mission just the server creates the vehicles (1 piece)

then if a player jumps in it will get local to the client.

regards,

Daywalker

biggrin_o.gif

Share this post


Link to post
Share on other sites

for now, this is my solution:

in init.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;find an object on the island

_onr=0

#DoObj

_onr=_onr+1

?(getpos (object _onr) select 0)==0:goto "DoObj"

;island-objects are only local for the server/host

IsServer=local (object _onr)

;client-scripts must not be executed on dedicated-server

IsClient=(!IsNull player)

IsServer is used for server-side actions like creating units, vehicles, etc.

IsClient is used to activate client-side actions like smoke, fire, water-effects.

with this system i try to save cpu-power on a dedicated-server. mathematics for generating/placing visual effects must not be calculated on a dedicated-server.

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  

×