Update to polls hope no desync

This commit is contained in:
Cooldude2606
2018-10-26 21:09:48 +01:00
parent fb36fb03f7
commit ec9a8db362

View File

@@ -26,7 +26,18 @@ local global = global{
}
-- Function Define
local function _poll_end(self)
local function _poll_data(question,answers)
local poll = {
uuid=Server.uuid(),
question=question,
answers=answers or {'None'},
votes={},
voted={}
}
Server.new_thread{
data={poll_uuid=poll.uuid},
timeout=poll_time_out*60
}:on_event('timeout',function(self)
local uuid = tostring(self.data.poll_uuid)
local poll = global.active[uuid]
if not poll then return end
@@ -46,21 +57,7 @@ local function _poll_end(self)
game.print({'ExpGamingPlayer-polls.end',poll.question},defines.textcolor.info)
game.print({'ExpGamingPlayer-polls.winner',highest[1]},defines.textcolor.info)
verbose('Ended Poll: '..poll.question..' ('..uuid..') Highest: '..highest[1])
end
local function _poll_data(question,answers)
local poll = {
uuid=Server.uuid(),
question=question,
answers=answers or {'None'},
votes={},
voted={}
}
Server.new_thread{
data={poll_uuid=poll.uuid},
timeout=poll_time_out*60
}:on_event('timeout',_poll_end):open()
-- This time out is known to cause desyncs and so I have moved it to a hard coded function
end):open()
global.active[tostring(poll.uuid)]=poll
verbose('Created Poll: '..question..' ('..poll.uuid..')')
return poll.uuid