hutin123 Posted August 24, 2017 Share Posted August 24, 2017 Can someone help me with this script, please. It has a problem that when one of the clients start command 'vr', the map is just restarted in stead of checking all the clients if they have voted or not. I don't own this script, btw Many thanks. local color = "#FFFFFF" VoteRedo = true playersVoted = 0 mapRestarted = true addCommandHandler("turnVR", function( player, cmd) if isPlayerInACLGroup(player, g_GameOptions.admingroup) then if VoteRedo then VoteRedo = false outputChatBox("[SERVER] "..color.."Command [/vr] Vote Redo #FF4040DISABLED "..color.."by #ffffff"..getPlayerNametagText(player), root, 255, 99, 99, true) else VoteRedo = true outputChatBox("[SERVER] "..color.."Command [/vr] Vote Redo #adff2fENABLED "..color.."by #ffffff"..getPlayerNametagText(player), root, 255, 99, 99, true) end end end ) addEventHandler ( "onPlayerJoin",root, function () setElementData( source, "hasVoted", "nope" ) end ) function PlayerVoted(thePlayer) if VoteRedo then if not stateAllowsRandomMapVote() or g_CurrentRaceMode:getTimeRemaining() < 1000 then outputChatBox("[SERVER] "..color.."Command only enabled with game in process.", thePlayer, 255, 99, 99, true) return end if mapRestarted then if redo then outputChatBox("[SERVER] "..color.."The map now automatically restart.", thePlayer, 255, 99, 99, true) return end if (getElementData( thePlayer, "hasVoted" ) == "nope") then setElementData( thePlayer, "hasVoted", "voted" ) playersVoted = playersVoted + 1 outputChatBox("[SERVER] #ffffff("..playersVoted.."/".. math.floor(getPlayerCount() /2 + 0.5) ..")"..color.." The player #ffffff"..getPlayerNametagText(thePlayer).." "..color.."voted to restart this map.", root, 255, 99, 99, true) if playersVoted >= math.floor(getPlayerCount() /2 + 0.5) then redo = true outputChatBox ("[SERVER] "..color.."Voting finished, the map will be restarted.", root, 255, 99, 99, true) triggerClientEvent("onSetNextMapRedo",root,redo) triggerEvent("redoByRace",root,redo) end else outputChatBox("[SERVER] "..color.."You have already voted.", thePlayer, 255, 99, 99, true) end else outputChatBox("[SERVER] "..color.."Sorry, This map has been restarted.", thePlayer, 255, 99, 99, true) end else outputChatBox("[SERVER] "..color.."Sorry, Vote Redo is DISABLED", thePlayer, 255, 99, 99, true) end end addCommandHandler ( "vr", PlayerVoted ) Link to comment
hutin123 Posted August 31, 2017 Author Share Posted August 31, 2017 oh, problem solved! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now