Home   Help Search Login Register  

Author Topic: Creating units on the fly in MP via a script  (Read 1568 times)

0 Members and 1 Guest are viewing this topic.

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Creating units on the fly in MP via a script
« on: 16 Oct 2002, 19:32:03 »

I have this script I use to create units one the fly for MP coop missions. The script for the more the most part works and creates units once a trigger is activated. However in MP it always creates 12 units even when I specify 4. In the editor it just creates 4 as intented. Also this script causes the occasional lag when 12 dudes pop out of no where.

Is there something I can do to improve the script?


;pos1 being an object (like a rock or barrel)
pos = getpos pos1
; number of units to create
unitnum=8
intel=1
a=0
newgroup=group1

#countloop
; Start Counting

a = a + 1

; if a = unitnum then end script
? a == unitnum : goto "stopscript"

; Create the Solider
"SoldierEMG" createUnit [pos, newgroup,"",intel,"SERGEANT"]

a = a + 1


? a == unitnum : goto "stopscript"

"SoldierELAW" createUnit [pos, newgroup,"",intel,"CAPTAIN"]

a = a + 1

; if a = _unitnum then end script
? a == unitnum : goto "stopscript"

"SoldierEG" createUnit [pos, newgroup,"",intel,"LIEUTENANT"]

a = a + 1

; if _a = _unitnum then end script
? a == unitnum : goto "stopscript"

"SoldierESaboteurPipeHG" createUnit [pos, newgroup,"",intel,"LIEUTENANT"]

goto "countloop"

#stopscript
exit
Xbox Rocks

Backoff

  • Guest
Re:Creating units on the fly in MP via a script
« Reply #1 on: 16 Oct 2002, 21:12:08 »
Hi hoz,

The problem here is that all clients execute the script and create new units. To avoid this, create a game logic called 'Server' somewhere on the map and add this code on the first line of your script:

?(!local Server): Exit

this will prevent clients to execute the script.


Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re:Creating units on the fly in MP via a script
« Reply #2 on: 17 Oct 2002, 02:27:30 »
Thanks for the help.

Hoz
Xbox Rocks

RedLion

  • Guest
Re:Creating units on the fly in MP via a script
« Reply #3 on: 17 Oct 2002, 18:44:33 »
Hi Hoz!
I have been looking for something like this so I can somewhat play a real time Campaign with my friend over a lan connection at home.
I am not that versed at scripting but if you could show me how to use this script, I will give it a shot. :)

Many thanks,
RedLion