Home   Help Search Login Register  

Author Topic: Scripting error  (Read 613 times)

0 Members and 1 Guest are viewing this topic.

Combat-Agent

  • Guest
Scripting error
« on: 22 Nov 2005, 06:10:22 »
Code: [Select]
;v.1

_units = (count units group player)

? _units == 12: goto full
? _units == 1: goto one
? _units == 2: goto two
? _units == 3: goto three
? _units == 4: goto four
? _units == 5: goto five
? _units == 6: goto six
? _units == 7: goto seven
? _units == 8: goto eight
? _units == 9: goto nine
? _units == 10: goto ten
? _units == 11: goto eleven


#one
money = money - 5
"PCSailor3" createunit [getpos aa, g1, "S2 = This; removeallweapons this;", .1, "private"]
exit

#two
money = money - 5
"PCSailor3" createunit [getpos aa, g1, "S3 = This; removeallweapons this;", .1, "private"]
exit

#Three
money = money - 5
"PCSailor3" createunit [getpos aa, g1, "S4 = This; removeallweapons this;", .1, "private"]
exit

#four
money = money - 5
"PCSailor3" createunit [getpos aa, g1, "S5 = This; removeallweapons this;", .1, "private"]
exit

#five
money = money - 5
"PCSailor3" createunit [getpos aa, g1, "S6 = This; removeallweapons this;", .1, "private"]
exit

#six
money = money - 5
"PCSailor3" createunit [getpos aa, g1, "S7 = This; removeallweapons this;", .1, "private"]
exit

#seven
money = money - 5
"PCSailor3" createunit [getpos aa, g1, "S8 = This; removeallweapons this;", .1, "private"]
exit

#eight
money = money - 5
"PCSailor3" createunit [getpos aa, g1, "S9 = This; removeallweapons this;", .1, "private"]
exit

#nine
money = money - 5
"PCSailor3" createunit [getpos aa, g1, "S10 = This; removeallweapons this;", .1, "private"]
exit

#ten
money = money - 5
"PCSailor3" createunit [getpos aa, g1, "S11 = This; removeallweapons this;", .1, "private"]
exit

#eleven
money = money - 5
"PCSailor3" createunit [getpos aa, g1, "S12 = This; removeallweapons this;", .1, "private"]
exit


This is a script i made to detect the amount of soldiers in the players group so that a certain named soldier could be added. However, it seems that only the first createunit works, then it just keeps going to "one" to create soldiers, which is bad because only one soldier can have the unique name of s2, the third soldier (including player) needs to be named s3, and the fourth s4 and so on. Where am i erring at? I seem to be lax in this sort of script, i havnt got a script to work that has such ifs in it.

Thanks in advance.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Scripting error
« Reply #1 on: 22 Nov 2005, 09:40:05 »
well for a start, goto commands need "inverted commas" around the tag they're jumping to, so it's

Code: [Select]
goto "one"
however, i'm not sure what this script is trying to do. is g1 the player's group? is this just to add one more loon to the player's group and have that loon named in sequence?

either way, here's a smaller script which will do the same thing. tested and works, on the assumption that player is leader.

Code: [Select]
_units = count (units group player)
?(_units==12):exit

money = money - 5

call format ["{PCSailor3} createunit [getpos aa, g1, {s%1 = this; removeallweapons this}, 0.1, {private}]",_units+1]

exit
« Last Edit: 22 Nov 2005, 09:42:09 by bedges »

Combat-Agent

  • Guest
Re:Scripting error
« Reply #2 on: 22 Nov 2005, 20:08:49 »
Outstanding. Thanks, this helps me out alot. Ive not quite developed the most efficeint thought process for creating the most logical scripts yet. Once again, thanks.


Combat