Home   Help Search Login Register  

Author Topic: Re: Locals thread (closed)  (Read 2689 times)

0 Members and 1 Guest are viewing this topic.

Mr.BoDean

  • Guest
Re: Locals thread (closed)
« on: 23 Jul 2003, 10:48:46 »
Arrgghh ...but I have a question!  :-X


From TEROX:
Quote
Create a gamelogic, name it "Server"

The name you gave "Server", has nothing to do with Servers, you could have simply named it "Hotchocolate" and it would do the same job

EG.

?(local server):
?(local Hotchocolate):

The above two line checks whether  the machine that the script  is run on is  the server


What the lines actually says is
Is "Server" or  "Hotchocolate" local (true) on  this machine?"
If it is, then it must be the server, because gamelogics are only present on server machines
_____________________________________________________________
You can then add further commands to the line
eg
?(local server): exit
The script will not run on the server machine
______________________________________________________________
?(local server): goto "Start1"

#Start1

The above line if run on the server will have the script jump to the "#Start1" line, missing any lines out inbetween
_____________________________________________________________
? !(local server): exit
The above line will cause the script to exit, if the script IS NOT being run on a server


Other lines of interest

?(Local Player):

Used to check if the machine that the script is running on is NOT a dedicated server

or if you want it run only on a dedicated server

? !(Local Player):

?(Local server): will run on a player/server machine as well as a dedicated server



Scripts or lines of scripts that are normally run on a server only are things like
Adding scoring
Vehicle respawn


For instance, i have seen scripts written that have lines running on both the client and the server, when really there was only need to have them running on one or the other, but not both

So if you want to optimise your mission to the optimum, you have to look at each individual line and ask, where does this line need to be run, and then put the Server checkline infront of that line, to deal with it as you want

Ok, I dunno why but all of this Client/Local/Global/ Server stuff confuses the hell outta me.  :P The more I read, the less I understand.

So these lines you've recommended are to be placed within a script? or at the beginning of a script? Or does someof it belong in Init.sqs?  And All you do is create a Gamelogic and name it and nothing else ? Nothing in it's Init. box or anything?

But how can you be sure what should run on the client PC's and what should be run on the server? Is it directly relative to WHO actually calls the script?  :-X   :-\     :P  
   Exasperated Thanks........


Rubble_Maker

  • Guest
Re: Locals thread (closed)
« Reply #1 on: 23 Jul 2003, 14:50:34 »
Ok lemme try: Everything your write into a mission's INIT.SQS script is executed on all machines (i.e. the server AND all clients). So if you call other scripts from the INIT.SQS, they will also run on all machines. This is nice for some things, but sometimes you want certain things to happen only on the clients, or only on the server, or only on the local machine.

To make sure some script only runs on the server, you add this line to its very beginning:

if !local SERVERLOGIC: EXIT

where SERVERLOGIC is the name of a gamelogic you placed on the map. The name does NOT matter; you can call it anything you like (for example, Allan_Peters would be a nice name too ;) - no I'm just kidding)

You also dont need to add anything to its init line. You're merely exploiting the fact that any game logic object is local only on the server. Thats all.

If you want something to run on the local machine only, you can use this:

?local playerName: ....

where playerName is the name of some player or vehicle. The ... will only execute on the machine that owns this player or vehicle. For example, if in a multiplayer session your friend John plays some soldier which is called SOLDIER1 on the map, then

?local SOLDIER1: ...

will execute something only on John's machine.

I know its confusing ;)


Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re: Locals thread (closed)
« Reply #2 on: 23 Jul 2003, 16:52:04 »
use the server to record and keep track of the score.
Use the server to respawn vehicles
Use the server to declare public variables (in most cases)
Use the clients to run graphical scripts

that should get you started

some scripts need to be run on every machine, however some lines within the script need only to be run on either the server or the client, this is where you make best use of
?(local server) etc etc
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Mr.BoDean

  • Guest
Re: Locals thread (closed)
« Reply #3 on: 24 Jul 2003, 00:44:38 »
Ok , good info guys, thanx.  So this mainly deals with the running of scripts, yet the part of checking of Host/Client PC is not done until you are IN the script, rather than where (who) it is called from?  Okay. I just figured that if you had a trigger with:

On Activation:Soldier1 exec "Hollayabooza.sqs"

that it would only run on that client's PC.    ???


  Terox, u said server for vehicle respawn ...does that mean player respawn should be only on the client's computer or does it need to be on the host server for all to see and synch?
 i.e. , I currently have 8 triggers (one for each player) setup to do a respawn at a random distance from the player's place of death. All activity is within the triggers, though ...no script is called.  Should they be client-based?  ???

Also "graphical scripts"  ...being anything with action ?
   I have a couple of paradrop and cargo drop scripts in my mission in both  the intro and mission. Should these be limited to HOST only? (Intro is player side, mission is enemy AI ) .

Also, when you say ?local playerName: .... do you place the next line of the script where the ... is , or does it go on the next line down or does it matter?

  Man, so much for the brain to absorb! Remind me to get new sponges.   :P    ;D

