Jump to content

VoteRedo Help #2


justn

Recommended Posts

Hey guys, So I made a voteredo script, and there's 1 small thing I need help with, so, when there's 3 player in a server. and 1 player does vr.. it says "[VR] playerName has voted for redo [1/1.5]" but If there's 3 player in server.. i want it to say "[VR] playerName has voted for redo [1/2]"

Examples

-- If 5 players in server it should say "[VR] playerName has voted for redo [1/4]" and not [1/2.5]

-- If 7 players in server it should say "[VR] playerName has voted for redo [1/6]" and not [1/3.5]

Anyways, you know what I mean, hope someone can help :P thanks

Code:

-addCommandHandler( "vr", function( player ) 
local alivePlayers = getAlivePlayers() 
if #alivePlayers ~= 0 then 
    if ( isMapRestarted == false ) then 
        if playerVotes[player] then return outputChatBox(serverColor.."[VR]: #ffffffYou have already voted", player, 255, 0, 0, true) end 
            playerVotes[player] = true 
            nbVotes = nbVotes + 1 
            local playerCount = getPlayerCount() 
            if nbVotes-1 < (playerCount/2) then 
                if (playerCount == 1) or (playerCount == 2) then 
                     
                outputChatBox("", root, 255, 0, 0, true) 
                outputChatBox(serverColor.."[VR]: "..getPlayerName(player).."#ffffff has voted for redo! ["..serverColor..nbVotes.."/1#FFFFFF]", root, 255, 0, 0, true) 
             
                outputChatBox("", root, 255, 0, 0, true) 
                outputChatBox(serverColor.."[VR]: #ffffffThis map will be restarted by vote!", root, 255, 0, 0, true) 
                         
                addEventHandler("onMapStarting",root,onFirstMapStarting) 
         
                if not onPlayerPickUpRacePickupHandler then 
                    onPlayerPickUpRacePickupHandler = addEventHandler("onPlayerPickUpRacePickup",root,onPlayerHitHunter) -- if the addEventHandler was successfully executed, it will return true else false. In the variable onPlayerPickUpRacePickupHandler. 
                end 
         
                if not onPlayerWastedHandler then 
                    onPlayerWastedHandler = addEventHandler("onPlayerWasted",root,onPlayerWasted) -- if the addEventHandler was successfully executed, it will return true else false. In the variable onPlayerWastedHandler. 
                end 
         
                if isTimer(resetVotesTimer) then -- anti flow 
                    killTimer(resetVotesTimer) 
                end 
                return end 
                    outputChatBox("", root, 255, 0, 0, true) 
                    outputChatBox(serverColor.."[VR]: "..getPlayerName(player).."#ffffff has voted for redo! ["..serverColor..nbVotes.."/"..(getPlayerCount()/2).."#FFFFFF]", root, 255, 0, 0, true) 
            end 
            if nbVotes >= ((playerCount)/2) then 
  
                outputChatBox("", root, 255, 0, 0, true) 
                outputChatBox(serverColor.."[VR]: #ffffffThis map will be restarted by vote!", root, 255, 0, 0, true) 
                addEventHandler("onMapStarting",root,onFirstMapStarting) 
         
                if not onPlayerPickUpRacePickupHandler then 
                    onPlayerPickUpRacePickupHandler = addEventHandler("onPlayerPickUpRacePickup",root,onPlayerHitHunter) -- if the addEventHandler was successfully executed, it will return true else false. In the variable onPlayerPickUpRacePickupHandler. 
                end 
         
                if not onPlayerWastedHandler then 
                    onPlayerWastedHandler = addEventHandler("onPlayerWasted",root,onPlayerWasted) -- if the addEventHandler was successfully executed, it will return true else false. In the variable onPlayerWastedHandler. 
                end 
         
                if isTimer(resetVotesTimer) then -- anti flow 
                    killTimer(resetVotesTimer) 
                end 
         
                resetVotesTimer = setTimer(resetVotes, 150*1000, 1) -- I put this function a both, because then you don't have to create a function over and over. 
         
                else 
                     
                    --outputChatBox("", root, 255, 0, 0, true) 
                    --outputChatBox("#ffb717[REDO]: "..getPlayerName(player).." #ffffffvoted for redo! [#FFB818"..nbVotes.."/"..(getPlayerCount()/2).."#FFFFFF]", root, 255, 0, 0, true) 
                end 
                else  
            outputChatBox(serverColor.."[VR]: #ffffffMap is already restarted !", player, 255, 0, 0, true)  
            end 
          else 
            outputChatBox(serverColor.."[VR]: #ffffffMap is already finished", player, 255, 0, 0, true)  
        end 
 end) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...