TYsiEK 0 Posted May 11, 2006 This is part of my script: _ig = 0 _ic = count (list _Trigger) ?_ic=_ig:_ig=_ig-_ic ; player sideChat ["If %1 = %2 then %2 - %1 = 0",_ic,_ig] It's not working player says If scalar = 6 then 6 - scalar = 0. And "_ig - _ic" is not working too. I tryed to convert scalar to number by: _icc = format ["%1",count (list _Trigger)] _ic = _icc And this is not working too Share this post Link to post Share on other sites
hardrock 1 Posted May 11, 2006 This is part of my script:_ig = 0 _ic = count (list _Trigger) ?_ic=_ig:_ig=_ig-_ic ; player sideChat ["If %1 = %2 then %2 - %1 = 0",_ic,_ig] It's not working player says If scalar = 6 then 6 - scalar = 0. And "_ig - _ic" is not working too. I tryed to convert scalar to number by: _icc = format ["%1",count (list _Trigger)] _ic = _icc And this is not working too That script seems very weird. 1. Why do you have a local _Trigger name? Each trigger has a global name, why not use that one? Or is it passed via argument? 2. Use == for comparisons 3. Your if statement is nonsense. Let's fill it with values: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; assumed _ig is 0 _ic = count (list _Trigger) // assume that returns ? 0==0: _ig=0-0 ; assumed _ig is 6 ? 6==0: not true, thus not executed What do you want to do with this script? I must say I don't have any clue. Share this post Link to post Share on other sites
Artak 0 Posted May 11, 2006 you're using _Trigger as a local variable but I don't see it defined anywhere. To check if something is equal to something you should use == = is for defining a variable _trigger = name of your trigger _ig = 0 _ic = count (list _trigger) ?_ic==_ig:_ig=_ig-_ic; player sidechat ["If %1 = %2... Share this post Link to post Share on other sites
Trapper 0 Posted May 11, 2006 _ic = count (list _Trigger) I guess this line doesn't work and _ic is never initalized. You can check this with hint format ["%1",_ic]. Maybe you can start your script from the trigger; onActivation: (count thislist) exec "script.sqs" and edit the _ic line to; _ic = _this Edit: Oh, and of course the others are right about the = / ==. Share this post Link to post Share on other sites
TYsiEK 0 Posted May 11, 2006 It's script for selecting target in trigger for sniper. Thx for suggestion but == instead of = is not working this is all of the script: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ; [sniper_name,trigger_name] exec "sniper.sqs" _Sniper = _this select 0 _Trigger = _this select 1 _ig=0 _id=count (list _Trigger) _ic=_id con = true fire = false ~1 {player sideChat format ["There are %1 units in %2 trgger",_x,_Trigger]} forEach _ic #HERE ~1 _g = list _Trigger select _ig player sideChat format ["%3 set, %2, target %1",_g,_Sniper,_ig] _Sniper doTarget _g _ig=_ig+1 ~1 con = false goto "UPDATE" #UPDATE player sideChat "Update" ~1 player sideChat format ["_ic = %1 _ig = %2",_ic,_ig] ;= instead of == is not working ?_ic==_ig:_ig=_ig-_ic ~2 ? fire : goto "FIRE" ~1 ? con : goto "HERE"; player sideChat "Next target" player sideChat "Updating" goto "UPDATE" #FIRE _Sniper doFire _g player sideChat "Fire !" fire = false goto "UPDATE" Share this post Link to post Share on other sites
TYsiEK 0 Posted May 11, 2006 Okay I got it working. I mean I got working sideChat without scalar because I used count thislist instead of count (list _Trigger) Now it looks like that: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ;executing in trigger: ;[thislist] exec "sniper.sqs" _Trigger = _this select 0 _ic = count _Trigger #UPDATE player sideChat "Update" ~1 player sideChat format ["_ic = %1 _ig = %2",_ic,_ig] ;= instead of == is not working ?_ic==_ig:_ig=_ig-_ic ~2 ? fire : goto "FIRE" ~1 ? con : goto "HERE"; player sideChat "Next target" player sideChat "Updating" goto "UPDATE" First update: Player says _ic = 3 (because of 3 units in trigger) _ig = 1 (because second target (unit) of thislist has been selected but in the second update player says _ic = 1 _ig = 1. So what the hell is going on ?? EDIT: Okay I got it all working ! Thx for thislist and == intead of = suggestions Now it is: ?_ic==_ig:_ig=_ig - _ic And it's working like hell Share this post Link to post Share on other sites