Thanx guys.    :)

Tactician

  • Guest
Re: Locals thread (closed)
« Reply #4 on: 24 Jul 2003, 09:46:48 »
Okay. I just figured that if you had a trigger with:

On Activation:Soldier1 exec "Hollayabooza.sqs"

that it would only run on that client's PC.    ???

Nope.. that line would exec "Hollayabooza.sqs" for everyone machine that read the trigger's condition as true.  The key to making triggers work for specific people is all in the CONDITION of the trigger, not the activation.

Condition: (whatever) AND player == soldier1
On Activation: [] exec "Hollayabooza.sqs"

Also you can make server-only triggers:

Condition: (whatever) AND local GAMELOGIC
On Activation: [] exec "anyserverscript.sqs"

Check out the Server-side Loops and Messages tutorial for more on this..

Mr.BoDean

  • Guest
Re: Locals thread (closed)
« Reply #5 on: 24 Jul 2003, 11:43:12 »
Aha! velly, velly intellesting, Tac, thx!  :)

  So is the way I currently  have the respawn set up okay, or would that be better scripted ?

Tactician

  • Guest
Re: Locals thread (closed)
« Reply #6 on: 24 Jul 2003, 13:58:19 »
It depends on what are you doing with the player respawn.  Normal respawn-at-base is handled by description.ext and a marker.  If you're doing more, you can usually handle it on just the player's side.  That's where "player" comes in handy.

A basic trigger detecting respawn is:

(Activated repeatedly)
Condition: !alive player
Activation:
Deactivation: (whatever)

Mr.BoDean

  • Guest
Re: Locals thread (closed)
« Reply #7 on: 24 Jul 2003, 23:03:01 »
It depends on what are you doing with the player respawn.  Normal respawn-at-base is handled by description.ext and a marker.  If you're doing more, you can usually handle it on just the player's side.  That's where "player" comes in handy.

A basic trigger detecting respawn is:

(Activated repeatedly)
Condition: !alive player
Activation:
Deactivation: (whatever)

Yeah, I'm using the following trigger setup I got from a cool guy named Tactician    ;)  :

Code: [Select]
Trigger activated repeatedly
Condition: !alive player
Activation:
Deactivation: player setPos [(getPos player select 0) + random (100), (getPos player select 1) + random (100), 0]

And I just made 8 triggers and replaced player with P1 thru P8 , respectively.

So I'm saying should I be doing this in a script format instead?  It seems to work great for what I needed, although for some reason any friendly AI you bring with you only respawn 3 or 4  times before they just disappear!   :-\   ???
« Last Edit: 24 Jul 2003, 23:03:27 by Mr.BoDean »

Tactician

  • Guest
Re: Locals thread (closed)
« Reply #8 on: 24 Jul 2003, 23:23:17 »
There's another way my friend.

Code: [Select]
;; respReloc.sqs
;; randomizes respawn position
_unit = _this
?!(local GAMELOGICNAME): exit

#loop
@(call format ["!alive %1",_unit])
@(call format ["alive %1",_unit])
call format ["%1 setPos [(getPos %1 select 0) + random (100), (getPos %1 select 1) + random (100), 0]",_unit]
goto "loop"
;; end respReloc.sqs

The script remembers the unit passed to it as _unit.  It proceeds to the #loop section.  It waits until the unit is dead, then waits until it's alive, then sets its position randomly.  Goes back to the beginning and waits for the unit to die again.  All this is only happening on the server (the player will feel the setPos).  I'm not sure about how well it will work under strained network conditions, but something should happen.  

And to activate it, use this init line:

"P1" exec "respReloc.sqs"

(P1 is the name of the soldier, and yes it has to be a string closed in quotes)

It ought to work, if not tell me what went wrong ;)  Note that you need a valid GAMELOGICNAME.

Mr.BoDean

  • Guest
Re: Locals thread (closed)
« Reply #9 on: 24 Jul 2003, 23:33:03 »
Okey-doke, I'll try that, thanks.   ;D   Think this would fix the AI  not  continuing to respawn?    :-\

« Last Edit: 25 Jul 2003, 09:21:43 by Mr.BoDean »

Mr.BoDean

  • Guest
Re: Locals thread (closed)
« Reply #10 on: 25 Jul 2003, 09:22:19 »
ALSO, if I am going to be running a weapon respawn script for player to have same weaps as when they died, should the 2 be combined into one script? Which should run first, the player respawn?  Then have the weapon detection/selection happen afterwards and return the script to the loop?

 Or would you just keep them separate and have each player's init. line be like:

P1 exec "respReloc.sqs"; P1 exec "WeapSel.sqs"

 ???   :-X  

Thanks for helping me thru my scripting newbism.   ;D

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re: Locals thread (closed)
« Reply #11 on: 25 Jul 2003, 16:57:50 »
have the first script that is run of your trigger activate the second script

or modify the two scripts into one
« Last Edit: 25 Jul 2003, 16:59:49 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123