• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Talkaction - vote

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,855
Solutions
18
Reaction score
671
Hello.
Anyone can make for me simple talkaction:

/vote Question

Broadcast:
Question? !vote yes/no

after that if you write !vote yes the count of yes is going +1 after vote no the count of no goes +1

Each player can give 1 voice for yes or no

And finally after 5 minutes display:
Broadcast:
VOting is now over.
X players voted yes and Y players voted no.
 
LUA:
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
 
Back
Top