Forum

> > CS2D > Scripts > Multiplication by the variable
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Multiplication by the variable

5 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Multiplication by the variable

orkin2913
User Off Offline

Zitieren
Hi,
i must multiplied a variable xyz[id] by variable zyx
it looks like this:
1
2
3
4
5
zyx = 15
if unknow[id]==1 then
unknowxyz[id]=xyz[id]*zyx
msg2(id,"Your number is '..unknowxyz[id]..'!@C")
end
However I can not multiply by zyx, I have to multiply by 15.
I have to write it that multiplied by zyx
Any suggestions on how to fix this?

alt Re: Multiplication by the variable

EngiN33R
Moderator Off Offline

Zitieren
Unless you have some kind of error in the xyz table, this should work. I tested this code:

1
2
3
4
5
6
zyx=15
xyz={1,2,3,4,5}

for i=1,5 do
	print(xyz[i]*zyx)
end

And it worked perfectly.

alt Re: Multiplication by the variable

uaiek
User Off Offline

Zitieren
user orkin2913 hat geschrieben
Spoiler >


There is a wrong string usage at line 4.
it should be
1
msg2(id,"Your number is "..unknowxyz[id].."!@C")
or
1
msg2(id,'Your number is '..unknowxyz[id]..'!@C')

alt Re: Multiplication by the variable

EngiN33R
Moderator Off Offline

Zitieren
user orkin2913 hat geschrieben
hmm, why you use "print"?
I need to a variable unknowxyz multiplied xyz and zyx but no print...


I use it to see the answer. You can as well set it, it won't make a difference.

Also, user uaiek has a fair point. Maybe that's why it doesn't work.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht