mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 04:51:40 +09:00
Update to polls hope no desync
This commit is contained in:
@@ -26,7 +26,18 @@ local global = global{
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- Function Define
|
-- 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 uuid = tostring(self.data.poll_uuid)
|
||||||
local poll = global.active[uuid]
|
local poll = global.active[uuid]
|
||||||
if not poll then return end
|
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.end',poll.question},defines.textcolor.info)
|
||||||
game.print({'ExpGamingPlayer-polls.winner',highest[1]},defines.textcolor.info)
|
game.print({'ExpGamingPlayer-polls.winner',highest[1]},defines.textcolor.info)
|
||||||
verbose('Ended Poll: '..poll.question..' ('..uuid..') Highest: '..highest[1])
|
verbose('Ended Poll: '..poll.question..' ('..uuid..') Highest: '..highest[1])
|
||||||
end
|
end):open()
|
||||||
|
|
||||||
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
|
|
||||||
global.active[tostring(poll.uuid)]=poll
|
global.active[tostring(poll.uuid)]=poll
|
||||||
verbose('Created Poll: '..question..' ('..poll.uuid..')')
|
verbose('Created Poll: '..question..' ('..poll.uuid..')')
|
||||||
return poll.uuid
|
return poll.uuid
|
||||||
|
|||||||
Reference in New Issue
Block a user