Home   Help Search Login Register  

Author Topic: Effects in MP Games  (Read 1542 times)

0 Members and 4 Guests are viewing this topic.

Offline the corinthian

  • Members
  • *
  • I'm a llama!
Effects in MP Games
« on: 14 Apr 2003, 14:36:22 »
I have completed a mission which uses the burnfire and the napalm addons to create large explosions but when these are called in an MP game only the host can see them, the visual effects are not performed on the other PCs playing, despite identical game video settings etc.

Does anyone know why this is the case and how to work around it please?

Pimmelorus

  • Guest
Re:Effects in MP Games
« Reply #1 on: 14 Apr 2003, 18:08:26 »
Well, the fire and smoke effects are created using the "drop" command and are only executed on the computer that has executed this command. Obviously, the script you run runs on the server alone. Solution, therefore, is to let every client execute this script at the same time. Lets consider a  Napalm strike. To let this happen each client should run a script that awaits a signal from the server (i.e., the changing of a global variable via the "PublicVariable" command) and then performs the visual aspects of the strike. If the strike does not occur always on the same location (e.g, can be called in by clicking on the map) the signal from the server should contain info about the localization of the strike as can be done with an array.

Offline the corinthian

  • Members
  • *
  • I'm a llama!
Re:Effects in MP Games
« Reply #2 on: 14 Apr 2003, 18:34:52 »
How do I get a script to run for every player in the game?

The effect in question is the napalm effect and I am using it for airstrikes activated by radio commands to hit a selected target on the map.

Other players in the game can call airstrikes but its only the host that can see the napalm effect. Does this mean I need ot change the airstrike script to run for every player as I assume that is where the problem lies?

If so then would I need to make the script run in a loop so it runs for each player? If so how do I tell the script which player I wish the script to run for?

Pimmelorus

  • Guest
Re:Effects in MP Games
« Reply #3 on: 15 Apr 2003, 08:33:30 »
OK,

1] Create a logic called "server" on the map. Well, now you have integrated in the map that there is a server side and a client side of the game. First things first :)

2] Have a script on server side running that coordinates the Napalm strike (as i do not see your precise application this bit is speculation). This can also be a trigger on the map that is activated -> triggers are always executed on all clients without extra steps. To execute a scripts on server only (from the start of the game) put in init.sqs:

?(local server): [] exec "Napalm_server.sqs"

3] The server cannot start a script by its own power in the clients. Instead we have all clients run a script from the beginning of the game that detects the location and time of a Napalm strike. Put in init.sqs:

?!(local server): [] exec "Napalm_client.sqs"

4] Put in init.sqs a definition of the strike-coordinates as a global variable that are non-functional. Might be like this:

Coordinates = [0,0]  <- Note the lack of underscore before"coordibates" making it a global variable

5] Have the server side script changing the strike coordinates to where you want to have it (again, this bit is speculation as i do not see your precise application). As an important step this scripts refreshes the global variable "coordinates" using the "publicVariable" command. This way the server tells ALL clients something is happening (like broadcasting). It will be like this:

?(Napalmstrike == true bla bla bla*): coordinates = [2705, 5658]; PublicVariable "coordinates"

*Put your own conditions here, depends on other scripts and map design

6] Have all client side scripts wait for the "coodinates" global variable to be different from [0,0]. If altered (by server of course) then they will execute the Strike at client-side. Like this:

#top
@!coordinates == [0,0]
_xcoordinate = coordinates select 0
_ycoordinate = coordinates select 1

<here comes the napalm script using the _x and _y positional info>

coordinates = [0,0]
goto "top"

These lines await signal of server, executes the strike at the position as defined by server and, finally, resets the coordinates to be ready for next strike. Note that the cllients do not need to "broadcast" the coordinates back to server and other clients, so the "PublicVariable" command is not applied here.

Good luck,



« Last Edit: 15 Apr 2003, 08:39:43 by Pimmelorus »

Tactician

  • Guest
Re:Effects in MP Games
« Reply #4 on: 15 Apr 2003, 21:32:14 »
The problem with that, Pim, is that an array can't be publicVariabled.  You have to seperate X and Y before sending the publicVar.

On the server side:

xcoord = coordinates select 0
ycoord = coordinates select 1
publicVariable "xcoord"; publicVariable "ycoord"

Then receive them with:

@!(xcoord == 0 AND ycoord == 0)
_xcoordinate = xcoord
_ycoordiante = ycoord