Forum
Scripts
Arrays
Arrays
19 replies
1

edited 1×, last 06.02.11 01:49:35 am
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function array_of_money()
	local tbl = {}
	for pl = 1,32 do
		if player(pl,"exists") then
			tbl[pl] = player(pl,"money")
		else
			tbl[pl] = 0
		end
	end
	return tbl
end
money = array_of_money()
money[1] = money of the first player
...
1
me = 1
1
me = {[1] = 1}
FN_Linkin Park has written
I dont want to be anoying but can u explain what si a table.. lol.
The table is an array, and that is like a variable, but it stores more than 1 value, to create an empty table, you need this
1
name = {}
you can write the values by yourself by 2 ways
1
name = {25,12,6,4}
that is like I write
1
2
3
4
2
3
4
name[1] = 25 name[2] = 12 name[3] = 6 name[4] = 4
this is usefull to make a variable to every player in the server, like money, lives, HP, armor, etc.
1
2
3
4
2
3
4
Health[1] = 100 Health[2] = 120 Health[3] = 107 Health[4] = 400
1
2
3
4
2
3
4
variable1 = 1 variable2 = 2 ... variable100 = 100
1
2
3
4
5
2
3
4
5
table = {}
for i = 1,100 do
	table[i] = i
end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
TileMaterial = {
[0] = "Soundless",
[1] = "Wall",
[2] = "Obstacle",
[3] = "Wall (No Shadow)",
[4] = "Obstacle (No Shadow)",
[10] = "Dirt",
[11] = "Snow",
[12] = "Step",
[13] = "Tile",
[14] = "Water",
[15] = "Metal",
[16] = "Wood",
[50] = "Deadly - Normal",
[51] = "Deadly - Explosion",
[52] = "Deadly - Toxic",
[53] = "Deadly - Abyss"
}
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
program test; uses crt; var X:array [1..5] of integer; i:byte; begin clrscr; for i:=1 to 5 do read (X[i]); end.
edited 1×, last 07.02.11 12:23:12 pm
... Crt lib is pretty useless there.
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
program Test; var X : Array[1..5] of Char; 	Y : Byte; begin 	for Y := 1 to 5 do X[Y] := Char(Random(255)); 	for Y := 1 to 5 do WriteLn(X[Y]); 	ReadLn; end.
edited 1×, last 07.02.11 10:42:56 am
1
initArray(32)

Edit: is this correct:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
----------------------------------------
--- Effects script by FN_Nemesis
--- for more info visit: Unrealsoftware.de
--- Date: 11/2/2011
----------------------------------------
Weapon tables = {
[Machinegun] = "40",
[rifles] = "30,31,32,33,38,39",
[snipers] = "34,35,36,37",
[pistols] = "1,2,3,4,5,6",
[Smg] = "20,21,22,23,24",
[Shotguns] = "10,11"}
addhook("attack","shake")
function shake(id)
if wpn == Machinegun then
parse("shake "..id.." 8")
end
end
addhook("attack","shake2")
function shake2(id)
if wpn == rifles then
parse("shake "..id.." 3")
end
end
addhook("attack","shake3")
function shake3(id)
if wpn == snipers then
parse("shake "..id.." 5")
end
end
addhook("attack","shake4")
function shake4(id)
if wpn == pistols then
parse("shake "..id.." 2")
end
end
addhook("attack","shake5")
function shake5(id)
if wpn == Smg then
parse("shake "..id.." 6")
end
end
addhook("attack","shake6")
function shake6(id)
if wpn == Shotguns then
parse("shake "..id.." 4")
end
end
addhook("hit","shake7")
function shake7(id)
parse("shake "..id.." 10")
end
edited 3×, last 19.02.11 08:06:30 pm
1

Offline