WiLDTuRTLE
Member
- Joined
- Feb 26, 2011
- Messages
- 478
- Reaction score
- 5
Ok, i need help to make no mistakes, how many talkactions.xml do i have to add? for players? huh!
Welp!
It might be OLD, let me know if it doesnt work on 9.60~ tfs 3.6
EDIT
Welp!
Code:
-- Optimized by Talaturen
-- Visit http://otland.net
-- 22:25 CET >> 2007-08-07
local activeValue = 666 -- Storage value of active poll
local yesValue = 1000 -- Storage value of yes votes
local noValue = 2000 -- Storage value of no votes
local exhaustTime = 600 -- Time in minutes that the player will have to wait before gaining ability to vote again (Default: 10 minutes)
local autoEnd = TRUE -- Auto ending poll (TRUE or FALSE)
local toEnd = 1000 * 60 * 10 -- Time until poll will auto end in miliseconds (Default: 10 minutes)
local writeBook = FALSE -- Write a book with the results (TRUE or FALSE)
function onSay(cid, words, param)
if words == "!makepoll" then
if getPlayerGroupId(cid) > 3 then
if getGlobalStorageValue(activeValue) ~= TRUE then
if param ~= "" then
broadcastMessage("Poll: " .. param)
setGlobalStorageValue(yesValue, 0)
setGlobalStorageValue(noValue, 0)
setGlobalStorageValue(activeValue, 1)
if autoEnd == TRUE then
addEvent(endPoll, toEnd, cid)
end
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "There is already a poll running.")
end
else
doPlayerSendCancel(cid, "Only gamemasters may create a poll.")
end
elseif getGlobalStorageValue(activeValue) == TRUE then
if words == "!vote" then
if exhaust(cid, 500, exhaustTime) == TRUE then
if param == "yes" then
setGlobalStorageValue(yesValue, getGlobalStorageValue(yesValue) + 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Thanks for your vote.")
elseif param == "no" then
setGlobalStorageValue(noValue, getGlobalStorageValue(noValue) + 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Thanks for your vote.")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Invalid command parameter, use 'yes' or 'no'.")
end
end
elseif getPlayerGroupId(cid) > 3 then
setGlobalStorageValue(activeValue, 2)
doSetItemText(doPlayerAddItem(cid, 1984, 1), "The results are...\n\nYes: " .. getGlobalStorageValue(yesValue) .. "\nNo: " .. getGlobalStorageValue(noValue))
broadcastMessage("The poll has ended, thanks for your votes.")
else
doPlayerSendCancel(cid, "Only gamemasters may end running polls.")
end
else
doPlayerSendCancel(cid, "There is no poll running.")
end
end
function endPoll(cid)
if getGlobalStorageValue(activeValue) == TRUE then
setGlobalStorageValue(activeValue, 2)
broadcastMessage("The poll has ended, thanks for your votes.")
if writeBook == TRUE then
doSetItemText(doPlayerAddItem(cid, 1984, 1), "The results are, yes: " .. getGlobalStorageValue(yesValue) .. ", no: " .. getGlobalStorageValue(noValue))
end
print("The results are, yes: " .. getGlobalStorageValue(yesValue) .. ", no: " .. getGlobalStorageValue(noValue))
end
end
It might be OLD, let me know if it doesnt work on 9.60~ tfs 3.6
EDIT
Code:
<talkaction words="!makepoll" script="poll.lua" />
<talkaction words="!vote" script="poll.lua" />
<talkaction words="!endpoll" script="poll.lua" />
Last edited: