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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
--main setting roundvote=15 --hooks addhook("startround", "sr") addhook("menu", "startmenu") addhook("endround", "er") --vars theround=0 voted={} themap={} votecount={} mapfiles = {} --1 setting parse("mp_roundlimit 0") --ATTENTION: If you are running windows use this (also change dir if required) os.execute("dir \"D:/CS2D/maps\"" .. " > tmpmap") --ATTENTION: If you are running an unix based os use this --os.execute("ls -a1 \"D:/CS2D/maps\"" .. " > tmpmap") --find any .maps for file1 in io.lines("tmpmap") do if file1:sub(-4) == ".map" then mapfiles[#mapfiles+1] = string.sub(file1, 40, -5) end end --pick 5 random maps, they cannot be the same themap={mapfiles[math.random(#mapfiles)],mapfiles[math.random(#mapfiles)],mapfiles[math.random(#mapfiles)],mapfiles[math.random(#mapfiles)],mapfiles[math.random(#mapfiles)]} while themap[2]==themap[1] do 	themap[2]=mapfiles[math.random(#mapfiles)] end while themap[3]==themap[1] or themap[3]==themap[2] do 	themap[3]=mapfiles[math.random(#mapfiles)] end while themap[4]==themap[1] or themap[4]==themap[2] or themap[4]==themap[3] do 	themap[4]=mapfiles[math.random(#mapfiles)] end while themap[5]==themap[1] or themap[5]==themap[2] or themap[5]==themap[3] or themap[5]==themap[4] do 	themap[5]=mapfiles[math.random(#mapfiles)] end --reset votes for all maps votecount={0, 0, 0, 0, 0} --vote menu pops up on roundvote function sr(mode) theround=theround+1 	if theround==roundvote then 	msg("255255255It's time to choose!") 	timer(2000, "choosemap") 	end end --vote dialog function startmenu(id, title, button) 	if title=="Vote Map" then 		if button > 0 then 			voted[id]=themap[button] 			msg("©255255255"..player(id, "name").." VOTED "..voted[id]..".map.") 			parse("sv_sound /player/vote.wav") 			votecount[button]=votecount[button]+1 		end 	end end --compare votes, if all are none pick a random map function er(mode) if theround == roundvote then if votecount[1] >= votecount[2] and votecount[1] >= votecount[3] and votecount[1] >= votecount[4] and votecount[1] >= votecount[5] then win(1) ; return; end if votecount[2] >= votecount[1] and votecount[2] >= votecount[3] and votecount[2] >= votecount[4] and votecount[2] >= votecount[5] then win(2) ; return; end if votecount[3] >= votecount[1] and votecount[3] >= votecount[2] and votecount[3] >= votecount[4] and votecount[3] >= votecount[5] then win(3) ; return; end if votecount[4] >= votecount[1] and votecount[4] >= votecount[2] and votecount[4] >= votecount[3] and votecount[4] >= votecount[5] then win(4) ; return; end if votecount[5] >= votecount[1] and votecount[5] >= votecount[2] and votecount[5] >= votecount[3] and votecount[5] >= votecount[4] then win(5) ; return; end end end --win map function win(number) msg("©255255255"..themap[number].." has WON by majority.") parse("sv_sound /env/mystery.wav") timer(2000, "changemap", themap[number]) end --change map with timer function changemap(map1) parse("map "..map1) end function choosemap() menu(0,"Vote Map@b,"..themap[1].."|.map,"..themap[2].."|.map,"..themap[3].."|.map,"..themap[4].."|.map,"..themap[5].."|.map") end
Vote Map - Sytem
Help me
Error in Console : LUA ERROR: sys/lua/adv.lua:26: bad argument #1 to 'random' (interval is empty)