Forum

> > CS2D > Scripts > C4 Map vote script
Forums overviewCS2D overview Scripts overviewLog in to reply

English C4 Map vote script

9 replies
To the start Previous 1 Next To the start

old Re: C4 Map vote script

RIP-HereRestsPlookerbooy
BANNED Off Offline

Quote
Heh,I saw it many times and I have script better than it,but, i didn't think that peoples here don't know how to do this lua.I just thought that they can easily do it and I am the only one who don't know how to..Anyway why can't anyone give me some hints is that hard?

old Re: C4 Map vote script

VADemon
User Off Offline

Quote
• You need a way to vote for/against the next map. F3/F4 or a voting menu, or a chat command.
• The white status bar is a cs2d cmd hudtxt which has the following structure:
1
2
3
4
5
votesRequired = 14 -- how many votes are needed to change map?
votesCurrent = 7 -- current YES votes. You could also take NO votes into account and change the math accordingly

voteBarLength = 12 -- how long the HUDTXT bar will be
print("|".. string.rep("=", math.floor(voteBarLength * (votesCurrent/votesRequired))) .. ">" .. string.rep(" ", math.ceil((voteBarLength+1) * (votesCurrent/votesRequired))) .. "|")

If you want a further explanation on the status bar code, feel free to ask. It looks clunky in it's finished form

old Re: C4 Map vote script

Mami Tomoe
User Off Offline

Quote
1
print("|".. string.rep("=", math.floor(voteBarLength * (votesCurrent/votesRequired))) .. ">" .. string.rep(" ", math.ceil((voteBarLength+1) * (votesCurrent/votesRequired))) .. "|")

is that meant to be a hudtxt?

old Re: C4 Map vote script

VADemon
User Off Offline

Quote
Fixed code:
1
2
3
4
5
votesRequired = 14 -- how many votes are needed to change map?
votesCurrent = 0 -- current YES votes. You could also take NO votes into account and change the math accordingly

voteBarLength = 12 -- how long the HUDTXT bar will be
print("|".. string.rep("=", math.floor(voteBarLength * (votesCurrent/votesRequired))) .. ">" .. string.rep(" ", 2* math.ceil(voteBarLength - (voteBarLength) * (votesCurrent/votesRequired))) .. "|")

• The HUDTXT became longer with every vote. FIX: voteBarLength - (voteBarLength) in the second string.rep -> the longer the left side (more YES votes), the shorter the right side
• Removed (voteBarLength + 1) as it was unnecessary and lead to bugs
• 2* because spaces has smaller size than =
edited 1×, last 22.01.16 04:57:26 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview