1
+ commands :Register (" vote" , function (playerid , args , argsCount , silent , prefix )
2
+ local player = GetPlayer (playerid )
3
+ if not player or not player :IsValid () then return end
4
+
5
+ if not isvoteactive then
6
+ return ReplyToCommand (playerid , config :Fetch (" map-chooser.prefix" ), FetchTranslation (" map-chooser.cannotvote" ))
7
+ end
8
+
9
+ if player :GetVar (" voted" ) ~= nil then
10
+ return ReplyToCommand (playerid , config :Fetch (" map-chooser.prefix" ), FetchTranslation (" map-chooser.alreadyvoted" ))
11
+ end
12
+
13
+ local option = args [1 ]
14
+ local mplist = config :Fetch (" map-chooser.maplist" )
15
+
16
+ if not mplist or type (mplist ) ~= " table" then
17
+ print (" Error: Map List is not valid" )
18
+ return
19
+ end
20
+
21
+ if mplist [option ] then
22
+ if not mapVotes [option ] then
23
+ mapVotes [option ] = 0
24
+ end
25
+ ReplyToCommand (playerid , config :Fetch (" map-chooser.prefix" ), FetchTranslation (" map-chooser.voted" ):gsub (" {MAP}" , mplist [option ]))
26
+ player :SetVar (" voted" , true )
27
+ mapVotes [option ] = mapVotes [option ] + 1
28
+ player :HideMenu ()
29
+ end
30
+ end )
31
+
32
+ commands :Register (" nextmap" , function (playerid , args , argsCount , silent , prefix )
33
+ local player = GetPlayer (playerid )
34
+ if not player or not player :IsValid () then return end
35
+
36
+ player :SendMsg (MessageType .Console , " Next map: " .. (nextMapName == " " and " None" or nextMapName ))
37
+ if playerid ~= - 1 then
38
+ ReplyToCommand (playerid , config :Fetch (" map-chooser.prefix" ), FetchTranslation (" map-chooser.checkconsole" ))
39
+ end
40
+ end )
41
+ commands :RegisterRawAlias (" nextmap" , " nextmap" )
42
+
43
+ commands :Register (" rtv" , function (playerid , args , argsCount , silent , prefix )
44
+ local player = GetPlayer (playerid )
45
+ if not player or not player :IsValid () then return end
46
+
47
+ if wasRTV then return ReplyToCommand (playerid , config :Fetch (" map-chooser.prefix" ), FetchTranslation (" map-chooser.alreadyrtv" )) end
48
+
49
+ rtvCount = rtvCount + 1
50
+ local requiredPlayers = math.ceil (playermanager :GetPlayerCount () / 2 )
51
+
52
+ if rtvCount >= requiredPlayers then
53
+ StartPlayersVote ()
54
+ wasRTV = true
55
+ else
56
+ return ReplyToCommand (playerid , config :Fetch (" map-chooser.prefix" ), FetchTranslation (" map-chooser.rtv" ):gsub (" {COUNT}" , rtvCount ):gsub (" {REQUIRED}" , requiredPlayers ))
57
+ end
58
+ end )
0 commit comments