TalkAction [8.0]Poll system(Forgotten Server & Evolutions)

Delirium

OTLand veteran
Staff member
Global Moderator
Joined
May 28, 2007
Messages
3,335
Best answers
1
Reaction score
196
Location
Athens, Greece
Welcome.This is a talk action.With this script if you are a gamemaster or higher you can make your own polls on the server you play.

Let's start

First add this to data/talkactions/lib/talkactions.lua


Code:
function exhaust(cid, storevalue, exhausttime)
-- Exhaustion function by Alreth, v1.1 2006-06-24 01:31
-- Returns 1 if not exhausted and 0 if exhausted
    
    newExhaust = os.time()
    oldExhaust = getPlayerStorageValue(cid, storevalue)
    if (oldExhaust == nil or oldExhaust < 0) then
        oldExhaust = 0
    end
    if (exhausttime == nil or exhausttime < 0) then
        exhausttime = 1
    end
    diffTime = os.difftime(newExhaust, oldExhaust)
    if (diffTime >= exhausttime or diffTime < 0) then
        setPlayerStorageValue(cid, storevalue, newExhaust) 
        return 1
    else
        return 0
    end
end
This will make the exhaustion in the script works perfectly

For evolutions:

save this as poll.lua in data/talkactions/scripts

Code:
local ActiveValue = 666
local YesValue = 1000
local NoValue =  2000
local ExhaustTime = 6000000 --- Time (in minutes) that the player will have to wait 'till he can vote again Default = 10min
local AutoEnd = true ---Use Auto End (set true or false)
local ToEnd = 1000*60*10 -- Time to auto-end poll (in miliseconds) Default = 10min
local WriteBook = false --- Write a book with the results (true or false)

function onSay(cid, words, param)
	if words == '!makepoll' then	
		if getPlayerAccess(cid) >= 3 then
			if getGlobalStorageValue(ActiveValue) ~= 1 then
				if param ~= nil then
					doPlayerSay(cid,'Poll: '..param..'',9)
					setGlobalStorageValue(YesValue,0)
					setGlobalStorageValue(NoValue,0)
					setGlobalStorageValue(ActiveValue,1)
					if AutoEnd == true then
						addEvent(EndPoll,ToEnd,cid)
					end
				end
			else
				doPlayerSendTextMessage(cid,22,'A poll is already running.')
			end
		else
			doPlayerSendCancel(cid,'Only Gamemasters can make a poll')
		end
	elseif words == '!vote' and getGlobalStorageValue(ActiveValue) == 1 and exhaust(cid,500,ExhaustTime) == 1 then
		if param == 'yes' then
			setGlobalStorageValue(YesValue,getGlobalStorageValue(YesValue)+1)
			doPlayerSendTextMessage(cid,22,'Thanks for your vote.')
		elseif param == 'no' then
			setGlobalStorageValue(NoValue,getGlobalStorageValue(NoValue)+1)
			doPlayerSendTextMessage(cid,22,'Thanks for your vote.')
		else
			doPlayerSendTextMessage(cid,22,'Use only !vote "yes or !vote "no.')
		end			
	elseif words == '!endpoll' then
		if getPlayerAccess(cid) >= 3 then 
			if getGlobalStorageValue(ActiveValue) == 1 then
				setGlobalStorageValue(ActiveValue,2)
				doSetItemText(doPlayerAddItem(cid,1984,1),'The results are: Yes: '..getGlobalStorageValue(YesValue)..', No: '..getGlobalStorageValue(NoValue)..'')
				doPlayerSay(cid,'The poll has ended, thanks for your votes.',9)
			else
				doPlayerSendCancel(cid,'There is no poll running.')
			end
		else
			doPlayerSendCancel(cid,'Only Gamemasters can end polls')
		end
	end
end

function EndPoll(cid)
if getGlobalStorageValue(ActiveValue) == 1 then
setGlobalStorageValue(ActiveValue,2)
doPlayerSay(cid,'The poll has ended, thanks for your votes.',9)
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)..'')
else
print('No polls running')
end
end
For The Forgotten Server:
Code:
-- Created by Nikolas1994<>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 = 6000000 -- 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
And then

in talkactions.xml add the following code


Code:
<talkaction words="!makepoll" script="poll.lua" />
<talkaction words="!vote" script="poll.lua" />
<talkaction words="!endpoll" script="poll.lua" />

Credits:
Evolutions script: Nikolas1994
Forgotten Server Script: Nikolas1994,Talaturen
Comments please :D
 
Last edited by a moderator:

Master-m

Need help? Just ask!
Joined
May 28, 2007
Messages
4,339
Best answers
0
Reaction score
15
Location
The Netherlands
RE: [7.92] Release<>Poll system with talk actions.

Nice for other server then The Forgotten Server because TFS has it already hardcoded:p btw I found a typo : This will make the exhaustion in the script works prfectly
 

gooden

New Member
Joined
May 28, 2007
Messages
29
Best answers
0
Reaction score
0
RE: [7.92] Release<>Poll system with talk actions.

Great job ;)
 
OP
Delirium

Delirium

OTLand veteran
Staff member
Global Moderator
Joined
May 28, 2007
Messages
3,335
Best answers
1
Reaction score
196
Location
Athens, Greece
RE: [7.92] Release<>Poll system with talk actions.

Thanks for this master-m and thanks gooden too
 

Henkieman

New Member
Joined
May 28, 2007
Messages
36
Best answers
0
Reaction score
0
RE: [Talkaction][7.92]Poll system

Very ty ill used it
 

Lithium

Ex-TFS Developer
Joined
Jun 2, 2007
Messages
334
Best answers
0
Reaction score
0
RE: [Talkaction][7.92]Poll system

nice job man works fine
 

TheMask

World of Comodato Owner
Joined
May 28, 2007
Messages
80
Best answers
0
Reaction score
0
Location
Brasil
RE: [Talkaction][7.92]Poll system

@NIK...

Nice exausted XDBut is possible fix it to only give exausted if player type the correct command?

EX: Give exausted only if the player type !vote "yes or !vote "no , cause if you type !vote "wrong or only !vote you will get the exasuted without voted :( and you cant will vote again :(

Try fix it plz
 

Kiwi Dan

Kiwi Server 3.0
Joined
Jun 5, 2007
Messages
618
Best answers
0
Reaction score
9
Location
New Zealand
RE: [Talkaction][7.92]Poll system

Awesome, I will use this latter on.

~Kiwi Dan~
 

n3oth3on3

~ Ashandra War ~
Joined
Jul 1, 2007
Messages
52
Best answers
0
Reaction score
0
Location
Germany
RE: [Talkaction][7.92]Poll system

woohoo thanks i will make it in my server~
 

Cronos

New Member
Joined
Jul 2, 2007
Messages
51
Best answers
0
Reaction score
0
RE: [Talkaction][7.92]Poll system

System is working good
 

mamon_2

Banned User
Joined
Jul 2, 2007
Messages
424
Best answers
0
Reaction score
0
RE: [Talkaction][7.92]Poll system

<talkaction words="!makepoll" script="poll.lua" />
<talkaction words="!vote" script="poll.lua" />
<talkaction words="!endpoll" script="poll.lua" />

It would be like?:
!makepoll Do you want to eat a cookie?
!vote yes or !vote no?
:S:S
 
OP
Delirium

Delirium

OTLand veteran
Staff member
Global Moderator
Joined
May 28, 2007
Messages
3,335
Best answers
1
Reaction score
196
Location
Athens, Greece
RE: [Talkaction][7.92]Poll system

mamon_2 said:
<talkaction words="!makepoll" script="poll.lua" />
<talkaction words="!vote" script="poll.lua" />
<talkaction words="!endpoll" script="poll.lua" />

It would be like?:
!makepoll Do you want to eat a cookie?
!vote yes or !vote no?
:S:S
!makepoll "Do you want to eat a cookie
!vote "Yes
!vote "No
 

gerberos

New Member
Joined
Jul 6, 2007
Messages
62
Best answers
0
Reaction score
0
RE: [Talkaction][7.92]Poll system

nice but i not rly understand codes =(
 

JayBeee

Retired Global Mod
Joined
Jun 2, 2007
Messages
5,225
Best answers
0
Reaction score
13
Location
Sweden
RE: [Talkaction][7.92]Poll system

It works for 8.0 too :) Good work!
 

Barbyn

Founder of Granaria 09/10
Joined
Jun 13, 2007
Messages
167
Best answers
0
Reaction score
1
RE: [Talkaction][7.92]Poll system

nice one :d
 

Jgarder

Tprogramming Ex-Adm|n
Joined
Jun 7, 2007
Messages
353
Best answers
0
Reaction score
1
Location
Michigan
RE: [Talkaction][7.92]Poll system

This isnt perfectly useful, :/ i have a website with it built in.. but if u could make a website.. that saved results.. nd displayed past polls and such (much like Rl tibias)
 

Sazzoo

New Member
Joined
Jul 12, 2007
Messages
50
Best answers
0
Reaction score
1
Location
Sweden
RE: [Talkaction][7.92]Poll system

Great job man! Keep it up! :p <short>
 

dwaaaaark

New Member
Joined
Jul 10, 2007
Messages
34
Best answers
0
Reaction score
0
RE: [Talkaction][7.92]Poll system

Nice, simple to vote in game.

Will it work for 8.0 as well?
 
OP
Delirium

Delirium

OTLand veteran
Staff member
Global Moderator
Joined
May 28, 2007
Messages
3,335
Best answers
1
Reaction score
196
Location
Athens, Greece
RE: [Talkaction][7.92]Poll system

Yes it would work probaply.
 
Top