Vote menu!
16 replies



09.03.12 11:10:26 pm
Hey I again need help! My script will finish but I think this is the last stuff to it!
So this:
First: I want to only MAP VOTE function!
Second: Remove other stuff and edit it!
Third: If you dont or cant edit I ask the creator!
So this:
Spoiler 

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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
if xvote==nil then xvote={} end
-- load configuration file
dofile("sys/lua/xvoteconfig.lua")
parse("mp_mapvoteratio 1.00")
parse("mp_kickpercent 1.00")
-- turn off automatic stuff (autoteambalance etc.) and some restrictions
parse('exec "sys/norestrictions.cfg"')
xvote.votecolor = "©000255150"
function xvote.initArray(size,value)
local array = {}
for i=1,size do
array[i]=value
end
return array
end
function xvote.getHumans()
local humans=0
for i=1,#player(0,"table") do
p=player(0,"table")[i]
if(player(p,"bot")==false) then
humans=humans+1
end
end
return humans
end
function xvote.getPlayers()
local players=0
for i=1,#player(0,"table") do
players=players+1
end
return players
end
function xvote.getMaxPlayerID()
local max = 0
for i=1,#player(0,"table") do
max = math.max(max,player(0,"table")[i])
end
return max
end
function xvote.getVotes(votetable,value)
local votes=0
for i=1,#votetable do
if(votetable[i]==value) then
votes=votes+1
end
end
return votes
end
function xvote.humans()
local table = {}
for i=1,32 do
if(player(i,"exists")) then
if(player(i,"bot")==false) then
table[#table+1]=i
end
end
end
return table
end
function xvote.players()
local table = {}
for i=1,32 do
if(player(i,"exists")) then
table[#table+1]=i
end
end
return table
end
function xvote.getMajority(votetable)
local possiblevotes = xvote.getVoteOptions(votetable)
local votecount = xvote.initArray(#possiblevotes,0)
local majority = nil
local max = 0
local humans = xvote.humans()
local id
for v=1,#humans do
id=humans[v]
for p=1,#possiblevotes do
if(votetable[id]==possiblevotes[p]) then
votecount[p] = votecount[p]+1
end
end
end
for c=1,#votecount do
if(votecount[c]>max) then
majority = possiblevotes[c]
max = votecount[c]
elseif(votecount[c]==max) then
majority = nil
end
end
return majority
end
function xvote.getVoteOptions(votetable)
local options = {}
local counted = false
for i=1,32 do
counted = false
for j=1,#options do
if(votetable[i]==options[j]) then
counted=true
end
end
if(counted==false) then
options[#options+1]=votetable[i]
end
end
return options
end
function xvote.getIDFromName(name)
for p=1,32 do
if(name==player(p,"name")) then
return p
end
end
return nil
end
function xvote.serveraction(playerID,action)
if(action == xvote.serveractionkey) then
xvote.refreshmenus()
menu(playerID, xvote.menu.game)
end
end
addhook("serveraction","xvote.serveraction",-10)
function xvote.say(playerID,text)
if(string.lower(text)=="!xvote") then
menu(playerID, xvote.menu.game)
return 1
end
return 0
end
addhook("say","xvote.say")
addhook("sayteam","xvote.say")
function xvote.votemenu(playerID,votemode,param)
local victim, map
if(votemode==1) then -- votekick
if(param~="") then
victim = xvote.getIDFromName(param)
if(victim~=nil) then
--msg(xvote.votecolor..player(playerID,"name").." votes to kick "..player(victim,"name")..".")
xvote.vote.kick[victim][playerID] = true
if(xvote.getMajority(xvote.vote.kick[victim])==true) then
parse("kick "..victim)
end
else
msg2(playerID,"©255000000This player is not on the server.@C")
end
else
for i=1,32 do
xvote.vote.kick[i][playerID] = false
end
msg(xvote.votecolor..player(playerID,"name").." withdrew the kick votes.")
end
elseif(votemode==2) then -- votemap
xvote.vote.map[playerID] = param
if(param=="") then
msg(xvote.votecolor..player(playerID,"name").." votes against mapchange.")
--[[
else
msg(xvote.votecolor..player(playerID,"name").." votes for map "..param)
]]
end
map=xvote.getMajority(xvote.vote.map)
if(map~="") then
parse("sv_map "..map)
end
end
end
addhook("vote","xvote.votemenu")
function xvote.getVoteRatio(votetable,value)
local votes = xvote.getVotes(votetable,value)
local humans =xvote.getHumans()
return ( votes/humans ) * 100
end
function xvote.voteString(votetable,vote,title)
return title.."|"..string.format('%.1f',xvote.getVoteRatio(votetable,vote)).."%"
end
function xvote.mapcycle(filter)
local maptable = {}
file = io.open(xvote.votemaps,"r")
if(filter==nil) then filter="" end
for line in io.lines("sys/mapcycle.cfg","r") do
local match = string.match(line,"^"..filter.."[^/][%w%d%p]+")
if(match ~= nil) then
table.insert(maptable,match)
end
end
file:close()
return maptable
end
function xvote.openVotemapMenu(playerID,page,filter,openmenu)
if(filter==nil) then filter="" end
if(filter=="") then space="" else space=" " end
if(openmenu==nil) then openmenu=true end
local str = "Vote for "..filter..space.."map (page "..page..")@b"
local start = 1 + (page-1)*7
local c = 1
local maps = xvote.mapcycle(filter)
for i=start,math.min(#maps,start+6) do
str = str..","..xvote.voteString(xvote.vote.map, maps[i], maps[i])
c = c+1
end
for i=c, 7 do
str = str..","
end
if(page~=1) then
str = str..",« previous page"
else
str = str..","
end
if(#maps~=math.min(#maps,start+6)) then
str = str..",next page »"
end
if(openmenu==true) then
menu(playerID,str)
end
return str
end
-- vote tables
xvote.vote = {}
xvote.vote.makespec = {}
xvote.vote.kick = {}
for i=1,32 do
xvote.vote.makespec[i] = {} -- create a new row
xvote.vote.kick[i] = {}
for j=1,32 do
xvote.vote.makespec[i][j] = false
xvote.vote.kick[i][j] = false
end
end
xvote.vote.fow = xvote.initArray(32,false) -- toggle Fog of War
xvote.vote.ff = xvote.initArray(32,false) -- toggle Friendly Fire
xvote.vote.infammo = xvote.initArray(32,false) -- toggle infinite ammo
xvote.vote.map = xvote.initArray(32,false) -- change map
xvote.vote.gamemode = xvote.initArray(32,false) -- set game mode
xvote.vote.specmode = xvote.initArray(32,false) -- set spectator mode
xvote.vote.roundtime = xvote.initArray(32,false) -- set round time
xvote.vote.freezetime = xvote.initArray(32,false) -- set freezetime
xvote.vote.buytime = xvote.initArray(32,false) -- set buytime
xvote.vote.startmoney = xvote.initArray(32,false) -- set start money
xvote.vote.curtailedexplosions = xvote.initArray(32,false)-- set curtailed explosions
xvote.vote.restart = xvote.initArray(32,false) -- restart round
xvote.menu = {}
xvote.menu.main = "XVote menu,Player,Game Options"
xvote.menu.map = "Select map type@b"
function xvote.refreshmenus()
xvote.menu.fow = "Vote for Fog of War,"..xvote.voteString(xvote.vote.fow,true,"on")..","..xvote.voteString(xvote.vote.fow,false,"off")..",(don't change)"
xvote.menu.ff = "Vote for Friendly Fire,"..xvote.voteString(xvote.vote.ff,true,"on")..","..xvote.voteString(xvote.vote.ff,false,"off")..",(don't change)"
xvote.menu.infammo = "Vote for infinite ammo"..xvote.voteString(xvote.vote.infammo,true,"on")..","..xvote.voteString(xvote.vote.infammo,false,"off")..",(don't change)"
xvote.menu.curtailedexplosions = "Vote for curtailed explosions,"..xvote.voteString(xvote.vote.curtailedexplosions,true,"on")..","..xvote.voteString(xvote.vote.curtailedexplosions,false,"off")..",(don't change)"
xvote.menu.gamemode = "Vote for game mode,"..xvote.voteString(xvote.vote.gamemode,0,"Standard")..","..xvote.voteString(xvote.vote.gamemode,1,"Deathmatch")..","..xvote.voteString(xvote.vote.gamemode,2,"Team Deathmatch")..","..xvote.voteString(xvote.vote.gamemode,3,"Construction")..","..xvote.voteString(xvote.vote.gamemode,4,"Zombies!")..",(current mode)"
xvote.menu.specmode = "Vote to allow to spectate ...,"..xvote.voteString(xvote.vote.specmode,1,"everything")..","..xvote.voteString(xvote.vote.specmode,2,"own team only")..","..xvote.voteString(xvote.vote.specmode,0,"nothing")..",(current setting)"
xvote.menu.game = "Vote game options,map,kick player,game mode,spectator mode,"..xvote.voteString(xvote.vote.fow,true,"Fog of War")..","..xvote.voteString(xvote.vote.ff,true,"Friendly Fire")..","..xvote.voteString(xvote.vote.infammo,true,"infinite ammo")..","..xvote.voteString(xvote.vote.restart,true,"restart round")..",withdraw my votes"
xvote.menu.construction = "Vote Construction options,unlimited buildings,instant build"
if(#xvote.mapcycle("") > 7) then
temp = {"","","","","","","","",""}
if(xvote.mapcycle("")~=nil) then
temp[1]="Other maps"
end
if(xvote.mapcycle("as_")~=nil) then
temp[2]="Assassination"
end
if(xvote.mapcycle("cs_")~=nil) then
temp[3]="Hostage Rescue"
end
if(xvote.mapcycle("de_")~=nil) then
temp[4]="Bomb Defuse"
end
if(xvote.mapcycle("dm_")~=nil) then
temp[5]="Deathmatch"
end
if(xvote.mapcycle("ctf_")~=nil) then
temp[6]="Capture the Flag"
end
if(xvote.mapcycle("dom_")~=nil) then
temp[7]="Domination"
end
if(xvote.mapcycle("zm_")~=nil) then
temp[8]="Zombie map"
end
if(xvote.mapcycle("gg_")~=nil) then
temp[9]="GunGame"
end
for i=1,9 do
xvote.menu.map = xvote.menu.map..","..temp[i]
end
else
xvote.menu.map = xvote.openVotemapMenu(0,1,"",false)
end
end
xvote.refreshmenus()
function xvote.clearvotes(votetable)
votetable = {}
end
function xvote.clearPlayerVotes(playerID)
xvote.vote.fow[playerID] = false
xvote.vote.ff[playerID] = false
xvote.vote.infammo[playerID] = false
xvote.vote.map[playerID] = false
xvote.vote.gamemode[playerID] = false
xvote.vote.specmode[playerID] = false
xvote.vote.roundtime[playerID] = false
xvote.vote.freezetime[playerID] = false
xvote.vote.buytime[playerID] = false
xvote.vote.startmoney[playerID] = false
xvote.vote.curtailedexplosions[playerID] = false
xvote.vote.restart[playerID] = false
for i=1,32 do
xvote.vote.kick[i][playerID] = false
xvote.vote.makespec[i][playerID] = false
end
end
function xvote.join(playerID)
xvote.clearPlayerVotes(playerID)
end
addhook("join","xvote.join")
function xvote.leave(playerID,reason)
xvote.clearPlayerVotes(playerID)
end
addhook("leave","xvote.leave")
function xvote.toggle(votetable, playerID, option, condition, positive, negative, name)
if(votetable[playerID]~=true) then
votetable[playerID]=true
msg(xvote.votecolor..player(playerID,"name").." votes to toggle "..name..".")
parse('sv_sound "player/vote.wav"')
end
if(xvote.getMajority(votetable)==true) then
if(tonumber(game(option))==condition) then
parse(negative)
else
parse(positive)
end
return true
end
return false
end
function xvote.openVotekickMenu(playerID,page)
local str = "Vote to kick player (page "..page..")"
local start = 1 + (page-1)*7
local c = 1
for i=start,math.min(xvote.getPlayers(),start+6) do
p = xvote.players()[i]
if(player(p,"exists")) then
str = str..","..xvote.voteString(xvote.vote.kick[p], true, player(p,"name"))
else
str = str..","
end
c = c+1
end
for i=c, 7 do
str = str..","
end
if(page~=1) then
str = str..",« previous page"
else
str = str..","
end
if(xvote.getPlayers()~=math.min(xvote.getPlayers(),start+6)) then
str = str..",next page »"
end
menu(playerID,str)
return str
end
function xvote.menucall(playerID,title,button)
if(title=="Vote game options") then
if(button==1) then
--xvote.openVotemapMenu(playerID,1)
menu(playerID,xvote.menu.map)
elseif(button==5) then
if(xvote.toggle(xvote.vote.fow, playerID, "sv_fow", 1, "sv_fow 1", "sv_fow 0", "Fog of War")) then
xvote.vote.fow = xvote.initArray(32,false)
end
elseif(button==6) then
if(xvote.toggle(xvote.vote.ff, playerID, "sv_friendlyfire", 1, "sv_friendlyfire 1", "sv_friendlyfire 0", "Friendly Fire")) then
xvote.vote.ff = xvote.initArray(32,false)
end
elseif(button==7) then
if(xvote.toggle(xvote.vote.infammo, playerID, "mp_infammo", 1, "mp_infammo 1", "mp_infammo 0", "infinite ammo")) then
xvote.vote.infammo = xvote.initArray(32,false)
end
elseif(button==3) then
menu(playerID,xvote.menu.gamemode)
elseif(button==4) then
menu(playerID,xvote.menu.specmode)
elseif(button==2) then
xvote.openVotekickMenu(playerID,1)
elseif(button==8) then
if(xvote.vote.restart~=true) then
xvote.vote.restart[playerID]=true
msg(xvote.votecolor..player(playerID,"name").." votes for a round restart.")
end
if(xvote.getMajority(xvote.vote.restart)==true) then
parse("sv_restartround")
xvote.vote.restart = xvote.initArray(32,false)
end
elseif(button==9) then
xvote.clearPlayerVotes(playerID)
msg(xvote.votecolor..player(playerID,"name").." withdraws his votes.")
end
elseif(title=="Vote for game mode") then
if(button>=1 and button<=5) then
xvote.vote.gamemode[playerID] = button-1
if(xvote.vote.gamemode[playerID]==0) then
msg(xvote.votecolor..player(playerID,"name").." votes the gamemode Standard.")
elseif(xvote.vote.gamemode[playerID]==1) then
msg(xvote.votecolor..player(playerID,"name").." votes the gamemode Deathmatch.")
elseif(xvote.vote.gamemode[playerID]==2) then
msg(xvote.votecolor..player(playerID,"name").." votes the gamemode Team Deathmatch.")
elseif(xvote.vote.gamemode[playerID]==3) then
msg(xvote.votecolor..player(playerID,"name").." votes the gamemode Construction.")
elseif(xvote.vote.gamemode[playerID]==4) then
msg(xvote.votecolor..player(playerID,"name").." votes the gamemode Zombies!")
end
parse('sv_sound "player/vote.wav"')
if(xvote.getMajority(xvote.vote.gamemode)~=false and xvote.getMajority(xvote.vote.gamemode)~=nil) then
parse("sv_gamemode "..xvote.vote.gamemode[playerID])
xvote.vote.gamemode = xvote.initArray(32,false)
end
elseif(button==6) then
xvote.vote.gamemode[playerID] = false
msg(xvote.votecolor..player(playerID,"name").." withdraws the vote on gamemode.")
end
elseif(title=="Vote to allow to spectate ...") then
if (button==1) then
xvote.vote.specmode[playerID] = 1 -- everything
msg(xvote.votecolor..player(playerID,"name").." votes to allow full spectating.")
elseif(button==2) then
xvote.vote.specmode[playerID] = 2 -- own team only
msg(xvote.votecolor..player(playerID,"name").." votes to to allow spectating own team only.")
elseif(button==3) then
xvote.vote.specmode[playerID] = 0 -- nothing
msg(xvote.votecolor..player(playerID,"name").." votes to disable spectating.")
elseif(button==4) then
xvote.vote.specmode[playerID] = false
msg(xvote.votecolor..player(playerID,"name").." withdraws the vote on spectating mode.")
end
parse('sv_sound "player/vote.wav"')
if(xvote.getMajority(xvote.vote.specmode)~=false and xvote.getMajority(xvote.vote.specmode)~=nil) then
parse("sv_specmode "..xvote.vote.specmode[playerID])
xvote.vote.specmode = xvote.initArray(32,false)
end
elseif(title=="Select map type") then
if(button==1) then
xvote.openVotemapMenu(playerID,1,"")
elseif(button==2) then
xvote.openVotemapMenu(playerID,1,"as_")
elseif(button==3) then
xvote.openVotemapMenu(playerID,1,"cs_")
elseif(button==4) then
xvote.openVotemapMenu(playerID,1,"de_")
elseif(button==5) then
xvote.openVotemapMenu(playerID,1,"dm_")
elseif(button==6) then
xvote.openVotemapMenu(playerID,1,"ctf_")
elseif(button==7) then
xvote.openVotemapMenu(playerID,1,"dom_")
elseif(button==8) then
xvote.openVotemapMenu(playerID,1,"zm_")
elseif(button==9) then
xvote.openVotemapMenu(playerID,1,"gg_")
end
elseif(string.sub(title,1,9)=="Vote for " and string.match(title,"map")~=nil) then
local page = string.match(title,"(%d+)")
local filter = string.match(title,"%a+_")
if filter==nil then filter="" end
local start = (page-1)*7
if(button>=1 and button<=7) then
maps=xvote.mapcycle(filter)
map = start+button
xvote.vote.map[playerID] = maps[map]
msg(xvote.votecolor..player(playerID,"name").." votes the map "..maps[map]..".")
parse('sv_sound "player/vote.wav"')
if(xvote.getMajority(xvote.vote.map)==maps[map]) then
parse("sv_map "..maps[map])
end
elseif(button==8) then
xvote.openVotemapMenu(playerID,page-1,filter)
elseif(button==9) then
xvote.openVotemapMenu(playerID,page+1,filter)
end
elseif(string.sub(title,1,19)=="Vote to kick player") then
local page = string.match(title,"(%d+)")
local start = (page-1)*7
if(button>=1 and button<=7) then
victim = xvote.players()[start+button]
xvote.vote.kick[victim][playerID] = true
msg(xvote.votecolor..player(playerID,"name").." votes to kick "..player(victim,"name")..".")
parse('sv_sound "player/vote.wav"')
if(xvote.getMajority(xvote.vote.kick[victim])==true) then
parse("kick "..victim)
end
elseif(button==8) then
xvote.openVotekickMenu(playerID,page-1)
elseif(button==9) then
xvote.openVotekickMenu(playerID,page+1)
end
end
end
addhook("menu","xvote.menucall")
-- load configuration file
dofile("sys/lua/xvoteconfig.lua")
parse("mp_mapvoteratio 1.00")
parse("mp_kickpercent 1.00")
-- turn off automatic stuff (autoteambalance etc.) and some restrictions
parse('exec "sys/norestrictions.cfg"')
xvote.votecolor = "©000255150"
function xvote.initArray(size,value)
local array = {}
for i=1,size do
array[i]=value
end
return array
end
function xvote.getHumans()
local humans=0
for i=1,#player(0,"table") do
p=player(0,"table")[i]
if(player(p,"bot")==false) then
humans=humans+1
end
end
return humans
end
function xvote.getPlayers()
local players=0
for i=1,#player(0,"table") do
players=players+1
end
return players
end
function xvote.getMaxPlayerID()
local max = 0
for i=1,#player(0,"table") do
max = math.max(max,player(0,"table")[i])
end
return max
end
function xvote.getVotes(votetable,value)
local votes=0
for i=1,#votetable do
if(votetable[i]==value) then
votes=votes+1
end
end
return votes
end
function xvote.humans()
local table = {}
for i=1,32 do
if(player(i,"exists")) then
if(player(i,"bot")==false) then
table[#table+1]=i
end
end
end
return table
end
function xvote.players()
local table = {}
for i=1,32 do
if(player(i,"exists")) then
table[#table+1]=i
end
end
return table
end
function xvote.getMajority(votetable)
local possiblevotes = xvote.getVoteOptions(votetable)
local votecount = xvote.initArray(#possiblevotes,0)
local majority = nil
local max = 0
local humans = xvote.humans()
local id
for v=1,#humans do
id=humans[v]
for p=1,#possiblevotes do
if(votetable[id]==possiblevotes[p]) then
votecount[p] = votecount[p]+1
end
end
end
for c=1,#votecount do
if(votecount[c]>max) then
majority = possiblevotes[c]
max = votecount[c]
elseif(votecount[c]==max) then
majority = nil
end
end
return majority
end
function xvote.getVoteOptions(votetable)
local options = {}
local counted = false
for i=1,32 do
counted = false
for j=1,#options do
if(votetable[i]==options[j]) then
counted=true
end
end
if(counted==false) then
options[#options+1]=votetable[i]
end
end
return options
end
function xvote.getIDFromName(name)
for p=1,32 do
if(name==player(p,"name")) then
return p
end
end
return nil
end
function xvote.serveraction(playerID,action)
if(action == xvote.serveractionkey) then
xvote.refreshmenus()
menu(playerID, xvote.menu.game)
end
end
addhook("serveraction","xvote.serveraction",-10)
function xvote.say(playerID,text)
if(string.lower(text)=="!xvote") then
menu(playerID, xvote.menu.game)
return 1
end
return 0
end
addhook("say","xvote.say")
addhook("sayteam","xvote.say")
function xvote.votemenu(playerID,votemode,param)
local victim, map
if(votemode==1) then -- votekick
if(param~="") then
victim = xvote.getIDFromName(param)
if(victim~=nil) then
--msg(xvote.votecolor..player(playerID,"name").." votes to kick "..player(victim,"name")..".")
xvote.vote.kick[victim][playerID] = true
if(xvote.getMajority(xvote.vote.kick[victim])==true) then
parse("kick "..victim)
end
else
msg2(playerID,"©255000000This player is not on the server.@C")
end
else
for i=1,32 do
xvote.vote.kick[i][playerID] = false
end
msg(xvote.votecolor..player(playerID,"name").." withdrew the kick votes.")
end
elseif(votemode==2) then -- votemap
xvote.vote.map[playerID] = param
if(param=="") then
msg(xvote.votecolor..player(playerID,"name").." votes against mapchange.")
--[[
else
msg(xvote.votecolor..player(playerID,"name").." votes for map "..param)
]]
end
map=xvote.getMajority(xvote.vote.map)
if(map~="") then
parse("sv_map "..map)
end
end
end
addhook("vote","xvote.votemenu")
function xvote.getVoteRatio(votetable,value)
local votes = xvote.getVotes(votetable,value)
local humans =xvote.getHumans()
return ( votes/humans ) * 100
end
function xvote.voteString(votetable,vote,title)
return title.."|"..string.format('%.1f',xvote.getVoteRatio(votetable,vote)).."%"
end
function xvote.mapcycle(filter)
local maptable = {}
file = io.open(xvote.votemaps,"r")
if(filter==nil) then filter="" end
for line in io.lines("sys/mapcycle.cfg","r") do
local match = string.match(line,"^"..filter.."[^/][%w%d%p]+")
if(match ~= nil) then
table.insert(maptable,match)
end
end
file:close()
return maptable
end
function xvote.openVotemapMenu(playerID,page,filter,openmenu)
if(filter==nil) then filter="" end
if(filter=="") then space="" else space=" " end
if(openmenu==nil) then openmenu=true end
local str = "Vote for "..filter..space.."map (page "..page..")@b"
local start = 1 + (page-1)*7
local c = 1
local maps = xvote.mapcycle(filter)
for i=start,math.min(#maps,start+6) do
str = str..","..xvote.voteString(xvote.vote.map, maps[i], maps[i])
c = c+1
end
for i=c, 7 do
str = str..","
end
if(page~=1) then
str = str..",« previous page"
else
str = str..","
end
if(#maps~=math.min(#maps,start+6)) then
str = str..",next page »"
end
if(openmenu==true) then
menu(playerID,str)
end
return str
end
-- vote tables
xvote.vote = {}
xvote.vote.makespec = {}
xvote.vote.kick = {}
for i=1,32 do
xvote.vote.makespec[i] = {} -- create a new row
xvote.vote.kick[i] = {}
for j=1,32 do
xvote.vote.makespec[i][j] = false
xvote.vote.kick[i][j] = false
end
end
xvote.vote.fow = xvote.initArray(32,false) -- toggle Fog of War
xvote.vote.ff = xvote.initArray(32,false) -- toggle Friendly Fire
xvote.vote.infammo = xvote.initArray(32,false) -- toggle infinite ammo
xvote.vote.map = xvote.initArray(32,false) -- change map
xvote.vote.gamemode = xvote.initArray(32,false) -- set game mode
xvote.vote.specmode = xvote.initArray(32,false) -- set spectator mode
xvote.vote.roundtime = xvote.initArray(32,false) -- set round time
xvote.vote.freezetime = xvote.initArray(32,false) -- set freezetime
xvote.vote.buytime = xvote.initArray(32,false) -- set buytime
xvote.vote.startmoney = xvote.initArray(32,false) -- set start money
xvote.vote.curtailedexplosions = xvote.initArray(32,false)-- set curtailed explosions
xvote.vote.restart = xvote.initArray(32,false) -- restart round
xvote.menu = {}
xvote.menu.main = "XVote menu,Player,Game Options"
xvote.menu.map = "Select map type@b"
function xvote.refreshmenus()
xvote.menu.fow = "Vote for Fog of War,"..xvote.voteString(xvote.vote.fow,true,"on")..","..xvote.voteString(xvote.vote.fow,false,"off")..",(don't change)"
xvote.menu.ff = "Vote for Friendly Fire,"..xvote.voteString(xvote.vote.ff,true,"on")..","..xvote.voteString(xvote.vote.ff,false,"off")..",(don't change)"
xvote.menu.infammo = "Vote for infinite ammo"..xvote.voteString(xvote.vote.infammo,true,"on")..","..xvote.voteString(xvote.vote.infammo,false,"off")..",(don't change)"
xvote.menu.curtailedexplosions = "Vote for curtailed explosions,"..xvote.voteString(xvote.vote.curtailedexplosions,true,"on")..","..xvote.voteString(xvote.vote.curtailedexplosions,false,"off")..",(don't change)"
xvote.menu.gamemode = "Vote for game mode,"..xvote.voteString(xvote.vote.gamemode,0,"Standard")..","..xvote.voteString(xvote.vote.gamemode,1,"Deathmatch")..","..xvote.voteString(xvote.vote.gamemode,2,"Team Deathmatch")..","..xvote.voteString(xvote.vote.gamemode,3,"Construction")..","..xvote.voteString(xvote.vote.gamemode,4,"Zombies!")..",(current mode)"
xvote.menu.specmode = "Vote to allow to spectate ...,"..xvote.voteString(xvote.vote.specmode,1,"everything")..","..xvote.voteString(xvote.vote.specmode,2,"own team only")..","..xvote.voteString(xvote.vote.specmode,0,"nothing")..",(current setting)"
xvote.menu.game = "Vote game options,map,kick player,game mode,spectator mode,"..xvote.voteString(xvote.vote.fow,true,"Fog of War")..","..xvote.voteString(xvote.vote.ff,true,"Friendly Fire")..","..xvote.voteString(xvote.vote.infammo,true,"infinite ammo")..","..xvote.voteString(xvote.vote.restart,true,"restart round")..",withdraw my votes"
xvote.menu.construction = "Vote Construction options,unlimited buildings,instant build"
if(#xvote.mapcycle("") > 7) then
temp = {"","","","","","","","",""}
if(xvote.mapcycle("")~=nil) then
temp[1]="Other maps"
end
if(xvote.mapcycle("as_")~=nil) then
temp[2]="Assassination"
end
if(xvote.mapcycle("cs_")~=nil) then
temp[3]="Hostage Rescue"
end
if(xvote.mapcycle("de_")~=nil) then
temp[4]="Bomb Defuse"
end
if(xvote.mapcycle("dm_")~=nil) then
temp[5]="Deathmatch"
end
if(xvote.mapcycle("ctf_")~=nil) then
temp[6]="Capture the Flag"
end
if(xvote.mapcycle("dom_")~=nil) then
temp[7]="Domination"
end
if(xvote.mapcycle("zm_")~=nil) then
temp[8]="Zombie map"
end
if(xvote.mapcycle("gg_")~=nil) then
temp[9]="GunGame"
end
for i=1,9 do
xvote.menu.map = xvote.menu.map..","..temp[i]
end
else
xvote.menu.map = xvote.openVotemapMenu(0,1,"",false)
end
end
xvote.refreshmenus()
function xvote.clearvotes(votetable)
votetable = {}
end
function xvote.clearPlayerVotes(playerID)
xvote.vote.fow[playerID] = false
xvote.vote.ff[playerID] = false
xvote.vote.infammo[playerID] = false
xvote.vote.map[playerID] = false
xvote.vote.gamemode[playerID] = false
xvote.vote.specmode[playerID] = false
xvote.vote.roundtime[playerID] = false
xvote.vote.freezetime[playerID] = false
xvote.vote.buytime[playerID] = false
xvote.vote.startmoney[playerID] = false
xvote.vote.curtailedexplosions[playerID] = false
xvote.vote.restart[playerID] = false
for i=1,32 do
xvote.vote.kick[i][playerID] = false
xvote.vote.makespec[i][playerID] = false
end
end
function xvote.join(playerID)
xvote.clearPlayerVotes(playerID)
end
addhook("join","xvote.join")
function xvote.leave(playerID,reason)
xvote.clearPlayerVotes(playerID)
end
addhook("leave","xvote.leave")
function xvote.toggle(votetable, playerID, option, condition, positive, negative, name)
if(votetable[playerID]~=true) then
votetable[playerID]=true
msg(xvote.votecolor..player(playerID,"name").." votes to toggle "..name..".")
parse('sv_sound "player/vote.wav"')
end
if(xvote.getMajority(votetable)==true) then
if(tonumber(game(option))==condition) then
parse(negative)
else
parse(positive)
end
return true
end
return false
end
function xvote.openVotekickMenu(playerID,page)
local str = "Vote to kick player (page "..page..")"
local start = 1 + (page-1)*7
local c = 1
for i=start,math.min(xvote.getPlayers(),start+6) do
p = xvote.players()[i]
if(player(p,"exists")) then
str = str..","..xvote.voteString(xvote.vote.kick[p], true, player(p,"name"))
else
str = str..","
end
c = c+1
end
for i=c, 7 do
str = str..","
end
if(page~=1) then
str = str..",« previous page"
else
str = str..","
end
if(xvote.getPlayers()~=math.min(xvote.getPlayers(),start+6)) then
str = str..",next page »"
end
menu(playerID,str)
return str
end
function xvote.menucall(playerID,title,button)
if(title=="Vote game options") then
if(button==1) then
--xvote.openVotemapMenu(playerID,1)
menu(playerID,xvote.menu.map)
elseif(button==5) then
if(xvote.toggle(xvote.vote.fow, playerID, "sv_fow", 1, "sv_fow 1", "sv_fow 0", "Fog of War")) then
xvote.vote.fow = xvote.initArray(32,false)
end
elseif(button==6) then
if(xvote.toggle(xvote.vote.ff, playerID, "sv_friendlyfire", 1, "sv_friendlyfire 1", "sv_friendlyfire 0", "Friendly Fire")) then
xvote.vote.ff = xvote.initArray(32,false)
end
elseif(button==7) then
if(xvote.toggle(xvote.vote.infammo, playerID, "mp_infammo", 1, "mp_infammo 1", "mp_infammo 0", "infinite ammo")) then
xvote.vote.infammo = xvote.initArray(32,false)
end
elseif(button==3) then
menu(playerID,xvote.menu.gamemode)
elseif(button==4) then
menu(playerID,xvote.menu.specmode)
elseif(button==2) then
xvote.openVotekickMenu(playerID,1)
elseif(button==8) then
if(xvote.vote.restart~=true) then
xvote.vote.restart[playerID]=true
msg(xvote.votecolor..player(playerID,"name").." votes for a round restart.")
end
if(xvote.getMajority(xvote.vote.restart)==true) then
parse("sv_restartround")
xvote.vote.restart = xvote.initArray(32,false)
end
elseif(button==9) then
xvote.clearPlayerVotes(playerID)
msg(xvote.votecolor..player(playerID,"name").." withdraws his votes.")
end
elseif(title=="Vote for game mode") then
if(button>=1 and button<=5) then
xvote.vote.gamemode[playerID] = button-1
if(xvote.vote.gamemode[playerID]==0) then
msg(xvote.votecolor..player(playerID,"name").." votes the gamemode Standard.")
elseif(xvote.vote.gamemode[playerID]==1) then
msg(xvote.votecolor..player(playerID,"name").." votes the gamemode Deathmatch.")
elseif(xvote.vote.gamemode[playerID]==2) then
msg(xvote.votecolor..player(playerID,"name").." votes the gamemode Team Deathmatch.")
elseif(xvote.vote.gamemode[playerID]==3) then
msg(xvote.votecolor..player(playerID,"name").." votes the gamemode Construction.")
elseif(xvote.vote.gamemode[playerID]==4) then
msg(xvote.votecolor..player(playerID,"name").." votes the gamemode Zombies!")
end
parse('sv_sound "player/vote.wav"')
if(xvote.getMajority(xvote.vote.gamemode)~=false and xvote.getMajority(xvote.vote.gamemode)~=nil) then
parse("sv_gamemode "..xvote.vote.gamemode[playerID])
xvote.vote.gamemode = xvote.initArray(32,false)
end
elseif(button==6) then
xvote.vote.gamemode[playerID] = false
msg(xvote.votecolor..player(playerID,"name").." withdraws the vote on gamemode.")
end
elseif(title=="Vote to allow to spectate ...") then
if (button==1) then
xvote.vote.specmode[playerID] = 1 -- everything
msg(xvote.votecolor..player(playerID,"name").." votes to allow full spectating.")
elseif(button==2) then
xvote.vote.specmode[playerID] = 2 -- own team only
msg(xvote.votecolor..player(playerID,"name").." votes to to allow spectating own team only.")
elseif(button==3) then
xvote.vote.specmode[playerID] = 0 -- nothing
msg(xvote.votecolor..player(playerID,"name").." votes to disable spectating.")
elseif(button==4) then
xvote.vote.specmode[playerID] = false
msg(xvote.votecolor..player(playerID,"name").." withdraws the vote on spectating mode.")
end
parse('sv_sound "player/vote.wav"')
if(xvote.getMajority(xvote.vote.specmode)~=false and xvote.getMajority(xvote.vote.specmode)~=nil) then
parse("sv_specmode "..xvote.vote.specmode[playerID])
xvote.vote.specmode = xvote.initArray(32,false)
end
elseif(title=="Select map type") then
if(button==1) then
xvote.openVotemapMenu(playerID,1,"")
elseif(button==2) then
xvote.openVotemapMenu(playerID,1,"as_")
elseif(button==3) then
xvote.openVotemapMenu(playerID,1,"cs_")
elseif(button==4) then
xvote.openVotemapMenu(playerID,1,"de_")
elseif(button==5) then
xvote.openVotemapMenu(playerID,1,"dm_")
elseif(button==6) then
xvote.openVotemapMenu(playerID,1,"ctf_")
elseif(button==7) then
xvote.openVotemapMenu(playerID,1,"dom_")
elseif(button==8) then
xvote.openVotemapMenu(playerID,1,"zm_")
elseif(button==9) then
xvote.openVotemapMenu(playerID,1,"gg_")
end
elseif(string.sub(title,1,9)=="Vote for " and string.match(title,"map")~=nil) then
local page = string.match(title,"(%d+)")
local filter = string.match(title,"%a+_")
if filter==nil then filter="" end
local start = (page-1)*7
if(button>=1 and button<=7) then
maps=xvote.mapcycle(filter)
map = start+button
xvote.vote.map[playerID] = maps[map]
msg(xvote.votecolor..player(playerID,"name").." votes the map "..maps[map]..".")
parse('sv_sound "player/vote.wav"')
if(xvote.getMajority(xvote.vote.map)==maps[map]) then
parse("sv_map "..maps[map])
end
elseif(button==8) then
xvote.openVotemapMenu(playerID,page-1,filter)
elseif(button==9) then
xvote.openVotemapMenu(playerID,page+1,filter)
end
elseif(string.sub(title,1,19)=="Vote to kick player") then
local page = string.match(title,"(%d+)")
local start = (page-1)*7
if(button>=1 and button<=7) then
victim = xvote.players()[start+button]
xvote.vote.kick[victim][playerID] = true
msg(xvote.votecolor..player(playerID,"name").." votes to kick "..player(victim,"name")..".")
parse('sv_sound "player/vote.wav"')
if(xvote.getMajority(xvote.vote.kick[victim])==true) then
parse("kick "..victim)
end
elseif(button==8) then
xvote.openVotekickMenu(playerID,page-1)
elseif(button==9) then
xvote.openVotekickMenu(playerID,page+1)
end
end
end
addhook("menu","xvote.menucall")
First: I want to only MAP VOTE function!
Second: Remove other stuff and edit it!
Third: If you dont or cant edit I ask the creator!
edited 1×, last 18.04.12 05:44:04 pm
© Unreal Software, 2003-2021 | This website is using cookies because they are delicious | Disclaimer | Site Notice
because it's hard to edit


Kel, use tables

A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV

look this here
XVote - Extended Vote System 1.0 (31)


*facepalm*
I want to this script edited version
EDIT: Ok I fixed my problem but i have a new! On maplist just are the maps showing full name where I dont use SPACE BUTTON! How to fix this?
edited 1×, last 10.03.12 03:54:44 pm
put it in " and "
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV

Post Here the file : xvoteconfig
Code:
1
dofile("sys/lua/xvoteconfig.lua")
What do you mean with that?
You should say that this line
goes in cs2d/sys/lua/server.lua.
Code:
1
dofile("sys/lua/xvoteconfig.lua")
goes in cs2d/sys/lua/server.lua.

Spoiler 

--[[ option: xvote.serveractionkey (default: 3)
binds (or not) the key for opening the XVote menu
possible values:
1 bind XVote menu to serveraction1 [F2]
2 bind XVote menu to serveraction2 [F3]
3 bind XVote menu to serveraction3 [F4]
false don't bind the menu it to any key
annotations:
the vote menu can always be opened by saying "!xvote" in chat
]]
xvote.serveractionkey = 3
--[[ option: xvote.votemaps (default: "sys/mapcycle.cfg")
controls which maps are available for vote
possible values:
a string with the path relative to the CS2D directory pointing to
a file which holds a list with all map names
annotations:
The map names must be at the beginning of each line.
The map names mustn't have any spaces.
Characters after the first space will be ignored.
Empty lines and lines starting with "//" will be ignored.
Be sure that ALL selected maps are playable and doesn't
make CS2D crash. Otherwise, your server will crash
as soon the players vote for an 'invalid' map, i.e. a
map which hasn't any spawn points set.
]]
xvote.votemaps = "sys/mapcycle.cfg"
binds (or not) the key for opening the XVote menu
possible values:
1 bind XVote menu to serveraction1 [F2]
2 bind XVote menu to serveraction2 [F3]
3 bind XVote menu to serveraction3 [F4]
false don't bind the menu it to any key
annotations:
the vote menu can always be opened by saying "!xvote" in chat
]]
xvote.serveractionkey = 3
--[[ option: xvote.votemaps (default: "sys/mapcycle.cfg")
controls which maps are available for vote
possible values:
a string with the path relative to the CS2D directory pointing to
a file which holds a list with all map names
annotations:
The map names must be at the beginning of each line.
The map names mustn't have any spaces.
Characters after the first space will be ignored.
Empty lines and lines starting with "//" will be ignored.
Be sure that ALL selected maps are playable and doesn't
make CS2D crash. Otherwise, your server will crash
as soon the players vote for an 'invalid' map, i.e. a
map which hasn't any spawn points set.
]]
xvote.votemaps = "sys/mapcycle.cfg"
This?



