//written by Lighto //players can cast a map votation like the ingame votes, why that isnt in the game btw //V5 18/02/'25 --tiref of hot fixing, phewV4 16-17/02/'25 --v3 24/10/'24' v2 quickest hotfix ever v3 quickest hotfix of hotfix ever if not LTB_vote then rawset(_G,"LTB_vote",{ isvoting = false, caller = -1, map = "northern district" , forcemap = '', encore = '', time = 0, votes = 0, voters = {}, cooldown = 0, topass = 0, passed = 0, failed = 0, oldvotes = {} }) end local votetime,votegoodtime,votebadtime,voteerrtime,mapspamtime,voterspamtime,votelimittime,pseudoleveltime local wannavote,voteslide,x,y,xs,flags, vtbtn, myvote, forcerelease,slide2,voterid x = 322 y = 170 - 10 voteslide = FRACUNIT flags = V_SNAPTOTOP|V_SNAPTORIGHT vtbtn = {"TLB_F","TLB_FB",""} myvote = 0 forcerelease = false slide2 = FRACUNIT pseudoleveltime = 0 voterid = 1 votetime = CV_RegisterVar({ name = "l_vote_votetime", defaultvalue = 15, flags = CV_NETVAR, PossibleValue = CV_Unsigned}).value votegoodtime = CV_RegisterVar({ name = "l_vote_passcd", defaultvalue = 30, flags = CV_NETVAR, PossibleValue = CV_Unsigned}).value votebadtime = CV_RegisterVar({ name = "l_vote_failcd", defaultvalue = 8, flags = CV_NETVAR, PossibleValue = CV_Unsigned}).value voteerrtime = CV_RegisterVar({ name = "l_vote_errorcd", defaultvalue = 4, flags = CV_NETVAR, PossibleValue = CV_Unsigned}).value mapspamtime = CV_RegisterVar({ name = "l_vote_spamcd", defaultvalue = 60*8, flags = CV_NETVAR, PossibleValue = CV_Unsigned}).value voterspamtime = CV_RegisterVar({ name = "l_vote_playerspamcd", defaultvalue = 60*4, flags = CV_NETVAR, PossibleValue = CV_Unsigned}).value votelimittime = CV_RegisterVar({ name = "l_vote_limittime", defaultvalue = 60, flags = CV_NETVAR, PossibleValue = CV_Unsigned}).value local function initpvote(p) if p.LTB_vote == nil then p.LTB_vote = {} p.LTB_vote.zb = false p.LTB_vote.init = true p.LTB_vote.forcerelease = false p.LTB_vote.wannavote = false p.LTB_vote.myvote = 0 p.LTB_vote.spamcooldown = 0 p.LTB_vote.id = voterid p.LTB_vote.dedi = isdedicatedserver//not isdedicatedserver and p == server voterid = $ + 1 else //p.LTB_vote = {} p.LTB_vote.zb = false p.LTB_vote.init = true p.LTB_vote.forcerelease = false p.LTB_vote.wannavote = false p.LTB_vote.myvote = 0 p.LTB_vote.dedi = isdedicatedserver //p.LTB_vote.spamcooldown = 0 end end local function resetvars() x = 322 y = 170 - 10 voteslide = FRACUNIT flags = V_SNAPTOTOP|V_SNAPTORIGHT vtbtn = {"TLB_F","TLB_FB",""} myvote = 0 forcerelease = false slide2 = FRACUNIT pseudoleveltime = 0 LTB_vote.isvoting = false LTB_vote.voters = {} LTB_vote.time = 0 LTB_vote.votes = 0 LTB_vote.topass = 0 LTB_vote.voter = -1 LTB_vote.passed = 0 LTB_vote.failed = 0 LTB_vote.forcemap = '' LTB_vote.encore = '' for p in players.iterate do initpvote(p) end end local function fontspacing(v,str) return v.stringWidth(str, V_SNAPTOTOP|V_SNAPTORIGHT) end local function timeleft(time) return (G_TicsToMinutes(time)+' minutes and '+G_TicsToSeconds(time)+' seconds') end //synch to joiners addHook("NetVars",function(net) LTB_vote = net($) pseudoleveltime = net($) --THAT TOO voterid = net($) end) ---ooooooooooooooops.... COM_AddCommand("vm", function(p,...) local args ='' for _, i in ipairs({...}) do args = $ + i + ' ' end COM_BufInsertText(p,'votemap '+ args) end) COM_AddCommand("l_vote_clearlist", function(p) if not IsPlayerAdmin(p) and p ~= server then CONS_Printf(p,"only server or admin can do that, nice try, you getting banned btw") CONS_Printf(server,"MAPVOTE > "..p.name.." tried to clear the old vote queue,mhm") return end LTB_vote.oldvotes = {} CONS_Printf(p,"previous votes list cleared") CONS_Printf(server,"MAPVOTE > "..p.name.." cleared old map vote list") end) COM_AddCommand("l_vote_forgive", function(p,...) if not {...} or #{...} == 0 then CONS_Printf(p,"no argument given, give a player name (can have spaced) or the player node") return end local name = '' for _, i in ipairs({...}) do name = $ + i if _ > 1 and _ < #{...} then name = $ + ' ' end end if not IsPlayerAdmin(p) and p ~= server then CONS_Printf(p,"only server or admin can do that, nice try, you getting banned btw") CONS_Printf(server,"MAPVOTE > "..p.name.." tried to forigve someone cooldown,mhm") return end name = tostring($) if type(tonumber(name)) == "number" then local found = false for op in players.iterate do if op and op.valid and op.LTB_vote and op.LTB_vote.spamcooldown > 0 and #op == tonumber(name) then found = true op.LTB_vote.spamcooldown = 0 CONS_Printf(p,op.name.." spam punishment lifted") CONS_Printf(op,p.name.." has lifted your spamming cooldown ,behave, now you? have fun") CONS_Printf(server,"MAPVOTE > "..p.name.." lifted ban of "..op.name) return end end if found == false then CONS_Printf(p,"no match for "..name) return end else//elseif type(name) == "string" then local found = false for op in players.iterate do if op and op.valid and op.LTB_vote and op.LTB_vote.spamcooldown > 0 and op.name == name then found = true op.LTB_vote.spamcooldown = 0 CONS_Printf(p,op.name.." spam punishment lifted") CONS_Printf(op,p.name.." has lifted your spamming cooldown ,behave, now you? have fun") CONS_Printf(server,"MAPVOTE > "..p.name.." lifted ban of "..op.name) return end end if found == false then CONS_Printf(p,"no match for "..name) return end end end) COM_AddCommand("votemap", function(p,...) if not p then CONS_Printf(server,"someone tried a command but died?????") return end if not p.LTB_vote then initpvote(p) end --BRUUUUU if p.LTB_vote.spamcooldown > 0 then CONS_Printf(p,"youre in cooldown for spamming too many votes, beehave, "+timeleft(p.LTB_vote.spamcooldown).." for you ban to be lifted") return end if votelimittime > 1 and pseudoleveltime > votelimittime*TICRATE and (p ~= server or not IsPlayerAdmin(p)) then CONS_Printf(p,"You took to long to vote, now you must play this race or spectate, current vote max time limit is "+timeleft(votelimittime*TICRATE)) return end if LTB_vote.isvoting then CONS_Printf(p,"theres already an ongoing voting, vote or wait!") return end if LTB_vote.cooldown > 0 and (p ~= server or not IsPlayerAdmin(p)) then CONS_Printf(p,"last map vote was too recent, for "+timeleft(LTB_vote.cooldown)) return end if not {...} or #{...} == 0 then CONS_Printf(p,"type a map name! can have spaces and cas specify act number, -f or -force to force a invalid map or -e or -encore for encore") return end //if p == server or IsPlayerAdmin(p) then CONS_Printf(p,"youre the owner/admin, use the map command instead") return end --check for specific player spamming votes if #LTB_vote.oldvotes > 0 and (p ~= server or (not IsPlayerAdmin(p) and p ~= server )) then local youcnt,votespacing = 0,0 --I SWEAR IT WASNT INTENTIONAL for _2, i in ipairs(LTB_vote.oldvotes) do if i[3] == p.LTB_vote.id then youcnt = $ + 1 continue end votespacing = $ + 1 end if youcnt > 2 and youcnt > (votespacing or 3) / 2 then CONS_Printf(p,"stop spamming votes!!!!, cooldown of "+timeleft(voterspamtime*TICRATE)+" you also cannot vote now, BEHAVE") CONS_Printf(server,"MAPVOTE > "..p.name.." was caught spamming") p.LTB_vote.spamcooldown = voterspamtime * TICRATE for _2, i in ipairs(LTB_vote.oldvotes) do --clearing your history, thank me later... if i[3] == p.LTB_vote.id then table.remove(LTB_vote.oldvotes,_2) end end return end end local _, test, cnt, map map = '' cnt = 1 //your vote already accounted for _,i in ipairs({...}) do //if i and type(i) == "string" then if i == "-f" or i == "-force" then LTB_vote.force = ' -f ' continue end if i == "-e" or i == "-encore" then LTB_vote.encore = ' -e ' continue end if _ > 1 and string.len(map) > 0 then map = $ +' ' end map = $ + i //end end if map and (map == "random" or map == "r" or map == "randommap" or map == "0" or map == "-1") then local randommap = P_RandomRange(1,#mapheaderinfo - 1) while not ((mapheaderinfo[randommap].typeoflevel & 0x0001) //TOL_RACE or (mapheaderinfo[randommap].typeoflevel & 0x0002)) //TOL_BATTLE do randommap = P_RandomRange(1,#mapheaderinfo - 1) end map = G_BuildMapTitle(randommap) end _,test = G_FindMap(map) if not test then CONS_Printf(p,"cant find a map with that name - "..map) return end --check for map spamming if #LTB_vote.oldvotes > 0 and (p ~= server or (not IsPlayerAdmin(p) and p ~= server )) then local mapcnt,votespacing = 0,0 for _2, i in ipairs(LTB_vote.oldvotes) do if i[1] == _2 then mapcnt = $ + 1 continue end votespacing = $ + 1 end if mapcnt > 2 and mapcnt > (votespacing or 3) / 2 then print("map spamming detected, map is "..test.." , whole server will be in a voting cooldown for "+timeleft(mapspamtime*TICRATE).." BEHAVE") CONS_Printf(server,"MAPVOTE > "..test.." was being spammed, server got punishment for that, who called last vote was "..p.name) LTB_vote.cooldown = mapspamtime * TICRATE LTB_vote.oldvotes = {} return end end LTB_vote.isvoting = true LTB_vote.caller = p LTB_vote.map = test LTB_vote.time = votetime*TICRATE// 15*TICRATE LTB_vote.votes = 1 LTB_vote.cooldown = 0 LTB_vote.voters = {p} LTB_vote.passed = 0 LTB_vote.failed = 0 table.insert(LTB_vote.oldvotes,{_,p,p.LTB_vote.id,test}) local ptotal = 0 for p2 in players.iterate do if p2 and not p2.bot and not p2.spectator and p.LTB_vote.spamcooldown <= 0 and not p.LTB_vote.dedi then ptotal = $ + 1 end if not p2 or p2 == p or p2.bot == true or p2.spectator or p.LTB_vote.dedi or p.LTB_vote.spamcooldown > 0 then continue end cnt = $ + 1 end if cnt > 2 then cnt = min(max(2,($/2))+1,ptotal - (1+(ptotal/5))) end //lone players can vote how much they desire :) if cnt == 1 then LTB_vote.votes = 1 LTB_vote.cooldown = 0 LTB_vote.passed = 2 --isnta warp, have fun table.remove(LTB_vote.oldvotes) --youre forfeith t obe free, little one :) else print(p.name.." is caling a vote!") local amntvotes = 0 if #LTB_vote.oldvotes > 0 then for _2, i in ipairs(LTB_vote.oldvotes) do if i[3] == p.LTB_vote.id then amntvotes = $ + 1 end end end CONS_Printf(server,"MAPVOTE > "..p.name.."started a vote for "..test.." they voted "..amntvotes.." during this session") end LTB_vote.topass = cnt end) local function pvotetic() for p in players.iterate do if not p then continue end if not (p.LTB_vote and p.LTB_vote.init) then initpvote(p) end p.LTB_vote.spamcooldown = max($ -1,0) p.LTB_vote.zb = (p.cmd.buttons & 1<<7) if p.LTB_vote.zb then if not p.LTB_vote.wannavote then p.LTB_vote.wannavote = true p.LTB_vote.forcerelease = true end if p.LTB_vote.forcerelease == false and p.LTB_vote.wannavote and LTB_vote.passed <= 0 and LTB_vote.failed <= 0 then //voting... p.LTB_vote.myvote = min($ + 1,TICRATE*2 +1) end else if p.LTB_vote.wannavote then p.LTB_vote.forcerelease = false end //force to release button to vote if p.LTB_vote.myvote < TICRATE then p.LTB_vote.myvote = 0 end //cancel voting if p.LTB_vote.myvote >= TICRATE then p.LTB_vote.myvote = TICRATE + 1 end //cancel the voting cancel (?) end //vote caller dont have to vote also it shows automatically also cant cancel if p == LTB_vote.caller or p.spectator then p.LTB_vote.myvote = TICRATE + 1 p.LTB_vote.wannavote = true end --players on spam cooldown lose voring rights, i love democracy if p.LTB_vote.spamcooldown > 0 then p.LTB_vote.myvote = 0 p.LTB_vote.wannavote = false end //check if a the player already voted if p.LTB_vote.myvote == TICRATE then local canvote = true for i = 1, #LTB_vote.voters do if p == LTB_vote.voters[i] then canvote = false break end end //you can and voted successfuly if canvote then LTB_vote.votes = $ + 1 table.insert(LTB_vote.voters,p) p.LTB_vote.forcerelease = true p.LTB_vote.myvote = TICRATE + 1 S_StartSound(nil, sfx_gshad) //omg congrats on voting end end //cancel your vote //the caller CANNOT cancel their votes, of course if p.LTB_vote.myvote == TICRATE*2 then local canunvote, is = false //look for yourself on the voters table to know if you can cancel for i = 1, #LTB_vote.voters do is = i if p == LTB_vote.voters[i] then canunvote = true break end end //you voted and can unvote if canunvote then LTB_vote.votes = $ - 1 table.remove(LTB_vote.voters,is) p.LTB_vote.forcerelease = true S_StartSound(nil, sfx_buzz4) //omg congrats on UNvoting p.LTB_vote.myvote = 0 end end if LTB_vote.passed < TICRATE / 3 and LTB_vote.cooldown > 0 then p.LTB_vote.wannavote = false end if LTB_vote.failed < TICRATE / 3 and LTB_vote.cooldown > 0 then p.LTB_vote.wannavote = false end end end local votehooks = { "ThinkFrame", "VoteThinker", "IntermissionThinker"} for i = 1, #votehooks do addHook(votehooks[i],do if i == 1 then pseudoleveltime = $ + 1 end if i == 2 and pseudoleveltime == 4 then --is on voting screen table.remove(LTB_vote.oldvotes) end if LTB_vote.cooldown then LTB_vote.cooldown = max(0,$-1) end if pseudoleveltime == 4 then --initialize players for p in players.iterate do initpvote(p) end end if LTB_vote.isvoting then pvotetic() if LTB_vote.time == votetime*TICRATE then S_StartSound(nil, sfx_cdfm67) //hii new votation started end LTB_vote.time = max($ - 1, 0) if pseudoleveltime % 64 == 0 and LTB_vote.passed <= 0 and LTB_vote.failed <= 0 then S_StartSound(nil, sfx_s3kd2s) //dont forget the votation, its hereeeee end //BAIL BAIL if not LTB_vote.caller or not (LTB_vote.caller and LTB_vote.caller.valid) then LTB_vote.failed = 2//3*TICRATE LTB_vote.passed = 0 LTB_vote.cooldown = voteerrtime*TICRATE//4*TICRATE S_StartSound(nil, sfx_adderr) //vote failed :((((((((( S_StartSound(nil, sfx_adderr) //FAILED LOUDLY //print("vote error :/") CONS_Printf(server,"MAPVOTE > ".." there was a avoidable voting error, player somehow vanished?") end end if LTB_vote.passed then LTB_vote.passed = max($ -1 ,0) end if LTB_vote.failed then LTB_vote.failed = max($ -1 ,0) end if LTB_vote.isvoting and LTB_vote.votes >= LTB_vote.topass and LTB_vote.time > 0 and LTB_vote.passed <= 0 then LTB_vote.passed = 4*TICRATE S_StartSound(nil, sfx_kc48) //vote passed hooray end if LTB_vote.passed == 1 then local gametype,tabtypes = 0, {0x0001,0x0002,0x0004,0x0008,0x0010} for i = 1, #tabtypes do if mapheaderinfo[G_FindMap(LTB_vote.map)].typeoflevel & tabtypes[i] then gametype = i - 1 break end end if netgame and (gametype == 2 or gametype == 4) then gametype = 0 LTB_vote.force = ' -f ' end //sealed star and tutorial - go to race if netgame and gametype == 3 then gametype = 1 LTB_vote.force = ' -f ' end //versus "boss" - go to battle LTB_vote.cooldown = votegoodtime*TICRATE//30*TICRATE if LTB_vote.topass == 1 then LTB_vote.cooldown = 0 end local arg = 'map '+LTB_vote.map+LTB_vote.force+LTB_vote.encore+' -g '+gametype resetvars() COM_BufInsertText(server, arg) end //vote failed if LTB_vote.isvoting and LTB_vote.time <= 0 and LTB_vote.passed <= 0 and LTB_vote.votes < LTB_vote.topass and LTB_vote.failed <= 0 then LTB_vote.failed = 4*TICRATE LTB_vote.cooldown = votebadtime *TICRATE//15*TICRATE S_StartSound(nil, sfx_adderr) //vote failed :((((((((( end if LTB_vote.failed == 1 then resetvars() end end) end local function votehud(v,p) if not p or not v or not LTB_vote.isvoting then return end local ZB,sha = (p.cmd.buttons & 1<<7) sha = v.stringWidth("a", V_SNAPTOTOP|V_SNAPTORIGHT) if p.LTB_vote.zb then vtbtn[3] = vtbtn[2] else vtbtn[3] = vtbtn[1] end if p.LTB_vote.wannavote then //may player names be longer than map name, use the longest local biggerfont = LTB_vote.map //if LTB_vote.caller.name:len() > //LTB_vote.map:len() then biggerfont = LTB_vote.caller.name end slide2 = ease.outsine(FRACUNIT / (TICRATE /4),$,(fontspacing(v,biggerfont)+(fontspacing(v,"a")))*FRACUNIT) else vtbtn[3] = vtbtn[max(1,(pseudoleveltime/(TICRATE/4)) % 3)] //z button blinking slide2 = ease.outsine(FRACUNIT / (TICRATE /4),$,FRACUNIT) end //drawing zaza v.drawScaled(((x-26) - FixedInt(slide2))*FRACUNIT,(y)*FRACUNIT,FRACUNIT,v.cachePatch("TLSBE0"),flags) v.drawScaled(((x-16) - FixedInt(slide2))*FRACUNIT,(y+12)*FRACUNIT,FRACUNIT,v.cachePatch(vtbtn[3]),flags) v.drawString(x - FixedInt(slide2), y,LTB_vote.map,flags) v.drawFill(x - FixedInt(slide2), y+sha+1 ,FixedInt(slide2)+18, 10, 29) v.drawFill((x-4) - (((FixedInt(slide2)/5))*((min(TICRATE,p.LTB_vote.myvote) or 1 )/ (TICRATE / 5))), y+sha+1 ,FixedInt(slide2)+18, 10, 6) if p.LTB_vote.myvote > TICRATE + 1 then //cancel your vote v.drawFill((x-4) - (((FixedInt(slide2)/5))*(((p.LTB_vote.myvote /2) or 1 )/ (TICRATE / 5))), y+sha +1,FixedInt(slide2)+18, 10, 34) end //green confirmation for succesful voting if LTB_vote.passed > 0 then if pseudoleveltime % 2 == 0 then v.drawFill((x-4) - (((FixedInt(slide2)/5))*(((p.LTB_vote.myvote % TICRATE) or 1 )/ (TICRATE / 5))), y+sha+1 ,FixedInt(slide2)+18, 10, 6) else v.drawFill((x-4) - (((FixedInt(slide2)/5))*(((p.LTB_vote.myvote % TICRATE) or 1 )/ (TICRATE / 5))), y+sha+1 ,FixedInt(slide2)+18, 10, 97) v.drawFill(x - FixedInt(slide2), y+sha+1 ,FixedInt(slide2)+18, 10, 97) end end if LTB_vote.failed > 0 then if pseudoleveltime % 2 == 0 then v.drawFill((x-4) - (((FixedInt(slide2)/5))*((min(TICRATE,p.LTB_vote.myvote) or 1 )/ (TICRATE / 5))), y+sha+1 ,FixedInt(slide2)+18, 10, 6) else v.drawFill((x-4) - (((FixedInt(slide2)/5))*((min(TICRATE,p.LTB_vote.myvote) or 1 )/ (TICRATE / 5))), y+sha +1,FixedInt(slide2)+18, 10, 35) v.drawFill(x - FixedInt(slide2), y+sha +1,FixedInt(slide2)+18, 10, 35) end end v.drawString(x - FixedInt(slide2) + (fontspacing(v,LTB_vote.map)/2) - 1 , y+sha+2,LTB_vote.votes.."/"..LTB_vote.topass,flags) //voters icons local yadd = 0 for i = 1, #LTB_vote.voters do if not (v and LTB_vote.voters[i] and LTB_vote.voters[i].valid) then continue end yadd = 12*(i/7) local shit = v.getSprite2Patch(LTB_vote.voters[i].skin, "XTRA",false, C, 0)// v.getSpritePatch("STIN", 1,1) local xs = x - FixedInt(slide2) v.drawScaled((xs+(((shit.width/2)+1)*((i-1)%7)))*FRACUNIT, (y+sha*2 +4+ yadd)*FRACUNIT, FRACUNIT, shit, flags, v.getColormap(LTB_vote.voters[i].skin,LTB_vote.voters[i].skincolor or 0)) end end addHook("MapChange",do pseudoleveltime = 0 end) hud.add(votehud)