function vote_clean()
setGlobalStorageValue(9955, 0)
setGlobalStorageValue(2222, 0)
setGlobalStorageValue(2223, 0)
return true
end
function vote_end()
doBroadcastMessage("Votes on YES - ("..getGlobalStorageValue(2222).."), votes on NO - ("..getGlobalStorageValue(2223)..").")
addEvent(vote_clean, 2000)
return true
end
function onSay(cid, words, param)
local vote_end_time = 60
if getGlobalStorageValue(9955) ~= 1 then
if words == '/vote' then
addEvent(vote_end, vote_end_time * 1000)
doBroadcastMessage("The question is: "..param..". To vote for YES please use the command \'!yes\', else use the command \'!no\'.")
setGlobalStorageValue(9955, 1)
end
end
if getGlobalStorageValue(9955) == 1 then
if words == '!yes' and getPlayerStorageValue(cid,7236) <= os.time() then
setGlobalStorageValue(2222, getGlobalStorageValue(2222) + 1)
doPlayerSendTextMessage(cid, 19, 'You gave vote in this poll, your voice is YES.')
setPlayerStorageValue(cid,7236, os.time()+(vote_end_time))
elseif words == '!no' and getPlayerStorageValue(cid,7236) <= os.time() then
setGlobalStorageValue(2223, getGlobalStorageValue(2223) + 1)
doPlayerSendTextMessage(cid, 19, 'You gave vote in this poll, your voice is NO.')
setPlayerStorageValue(cid,7236, os.time()+(vote_end_time))
elseif getPlayerStorageValue(cid,7236) >= os.time() then
doPlayerSendTextMessage(cid, 19, "You have already voted in this poll!")
end
else
doPlayerSendTextMessage(cid, 19, "The vote hasn't been started.")
end
return true
end