local votes = { yes = 19000, no = 19001 }
local hasVoted = 19002
local function msgContains(msg, lookfor)
for word in msg:gmatch('%a+') do
if word == lookfor then
return true
end
end
return false
end
function onSay(player, words, param)
if player:getStorageValue(hasVoted) < 0 then
if msgContains(param, 'yes') then
Game.setStorageValue(votes['yes'], Game.getStorageValue(votes['yes']) + 1)
player:setStorageValue(hasVoted, 1)
elseif msgContains(param, 'no') then
Game.setStorageValue(votes['no'], Game.getStorageValue(votes['no']) + 1)
player:setStorageValue(hasVoted, 1)
else
player:sendTextMessage(MESSAGE_STATUS_WARNING, 'That isn\'t a valid voting option.')
end
else
player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Sorry, you are only allowed to vote once.')
end
end