God Mythera
Veteran OT User
Credit goes to: Mock
Original Post: https://otland.net/threads/advanced-poll-system-whit-logs.95258/
Just incase someone wants this for TFS 1.2!
data/talkactions/scripts/vote.lua
Original Post: https://otland.net/threads/advanced-poll-system-whit-logs.95258/
Just incase someone wants this for TFS 1.2!
<!-- Gods -->
<talkaction words="/vote" separator=" " script="vote.lua" />
<!-- player talkactions -->
<talkaction words="!yes" script="vote.lua"/>
<talkaction words="!no" script="vote.lua"/>
data/talkactions/scripts/vote.lua
Code:
function vote_clean()
setGlobalStorageValue(9955, 0)
setGlobalStorageValue(2222, 0)
setGlobalStorageValue(2223, 0)
return true
end
function vote_end()
broadcastMessage("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 * 5000)
broadcastMessage("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