Home   Help Search Login Register  

Author Topic: Trimming down a cumbersome script  (Read 1205 times)

0 Members and 1 Guest are viewing this topic.

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
Trimming down a cumbersome script
« on: 20 Dec 2002, 02:42:50 »
Can anyone help me to trim this scrop[t down some?  It works, after much frustration, but it is cumbersome to type and I haven't even completed 1 side much less both!  It is called from an anyone trrigger and all the units are named "s1" etc and "n1" etc  There must be an easier way in 1.46.  This does get rid of pesky ai units tho!
?!(local server):exit
~5
#jail
jailarray=["s1","s2","s3","s4"]
~5
hint "goto Jail"
?(s1==player):goto "s2"
"s1 setpos [9575,4100,0]" foreach jailarray
[s1] join grpnull
#s2
?(s2==player):goto "s3"
[s2] join grpnull
"s2 setpos [9575,4100,0]" foreach jailarray
#s3
?(s3==player):goto "s4"
"s3 setpos [9575,4100,0]" foreach jailarray
[s3] join grpnull
#s4
?(s4==player):goto "end"
[s4] join grpnull
"s4 setpos [9575,4100,0]" foreach jailarray
goto "jail"

#end
~5
hint "all were a player"

Offline Vortrog

  • Members
  • *
  • Ski'in, Fish'in, Shoot'in, OFP'in
    • Vortrog's Lair
Re:Trimming down a cumbersome script
« Reply #1 on: 20 Dec 2002, 06:56:29 »
Well, for starters, get a loop to do the dirty work



;make a counter as a selector of the array
_count = 0
?!(localserver):exit
~5
;I assume all these guys "S" and "N" start in the same location? Thats how Ive fixed it for now
jailarray=["s1","s2","s3","s4","n1","n2","n3","n4"]

~5
hint "goto jail"

#jail
_players = jailarray this select _count
?(_players==player):goto "next"
;if you wanted to be rid of AI, why not setdammage 1 them all?  :-)
"_players setpos [9575,4100,0]" foreach jailarray
[_players] join grpnull
;check to see if the unit count is up to max
?(_count==3):goto "end"

#next
;advances the player count
_count = _count + 1
goto "jail"

#end
~5
hint "All were a player"



Try that....I havent, but give it a go.

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
Re:Trimming down a cumbersome script
« Reply #2 on: 20 Dec 2002, 11:47:56 »
OK, I'll give this a shot later today, as to your questions though,
For now they start in the same location but I will move them to their respective respawn areas when this works, and I can setdamage on all of them, but then they will respawn and have to be moved or killed again.  I am also unfamiliar with the count routine, what does it do and why do I need it?  Also, will this work in a MP game if someone leaves?  Those are the reall pesky AI I'm trying to control.  Thanks for your help.....

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
Re:Trimming down a cumbersome script
« Reply #3 on: 20 Dec 2002, 11:48:13 »
I tried it and get some errors:  it says generic error in expression  ?(_players==player):goto "next"  and then nothing happens
« Last Edit: 20 Dec 2002, 12:55:15 by Zombie »