Forum

> > CS2D > Scripts > Table in Hudtxt2
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Table in Hudtxt2

13 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Table in Hudtxt2

Sudden Death
User Off Offline

Zitieren
Like in title, my question is how to show table
Mehr >

in Hudtxt2:
parse('hudtxt2 '..id..' 6 "questionbox['..math.random(1,15)..']" 120 420')

questionbox is name of table and that math.random is for random question from this table, I hope you understand what I wrote here

alt Re: Table in Hudtxt2

Alistaire
User Off Offline

Zitieren
Why did you put quotation marks around that table?

Now it will just create a hudtext saying 'questionbox['..math.random(1,15)..']', not the actual table value.

alt Re: Table in Hudtxt2

Alistaire
User Off Offline

Zitieren
So you WANT it to print 'questionbox['..math.random(1,15)..']'?

----

Srsly, remove the quotation marks.

Also, why the fuck did you add '.. and ..' at that value! You HAVE a value in your table which is called ..math.random(1,15).. ?

alt Re: Table in Hudtxt2

Sudden Death
User Off Offline

Zitieren
Ehh, you don't understand
I want to print random question from table called questionbox and I removed quotation marks but it's don't help.

alt Re: Table in Hudtxt2

Alistaire
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
questionbox = {
	[1] = 'Question 1',
	[2] = 'Question 2',
	[3] = 'Question 3',
	[4] = 'Question 4',
	[5] = 'Question 5',
	[6] = 'Question 6',
	[7] = 'Question 7',
	[8] = 'Question 8',
	[9] = 'Question 9',
	[10] = 'Question 10',
	[11] = 'Question 11',
	[12] = 'Question 12',
	[13] = 'Question 13',
	[14] = 'Question 14',
	[15] = 'Question 15'
}

parse('hudtxt2 '..id..' 6 ""..questionbox[math.random(1, 15)].."" 120 420')

alt Re: Table in Hudtxt2

Sudden Death
User Off Offline

Zitieren
Okay, it's work, thanks you
(But I have to change quotation marks from " to ', i don't understand lua >.>)

alt Re: Table in Hudtxt2

Alistaire
User Off Offline

Zitieren
Well if the text doesn't need quotation marks just delete the "".. and .."".

Also, you could make the table like;

1
questionbox = {'Question 1', 'Question 2', etc etc}

But that would create nil values in the table with the NAMES 'Question 1' and so forth. Also, the table you've made is just wrong.

1
2
3
questionbox = {
	{'s1','s2','s3','s4','s5','s6','s7','s8','s9','s10','s11','s12','s13','s14','s15'}
}

- You made a table inside a table, so it's like questionbox[1]['s1'] etc.

- The table values are nils

alt Re: Table in Hudtxt2

EngiN33R
Moderator Off Offline

Zitieren
user Alistaire hat geschrieben
Well if the text doesn't need quotation marks just delete the "".. and .."".

Also, you could make the table like;

1
questionbox = {'Question 1', 'Question 2', etc etc}

But that would create nil values in the table with the NAMES 'Question 1' and so forth. Also, the table you've made is just wrong.


user Alistaire, you're wrong.
1
2
3
questionbox = {'Question 1', 'Question 2'}
print(questionbox[1]) -> Question 1
print(questionbox[2]) -> Question 2

@thread:
1
parse('hudtxt2 '..id..' 6 '..questionbox[math.random(1,15)]..' 120 420')
Should work.

alt Re: Table in Hudtxt2

omg
User Off Offline

Zitieren
lol alistaire...i believe this is the second time u had the same misconception with tables and engineer corrected u both times

alt Re: Table in Hudtxt2

Alistaire
User Off Offline

Zitieren
user omg hat geschrieben
i believe this is the second time u had the same misconception with tables and engineer corrected u both times


Because he likes to correct people.

alt Re: Table in Hudtxt2

Avo
User Off Offline

Zitieren
I can't see what you post here dudes...

@user Sudden Death:

1
2
3
questionbox={"What's your favourite color?","What do you think about this stupid answers?","Have you got a dog?","How old are you?","Do you want to be DC for a one day?"}
local q=questionbox[math.random(1,#questionbox)]
parse('hudtxt2 '..id..' 6 "'..q..'" 120 420')

alt Re: Table in Hudtxt2

EngiN33R
Moderator Off Offline

Zitieren
@user Alistaire: I endeavour to eliminate ignorance, that's all. Usually it involves correcting others.
@user Avo: That would work, too, although there's an extra line that can be omitted.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht