Home   Help Search Login Register  

Author Topic: The return of "player = ? on dedicated server"  (Read 2250 times)

0 Members and 1 Guest are viewing this topic.

Offline Killswitch

  • Members
  • *
  • Peace, cheese and ArmA
The return of "player = ? on dedicated server"
« on: 14 Sep 2003, 21:33:18 »
This thread: player=? on dedicated server hints at a nice trick for checking wether a script is run on a dedicated server:

Code: [Select]
? format ["%1",player] == "<NULL-object>": do-stuff-for-a-dedicated

However, I believe I have found a snag with that. There are three cases where player is a null object:
  • In missions running on a dedicated server (as above)
  • During an intro (in SP)
  • During an outro (in SP)
The deal, you ask? Well, there are scripts out there and addons with event handlers that do the above check
(player equalling the null object) and conclude "Ok, I'm on a deddy". Nuh-uh...

Case in point: the OFPEC Blood addon scripts do this and, for performance reasons, don't activate parts that would be meaningless to run on a dedicated server.

This could potentially affect the way one expects scripts and/or addons to behave while in an intro or an outro.

So... does anyone have a good idea on how to detect a dedicated server conclusively?

Assume that you are running from an addon event handler and therefore cannot do any fancy scripting in, say, a initIntro.sqs script in order to set something like "SPIntro=true" or expect the existence of a GameLogic conveniently named "Server".

« Last Edit: 15 Sep 2003, 20:44:17 by Killswitch »

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:The return of "player = ? on dedicated server"
« Reply #1 on: 15 Sep 2003, 01:19:55 »
?! (local player)

You can take it for granted that a mission will always have a player
however the player will never be local to the server on a dedi, so unless i am mistaken, the above should do the trick
« Last Edit: 15 Sep 2003, 01:21:00 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Killswitch

  • Members
  • *
  • Peace, cheese and ArmA
Re:The return of "player = ? on dedicated server"
« Reply #2 on: 15 Sep 2003, 13:26:34 »
I thought so too at first... however, the expression !(local player) evaluates to true during an intro (and an outro, perhaps, didn't test that).

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:The return of "player = ? on dedicated server"
« Reply #3 on: 15 Sep 2003, 17:42:51 »
why do you want to do this.

I mean if its an MP it cant have an intro just a cutscene

my other thjoughts are, as u posted
player = objnull type thing

how about (Stabbing in the dark)
! Player
or  maybe this weird one
?(!alive player) 0r (alive player):exit

why do you need to distinguish this so much, are you trying to create something that will run in all cases or an SP and an MP player server and a dedicated server
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Killswitch

  • Members
  • *
  • Peace, cheese and ArmA
Re:The return of "player = ? on dedicated server"
« Reply #4 on: 15 Sep 2003, 20:41:02 »
why do you want to do this.

Like I hinted at - imagine using an addon init event handler to set up some extra functionality/effects for an addon. Parts of these features may be unnecessary to run on a dedicated server (to save CPU load). However, the same init event handler running on a machine that is not a deddy might be running during an intro. The simple heuristic above for determining "running on a deddy" might lead to that addon wrongly disabling visual features that actually should be showing during an intro/outro.

Quote
why do you need to distinguish this so much, are you trying to create something that will run in all cases or an SP and an MP player server and a dedicated server
Yes.  Addons worth their name should do precisely that. A working solution is good enough. We don't have that as of yet.

« Last Edit: 15 Sep 2003, 20:51:46 by Killswitch »

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:The return of "player = ? on dedicated server"
« Reply #5 on: 16 Sep 2003, 16:55:13 »
well short of a readme file with the addon explaining the need for and how to implement a gamelogic i really dont see a solution

There are commands that only work in an SP game, campaign saves etc etc, maybe this would be be avenue pursuing

Did you try the two player lines. I didnt even run them in editor, they were just wild guesses, however if the command is accepted then maybe it will be part of the solution


Is there anything in the COC network system that would accomodate.

Good luck in your quest!
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Rubble_Maker

  • Guest
Re:The return of "player = ? on dedicated server"
« Reply #6 on: 16 Sep 2003, 21:36:56 »
Don't go about it like that. The need to implement a game logic only pisses off ppl, and since 90% of the ppl is stupid, many will not understand why/how to do that ;)

Fortunately it doesn't matter if the game logic is created by the map designer or a script. So you can use

_ServerLogic="logic" createVehicle [0,0,0]
?local _ServerLogic: ...

without probs :)

Offline Killswitch

  • Members
  • *
  • Peace, cheese and ArmA
Re:The return of "player = ? on dedicated server"
« Reply #7 on: 17 Sep 2003, 03:14:37 »
Don't go about it like that. The need to implement a game logic only pisses off ppl, and since 90% of the ppl is stupid, many will not understand why/how to do that ;)

Fortunately it doesn't matter if the game logic is created by the map designer or a script. So you can use

_ServerLogic="logic" createVehicle [0,0,0]
?local _ServerLogic: ...

without probs :)
Saw that one coming a mile out... ok, it's time for a slight exercise: Assume we do create a GL on the fly. Combine that with the "player not existing" trick as per the first post. Now try it out in your minds: where does this lead us with regard to discerning between a dedicated server session and a SP intro/outro?

Yup. "Nowheres"  :-X

Wonder if we should get on our knees and beg Suma/BIS for something like a "isDedicated" script command. That and a command that would return the version of the game would be like a cold one after a day in the desert, i.e just what the doctor ordered.

Note to budding mission makers/scripters: the "create a GL on the fly" is a very useful trick under many circumstances, so don't forget that little tidbit, even if it won't solve the problem at hand.

Terox: I will try some of the things you suggested. Indeed, there might be a way to use some of the scripting commands in a clever way  to infer "running on a deddy". I have had my eyes on the load/save thingies just as you hint at, but havent had the time to further investigate the matter.  I'll be sure to tell you all if I succed in my quest.  ;D
« Last Edit: 17 Sep 2003, 03:22:11 by Killswitch »

Rubble_Maker

  • Guest
Re:The return of "player = ? on dedicated server"
« Reply #8 on: 17 Sep 2003, 13:15:09 »
Excuse my ignorance Killswitch, but I didn't bother to read the full thread :)

But if you need to find out if you're in SP or MP, put the following in your init EH:

?format ["%1",clients]=="scalar bool array string 0xfcffffef":clients=0;publicVaiable "clients"
clients=clients+1
publicVariable "clients"

In those script that need to know if its SP or MP, you can assume that a second after mission start, the "client" variable will be unequal to 1 in MP. This, together with the "player=player" query, should be enough to find out if you're on a dedi or not!

>That and a command that would return the version of the game

Mhmm didn't try this yet, but probably you can find out the version. Count up a float var from, say, 1.46 to 1.92, and pass it to the requiredVersion command (use "format"). Store the last one that passed the test in a var "theVersion". When the test fails the first time, quit the loop, and "theVersion" should contain the game's version.

Again: I didn't test this, so don't blame me if it doesn't work


Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:The return of "player = ? on dedicated server"
« Reply #9 on: 18 Sep 2003, 01:22:07 »
i can see a flaw in the version command query due to linux 1.91 not being recognised as 1.91 only 1.90, however when (If) 1.92 comes out of beta (Has it already dont know) then that shoudnt be an issue anymore
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Killswitch

  • Members
  • *
  • Peace, cheese and ArmA
Re:The return of "player = ? on dedicated server"
« Reply #10 on: 18 Sep 2003, 13:13:43 »
Rubble's first "pass the counter around" looks like a possible solution.

In addition to the linux flaw Terox mentioned, the requiredVersion method has a problem in that it gives you a error dialog the first time the test fails. Doing a "result = requiredVersion 1.93" on the 1.92 beta gives a "this game requires..." (or something like that) dialog, much like the "Missing addons..." dialog, thereby requiring user input.
« Last Edit: 18 Sep 2003, 13:14:34 by Killswitch »