Cube Code wrong? |
by MisanthropX
on 11/05/2008 14:30, 9 messages, last message: 11/07/2008 11:37, 1534 views, last view: 04/01/2024 05:12 |
|
hi guys.. i dont know whats wrong with my script =P
and was also asking in our forum and others but we dont get it..
i try to make this code shorter:
guibutton "spec " [if (= $cnchoose0 1) [spectator 1 0] ; if (= $cnchoose1 1) [spectator 1 1] ; if (= $cnchoose2 1) [spectator 1 2] ; if (= $cnchoose3 1) [spectator 1 3] ; if (= $cnchoose4 1) [spectator 1 4] ; if (= $cnchoose5 1) [spectator 1 5] ; if (= $cnchoose6 1) [spectator 1 6] ; if (= $cnchoose7 1) [spectator 1 7] ; if (= $cnchoose8 1) [spectator 1 8] ; if (= $cnchoose9 1) [spectator 1 9] ; if (= $cnchoose10 1) [spectator 1 10] ]
simple.. isnt it? cnchoose = variable of checkbox for ppl if somone is choosed like the CN 4.. the variable cnchoose4 will get the new value 1
now i tried this:
aplus = [ a = (+ $a 1) ]
guibutton "spec " [a = 0 ; while (< $a 15) [ if (= (concatword cnchoose $a) 1) [spectator 1 $a] ; aplus ] ]
but it wont work
and i dont know why o.o actually it should work
oh and ps.. i made 15 player slots (just for try) everyone have a own variable / cn so if i (mX|MisanthropX) is CN 0 i will be the variable cnchoose0
i hope you can help
thanks - Misa
|
|
Board Index
|
|
#1: Try... |
by Hirato Kirata
on 11/05/2008 23:07
|
|
try...
loop i 15 [
guibutton (format "spec %1" $i) [spectator 1 $i]
]
if you want to spec everyone at once, which I think you're trying to do, try...
guibutton "Spec all" [loop i 16 [specator 1 $i]]
and all I ca find wrong with your script by looking at it, is this part
(= (concatword cnchoose $a) 1)
it merges 2 strings, so you end up with... saying a was 0
(= cnchoose0 1)
what's wrong with that statement? the $ before the cnchoose, so this should suit your script, despite the fact I think it's not that... clean
(= (getalias (concatword cnchoose $a)) 1)
reply to this message
|
|
#2: Re: Try... |
by MisanthropX
on 11/05/2008 23:13, refers to #1
|
|
i dont want to spec all at once ;)
i try to make a master control panel
everyone has a checkbox so i can choose them and then spec/unspec/kick or move them in a team etc.
and i want to spec only the ppl who are choosen but i try what you said.. ty
reply to this message
|
|
#3: sorry for doublepost: |
by MisanthropX
on 11/05/2008 23:18, refers to #2
|
|
i did that now:
guilist [
guibutton "spec " [ while (< $a 15) [ if (= (getalias (concatword client $a)) 1) [spectator 1 $a] ; aplus ] ]
guibutton "unspec " [ while (< $a 15) [ if (= (getalias (concatword client $a)) 1) [spectator 0 $a] ; aplus ] ]
guibutton "kick " [ while (< $a 15) [ if (= (getalias (concatword client $a)) 1) [kick $a] ; aplus ] ]
]
still wont work..
reply to this message
|
|
#4: Re: sorry for doublepost: |
by eihrul
on 11/06/2008 06:52, refers to #3
|
|
You must do:
while [< $a 15] [...stuff here...]
note the [< $a 15] instead of (< $a 15). If you surround it with ()s, that expression is evaluted to a single result 0 BEFORE while sees it. So the []s pass it a block of code it can re-evaluate each time.
reply to this message
|
|
#5: .still.. |
by MisanthropX
on 11/06/2008 15:26
|
|
still wont work.. i tried a few combinations but it wont work..
guilist [
guibutton "select all " [ a = 0 ; while [ (< $a 15 ) ] [ (concatword client $a) = 1 ; aplus ] ]
guibutton "deselect all " [ a = 0 ; while [ (< $a 15 ) ] [ (concatword client $a) = 0 ; aplus ] ]
]
guibutton "spec " [ a = 0 ; while [ (< $a 15) ] [ if (= (getalias ((concatword client $a)) 1 ) [spectator 1 $a ; echo $a "has been specced" ] ; aplus ] ]
.. now the script specs all o.o (yes even if i choosed no one)
sigh i uploaded whole script here :
http://www.file-upload.net/download-1235320/X.cfg.html
reply to this message
|
|
#6: Re: .still.. |
by Quin
on 11/06/2008 19:41, refers to #5
|
|
You didn't read eihrul's post properly, that's why.
reply to this message
|
|
#7: .. |
by MisanthropX
on 11/06/2008 20:34
|
|
í did.. i should put it in [ ] the condition..
i also did
but wont work
so like i said: i tried a few combinations...
(even if its [ ( ) ] on the readme..
reply to this message
|
|
#8: .. |
by Quin
on 11/06/2008 21:22
|
|
a) while [] NOT while [()]
b) avoid things like this: ((concatword client $a)), you're evaluating this twice which would probably come out as "" (or better known as 'null'), brackets etc matter.
c) try a cubescript tutorial or look at other people's scripts for ideas on how things work
reply to this message
|
|
#9: .. |
by MisanthropX
on 11/07/2008 11:37
|
|
actually im an average good scripter.. im just not that good with concatword x.x
reply to this message
|
|
|
Board Index
|
|