So somehow my voteredo doesnt work with the current gamemode i have.. Any clues? I really have no idea where to start...
--- VR ---
mapRestarted = true
cRedo = false
playersTable = {}
playersVoted = 0
vrColor = "#FF4400"
VoteRedo = true
function tableFind(tabela,value)
local ifIs = false
for i,data in pairs(tabela) do
if data == value then
ifIs = true
break
end
end
return ifIs
end
addCommandHandler("forceredo",
function(player)
local accName = getAccountName ( getPlayerAccount ( player ) )
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then
cRedo = true
outputChatBox ("[#FF4400Voteredo#FFFFFF] an Admin forced a redo. Map will be restarted", getRootElement(), 255, 255, 255, true )
end
end)
--function PlayerForceRedo(thePlayer)
-- cRedo = true
-- outputChatBox ("[sERVER] an Admin forced a redo. Map will be restarted", getRootElement(), 255, 255, 255, true )
--end
function PlayerVoted(thePlayer)
if VoteRedo then
if mapRestarted then
if playersVoted < math.floor(getPlayerCount() /2 + 0.5) then
if not tableFind(playersTable, getElementData(thePlayer,"hisNick")) then
table.insert(playersTable, getElementData(thePlayer,"hisNick"))
playersVoted = playersVoted + 1
if playersVoted >= math.floor(getPlayerCount() /2 + 0.5) then
vrColor = "#FF4400"
end
outputChatBox("[#FF4400Voteredo#FFFFFF] ' "..getPlayerNametagText(thePlayer).." #FFFFFF' has voted for redo | "..vrColor.."["..playersVoted.."/".. math.floor(getPlayerCount() /2 + 0.5) .."]", root, 255, 255,255, true)
if playersVoted >= math.floor(getPlayerCount() /2 + 0.5) then
cRedo = true
outputChatBox ("[#FF4400Voteredo#FFFFFF] This map will be restarted by #FF4400Vote", root, 255, 255, 255, true)
end
else
outputChatBox("[#FF4400Voteredo#FFFFFF] #FfffffYou already Voted for a redo !", thePlayer, 255, 255, 255, true)
end
else
outputChatBox ("[#FF4400Voteredo#FFFFFF] This map will be already restarted by #FF4400Vote", thePlayer, 255, 255, 255, true)
end
else
outputChatBox("[#FF4400Voteredo#FFFFFF] #FF0000Sorry, This map was restarted by Vote !", thePlayer, 255, 255, 255, true)
end
else
outputChatBox("[#FF4400Voteredo#FFFFFF] #FF0000Sorry, VoteRedo System disabled for 3 minutes!", thePlayer,255,255,255,true)
end
end
addCommandHandler ( "vr", PlayerVoted )
addCommandHandler ( "voteredo", PlayerVoted )
--addCommandHandler ( "forceredo", PlayerForceRedo )
------
addEvent("onRaceStateChanging",true)
addEventHandler("onRaceStateChanging",root,
function(newStateName)
if newStateName == "LoadingMap" then
table.remove(playersTable)
vrColor = "#FF4400"
playersVoted = 0
end
end)
------
addEventHandler("onPlayerJoin",root,
function()
setElementData(source,"hisNick",getPlayerName(source))
end)
----
addCommandHandler("kickall",
function(player)
local accName = getAccountName ( getPlayerAccount ( player ) )
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then
for t,p in ipairs (getElementsByType("player")) do
kickPlayer(p,getPlayerName(player)..": please all come again \"{SMILIES_PATH}/icon_biggrin.gif\" alt=\"\" title=\"Very Happy\" />")
end
end
end)
----
addCommandHandler("turnVR",
function(player)
local accName = getAccountName ( getPlayerAccount ( player ) )
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then
if VoteRedo then
VoteRedo = false
cRedo = false
outputChatBox("[#FF4400Voteredo#FFFFFF] ' "..getPlayerNametagText(player).." #FFFFFF' #FF0000has disabled VoteRedo System!",root,255,255,255,true)
else
VoteRedo = true
outputChatBox("[#FF4400Voteredo#FFFFFF] ' "..getPlayerNametagText(player).." #FFFFFF' #FF4400has enabled VoteRedo System!",root,255,255,255,true)
end
end
end)