Forum

> > CS2D > Scripts > Votemap script request
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Votemap script request

7 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Votemap script request

mrc
User Spielt CS2D

Zitieren
So basically Im looking for this:

if CT or T scores 13 rounds, a votemap menu appears with map A,B,C,etc including the current map. If people vote to the current map (60%), it just restarts. if people vote on othermap, then changemap.

alt Re: Votemap script request

Alpha Beta
User Off Offline

Zitieren
I tried my best. Do whatever you want with this code.

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
83
84
85
86
87
88
votemap = {}
votemap.title = "Vote for the next map"
votemap.rounds = 13
votemap.maps = {"de_dust", "de_dust2", "de_aztec"}
votemap.temptime = 0
votemap.time = 15000

votemap.votes = initArray(9)
votemap.voted = initBoolArray(32)
votemap.showmenu = true
votemap.running = false

addhook("startround", "votemap.round")
function votemap.round()
	if (game("score_t") == votemap.rounds or 
		game("score_ct") == votemap.rounds) then
		votemap.running = true
		
		parse("sv_msg Type 'vote' to vote for the next map! You have "..tostring(votemap.time/1000)	.." seconds of time.")
		
		if (votemap.showmenu) then
			for i=1, 32 do
				if (player(i, "exists")) then
					votemap.menu(i)
				end
			end
		end
	end
end

function votemap.menu(id)
	local buttons = ""
	
	for i=1, #votemap.maps do
		buttons = buttons..""..votemap.maps[i].."|"..votemap.votes[i]
		
		if not (i==#votemap.maps) then
			buttons = buttons..","
		end
	end
	
	menu(id, votemap.title..","..buttons)
end

addhook("menu", "votemap.vote")
function votemap.vote(id, menu, button)
	if (votemap.running) then
		if (menu == votemap.title) then
			if not (votemap.voted[id]) then
				votemap.votes[button] = votemap.votes[button]+1
				parse("sv_msg "..player(id, "name").." voted "..votemap.maps[button])
				votemap.voted[id] = true
			else
				parse("sv_msg2 "..id.." You voted already!@C")
			end
		end
	end
end

addhook("say", "votemap.say")
function votemap.say(id, txt)
	if (string.lower(txt) == "vote") then
		votemap.menu(id)
	end
end

addhook("second", "votemap.second")
function votemap.second()
	if (votemap.running) then
		votemap.temptime = votemap.temptime+1000
		
		parse("sv_msg "..tostring((votemap.time-votemap.temptime)/1000).." seconds left to vote!@C")
		
		if (votemap.temptime == votemap.time) then
			local indexmap = 1
			for i=1, #votemap.maps do
				if (votemap.votes[i] > votemap.votes[indexmap]) then
					print(i)
					indexmap = i
				end
			end
			
			parse("changemap "..votemap.maps[indexmap])
			
			votemap.running = false
		end
	end
end

alt Re: Votemap script request

Cure Pikachu
User Off Offline

Zitieren
Add this too.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function initBoolArray(m)
     local array = {}
     for id = 1, m do
          array[id] = false
     end
     return array
end

function initArray(m)
     local array = {}
     for id = 1, m do
          array[id] = 0
     end
     return array
end
Also user Alpha Beta's script doesn't really fulfill that requirement of yours where if the vote is on the same map as the one being played, it restarts the game instead. So for that, replace line 83 of his code with this:
1
2
3
4
5
6
if votemap.maps[indexmap] == map("name") then
	parse("restart 10")
	votemap.temptime = 0
else
	parse("changemap "..votemap.maps[indexmap])
end
1× editiert, zuletzt 31.05.20 02:19:35

alt Re: Votemap script request

Alpha Beta
User Off Offline

Zitieren
user Cure Pikachu hat geschrieben
Add this too.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function initBoolArray(m)
     local array = {}
     for id = 1, m do
          array[id] = false
     end
     return array
end

function initArray(m)
     local array = {}
     for id = 1, m do
          array[id] = 0
     end
     return array
end
Also user Alpha Beta's script doesn't really fulfill that requirement of yours where if the vote is on the same map as the one being played, it restarts the game instead. So for that, replace line 83 of his code with this:
1
2
3
4
5
6
if votemap.maps[indexmap] == map("name") then
	parse("restart 10")
	votemap.temptime = 0
else
	parse("changemap "..votemap.maps[indexmap])
end

Oh yeah I didn't copy that part for a reason.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht