local pvscolor = '#0099aa'
function getPlayersCount()
players = {}
for k,v in ipairs(getElementsByType('player')) do
table.insert(players,v)
end
return #players
end
addEvent('onMapStarting',true)
addEventHandler('onMapStarting',root,
function()
for k,v in ipairs(getElementsByType('player')) do
if getElementData(v,'voted') == true then
setElementData(v,'voted',false)
end
end
voteredo = {
players = math.ceil(getPlayersCount()/2),
vr = 0,
redo = false,
mapname = getMapName(exports.mapmanager:getRunningGamemodeMap()),
votedPlayers = {},
}
end
)
function annen(plr)
if voteredo then
if isRestarted() == false then
if voteredo.redo ~= true then
if not voteredo.votedPlayers[getPlayerSerial(plr)] then
if voteredo.vr+1 < voteredo.players then
voteredo.vr = voteredo.vr+1
voteredo.votedPlayers[getPlayerSerial(plr)] = true
outputChatBox(pvscolor..'[VOTEREDO] #FFFFFF('..getPlayerName(plr)..'#FFFFFF) adlı oyuncu voteredo için oy kullandı. #FFFFFF(#FF0000'..voteredo.vr..'#FFFFFF/'..voteredo.players..')',root,255,255,255,true)
else
voteredo.vr = voteredo.vr+1
voteredo.votedPlayers[getPlayerSerial(plr)] = true
voteredo.redo = true
outputChatBox(pvscolor..'[VOTEREDO] #FFFFFF('..getPlayerName(plr)..'#FFFFFF) adlı oyuncu voteredo için oy kullandı. #FFFFFF(#00FF00'..voteredo.vr..'#FFFFFF/'..voteredo.players..')',root,255,255,255,true)
end
else
outputChatBox(pvscolor..'[VOTEREDO] #FFFFFFBirden fazla oy kullanamazsın koçum',plr,255,255,255,true)
end
else
outputChatBox(pvscolor..'[VOTEREDO] #FFFFFFSeçim başarılı',plr,255,255,255,true)
end
else
outputChatBox(pvscolor..'[VOTEREDO] #FFFFFFBu harita zaten az sonra redolanacak.',plr,255,255,255,true)
end
else
outputChatBox(pvscolor..'[VOTEREDO] #FFFFFFERROR',plr,255,255,255,true)
end
end
addCommandHandler('vr',annen)
addCommandHandler('voteredo',annen)
addEvent('onRaceStateChanging',true)
addEventHandler('onRaceStateChanging',root,
function(newState)
if newState == "PostFinish" then
if voteredo then
if voteredo.redo == true then
local currentMap = exports.mapmanager:getRunningGamemodeMap()
exports.mapmanager:changeGamemodeMap (currentMap, nil, true)
lastmaprestarted = getMapName(exports.mapmanager:getRunningGamemodeMap())
outputChatBox(Clancolor..'[VOTEREDO] #FFFFFFHarita redolandı.',plr,255,255,255,true)
end
end
end
end
)
function isRestarted()
if lastmaprestarted and voteredo.mapname then
if lastmaprestarted == voteredo.mapname then
return true
else
return false
end
else
return false
end
end
function getMapName( map )
return getResourceInfo( map, "name" ) or getResourceName( map ) or "unknown"
end