POLL BOT
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

POLL BOT

Started by kash?, 28 March, 2005, 17:21:22

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kash?

Hi, can anybody plz. convert this script to LUA5.
Thanking u..

code:----------------------------------------------------------------------------------Made by nErBoS

Bot = "Vote-Bot"

vt = {}
nr = {}

votetext = "votepoll.txt" --Will be created in the script folder
oldpolls = "oldpolls.txt" --Will be created in the script folder

function Main()
frmHub:RegBot(Bot)
end

function NewUserConnected(user, data)
if (vt[user.sName] == nil) then
vt[user.sName] = 0
end
if (nr[user.sName] == nil) then
nr[user.sName] = 0
end
end

function DataArrival(user, data)

if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
   data=strsub(data,1,strlen(data)-1)
   s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if (cmd=="+votehelp") then
         local msg = ""
         if (user.iProfile == 0) then
         msg = msg.."Commands to the Vote-Poll:\r\n"
         msg = msg.."\r\n"
         msg = msg.."+createvote \tCreates a poll (nr = number to give to poll) (q = Poll question)\r\n"
         msg = msg.."+stopvote \t\tWill end the vote-poll\r\n"
         msg = msg.."+showvote \tShow the vote results of the poll (old = old polls) or (new = polls that haven't been closed)\r\n"
         msg = msg.."+svmain \tShow the vote results in the mainchat (old = old polls) or (new = polls that haven't been closed)\r\n"
         msg = msg.."+votelist\t\t\tShow all finished polls\r\n"
         msg = msg.."+votefor\t\t\tShow the polls that you can vote\r\n"
         msg = msg.."+vote \t\tTo vote on the poll (y = yes) (n = no) (nr = number of the poll)\r\n"
         msg = msg.."+delvote \t\tTo delete old polls (nr = number of the poll)\r\n"
         msg = msg.."\r\n"
         user:SendPM(Bot, msg)
         else
         msg = msg.."Commands to the Vote-Poll:\r\n"
         msg = msg.."\r\n"
         msg = msg.."+votefor\t\t\tShow the polls that you can vote\r\n"
         msg = msg.."+vote \t\tTo vote on the poll (y = yes) (n = no) (nr = number of the poll)\r\n"
         msg = msg.."\r\n"
         user:SendPM(Bot, msg)
         end
         return 1
      elseif (cmd=="+createvote") then
         if (user.iProfile == 0) then
         local s,e,number,question = strfind(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")
         if (tonumber(number) == nil) then
            user:SendPM(Bot, "Syntax error, +createvote , nr must be a number.")
         else
            number = tonumber(number)
            if (question == nil or question == "") then
               user:SendPM(Bot, "Syntax error, +createvote , you must write a question to the poll.")
            else
               if (CreatePoll(user, number, question) == 1) then
               user:SendPM(Bot, "The Vote-Poll has been created.")
               else
               user:SendPM(Bot, "There is a already a Vote-Poll with the number "..number..".")
               end
            end
         end
         else
            user:SendPM(Bot, "You don?t have permision to this command.")
         end
         return 1
      elseif (cmd=="+stopvote") then
         if (user.iProfile == 0) then
         local s,e,number = strfind(data,"%b<>%s+%S+%s+(.*)")
         if (tonumber(number) == nil or number == "") then
            user:SendPM(Bot, "Syntax error, +stopvote , nr must be a number.")
         else
            number = tonumber(number)
            if (OldPoll(user, number) == 1) then
               user:SendPM(Bot, "The Vote-Poll has been closed an saved on the Old Polls.")
            else
               user:SendPM(Bot, "There is no Vote-Poll with the number "..number..".")
            end
         end
         else
            user:SendPM(Bot, "You don?t have permision to this command.")
         end
         return 1
      elseif (cmd=="+showvote") then
         if (user.iProfile == 0) then
         local s,e,number, opt = strfind(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)")
         if (tonumber(number) == nil) then
            user:SendPM(Bot, "Syntax error, +showvote , nr must be a number.")
         else
            number = tonumber(number)
            if (opt == "old") then
            if (CheckPoll(user, number, oldpolls) == "") then
               user:SendPM(Bot, "There is no Vote-Poll with the number "..number..".")
            else
               user:SendPM(Bot, CheckPoll(user, number, oldpolls))
            end
            elseif(opt == "new") then
            if (CheckPoll(user, number, votetext) == "") then
               user:SendPM(Bot, "There is no Vote-Poll with the number "..number..".")
            else
               user:SendPM(Bot, CheckPoll(user, number, votetext))
            end
            else
            user:SendPM(Bot, "Syntax error, +showvote , must be (old = old polls) or (new = polls that haven't been closed)")
            end
         end
         else
            user:SendPM(Bot, "You don?t have permision to this command.")
         end
         return 1
      elseif (cmd=="+svmain") then
         if (user.iProfile == 0) then
         local s,e,number, opt = strfind(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)")
         if (tonumber(number) == nil) then
            user:SendPM(Bot, "Syntax error, +svmain , nr must be a number.")
         else
            number = tonumber(number)
            if (opt == "old") then
            if (CheckPoll(user, number, oldpolls) == "") then
               user:SendPM(Bot, "There is no Vote-Poll with the number "..number..".")
            else
               SendToAll(Bot, CheckPoll(user, number, oldpolls))
            end
            elseif(opt == "new") then
            if (CheckPoll(user, number, votetext) == "") then
               user:SendPM(Bot, "There is no Vote-Poll with the number "..number..".")
            else
               SendToAll(Bot, CheckPoll(user, number, votetext))
            end
            else
            user:SendPM(Bot, "Syntax error, +svmain , must be (old = old polls) or (new = polls that haven't been closed)")
            end
         end
         else
            user:SendPM(Bot, "You don?t have permision to this command.")
         end
         return 1
      elseif (cmd=="+votelist") then
         if (user.iProfile == 0) then
         if (readfrom(oldpolls) == nil or ReadPoll(user, oldpolls) == "") then
            user:SendPM(Bot, "There is no closed Vote-Polls")
         else
            user:SendPM(Bot, ReadPoll(user, oldpolls))
         end
         else
            user:SendPM(Bot, "You don?t have permision to this command.")
         end
         return 1
      elseif (cmd=="+votefor") then
         if (readfrom(votetext) == nil or ReadPoll(user, votetext) == "") then
            user:SendPM(Bot, "There is no Vote-Polls")
         else
            user:SendPM(Bot, ReadPoll(user, votetext))
         end
         return 1
      elseif (cmd=="+vote") then
         local s,e,number,opt = strfind(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)")
         if (tonumber(number) == nil) then
            user:SendPM(Bot, "Syntax error, +vote , nr must be a number.")
         else
            number = tonumber(number)
            if (opt == nil or opt == "" or opt ~= "n" and opt ~= "y") then
               user:SendPM(Bot, "Syntax error, +vote , must type (y = yes) or (n = no).")
            else
               if (Vote(user, number, opt) == 1) then
                  user:SendPM(Bot, "Your Vote has been registered.")
                  vt[user.sName] = 1
                  nr[user.sName] = number
               elseif(Vote(user, number, opt) == 2) then
                  user:SendPM(Bot, "You have already made a vote on this Vote-Poll")
               else
               user:SendPM(Bot, "There isn?t any Vote-Poll with the number "..number..".")
               end
            end
         end
         return 1
      elseif (cmd=="+delvote") then
         if (user.iProfile == 0) then
         local s,e,number = strfind(data,"%b<>%s+%S+%s+(%S+)")
         if (tonumber(number) == nil) then
            user:SendPM(Bot, "Syntax error, +delvote , nr must be a number.")
         else
            number = tonumber(number)
            if (DelOldPoll(user, number) == 0) then
               user:SendPM(Bot, "Ther is no Old Polll wtih the number "..number)
            else
               user:SendPM(Bot, "The Old Poll has been deleted.")
            end
         end
         else
            user:SendPM(Bot, "You don?t have permision to this command.")
         end
         return 1
      end
end
end

function CreatePoll(user, number, question)
local tmp = ""
local time = 0

   readfrom(oldpolls)
   while 1 do
      local line = read()
      if (line == nil) then
   break
      else
    local s,e,num = strfind(line,"Nr:%s+(%S+)%s+")
    if (tonumber(num) ~= nil and tonumber(num) == number) then
    time = 2
    else
    end
      end
   end
readfrom()

   readfrom(votetext)
   while 1 do
      local line = read()
      if (line == nil) then
    if (time == 2) then
         break
    else
    tmp = tmp.."Nr: "..number.." Question: "..question.." Yes: 0 No: 0 Active: Yes\r\n"
    time = 1
         break
         end
      else
    local s,e,num = strfind(line,"Nr:%s+(%S+)%s+")
    if (tonumber(num) ~= nil and tonumber(num) == number) then
    tmp = tmp..line.."\r\n"
    time = 2
    else
    tmp = tmp..line.."\r\n"
    end
      end
   end
readfrom()
writeto(votetext)
write(tmp)
writeto()
return time
end

function OldPoll(user, number)
local tmp = ""
local tmp2 = ""
local time = 0
   readfrom(votetext)
   while 1 do
      local line = read()
      if (line == nil) then
      break
      else
    local s,e, num, question, ny, nn = strfind(line,"Nr:%s+(%S+)%s+(.*)Yes:%s+(%S+)%s+No:%s+(%S+)%s+Active:")
    if (tonumber(num) ~= nil and tonumber(num) == number) then
    tmp2 = tmp2.."Nr: "..number.." "..question.."Yes: "..ny.." No: "..nn.." Active: No\r\n"
         time = 1
    else
    tmp = tmp..line.."\r\n"
    end
      end
   end
readfrom()
writeto(votetext)
write(tmp)
writeto()
if (time == 0) then
else
appendto(oldpolls)
write(tmp2)
writeto()
end
return time
end

function CheckPoll(user, number, file)
local tmp = ""
   readfrom(file)
   while 1 do
      local line = read()
      if (line == nil) then
      break
      else
    local s,e, num, question, ny, nn = strfind(line,"Nr:%s+(%S+)%s+(.*)Yes:%s+(%S+)%s+No:%s+(%S+)%s+Active:")
    if (tonumber(num) ~= nil and tonumber(num) == number) then
    tmp = tmp.."\r\n-------------------- Vote Poll --------------------\r\n"
    tmp = tmp.."Results of Vote-Poll Nr: "..num.."\r\n"
    tmp = tmp.."Vote "..question.."\r\n"
    tmp = tmp.."------------------------------\r\n"
    tmp = tmp.."Yes: "..ny.."\r\n"
    tmp = tmp.."No: "..nn.."\r\n"
    tmp = tmp.."------------------------------\r\n"
      if (tonumber(ny) > tonumber(nn)) then
      tmp = tmp.."Yes is Winnig."
      elseif (tonumber(ny) < tonumber(nn)) then
      tmp = tmp.."No is Winnig."
      elseif (tonumber(ny) == tonumber(nn)) then
      tmp = tmp.."Yes and No is equal."
      end
    break
    else
    end
      end
   end
readfrom()
return tmp
end

function ReadPoll(user, file)
local tmp = ""
   readfrom(file)
   while 1 do
      local line = read()
      if (line == nil or line == "") then
      break
      else
    local s,e, num, question, ny, nn = strfind(line,"Nr:%s+(%S+)%s+(.*)Yes:%s+(%S+)%s+No:%s+(%S+)%s+Active:")
    if (num == nil) then
    else
    tmp = tmp.."\r\n-------------------- Vote Poll --------------------\r\n"
    tmp = tmp.."Results of Vote-Poll Nr: "..num.."\r\n"
    tmp = tmp.."Vote "..question.."\r\n"
    tmp = tmp.."------------------------------\r\n"
    tmp = tmp.."Yes: "..ny.."\r\n"
    tmp = tmp.."No: "..nn.."\r\n"
    tmp = tmp.."------------------------------\r\n"
      if (file == oldpolls) then
      tmp = tmp.."Closed Vote-Poll\r\n"
      elseif (file == votetext) then
      tmp = tmp.."Active Vote-Poll\r\n"
      end
    end
      end
   end
readfrom()
return tmp
end

function Vote(user, number, opt)
local tmp = ""
local time = 0
if (vt[user.sName] == 1 and nr[user.sName] == number) then
   time = 2
else
   readfrom(votetext)
   while 1 do
      local line = read()
      if (line == nil) then
      break
      else
    local s,e, num, question, ny, nn = strfind(line,"Nr:%s+(%S+)%s+(.*)Yes:%s+(%S+)%s+No:%s+(%S+)%s+Active:")
    if (tonumber(num) ~= nil and tonumber(num) == number) then
    if (opt == "y") then
       ny = tonumber(ny) + 1
    elseif (opt == "n") then
       nn = tonumber(nn) + 1
    end
    tmp = tmp.."Nr: "..number.." "..question.."Yes: "..ny.." No: "..nn.." Active: Yes\r\n"
         time = 1
    else
    tmp = tmp..line.."\r\n"
    end
      end
   end
readfrom()
writeto(votetext)
write(tmp)
writeto()
end
return time
end

function DelOldPoll(user, number)
local tmp = ""
local time = 0
   readfrom(oldpolls)
   while 1 do
      local line = read()
      if (line == nil) then
      break
      else
    local s,e, num, question, ny, nn = strfind(line,"Nr:%s+(%S+)%s+(.*)Yes:%s+(%S+)%s+No:%s+(%S+)%s+Active:")
    if (tonumber(num) ~= nil and tonumber(num) == number) then
         time = 1
    else
    tmp = tmp..line.."\r\n"
    end
      end
   end
readfrom()
writeto(oldpolls)
write(tmp)
writeto()
return time
end

jiten

Check this .

Best regards.

kash?


jiten


kash?

hey, is it possible to display all vote-polls
in main chat at short intervals and customise
the time duration to display each one....

jiten

Which ones do u want to show in main?
The ones that u can vote for?

kash?

ya....I want to show active polls for which can be voted

jiten

Try this one:

Part 1:

--Made by nErBoS 
--Converted to Lua 5 by jiten
--Added: Timer between each mainchat votepoll display

Bot = "Vote-Bot" 

vt = {} 
nr = {} 

sec = 1000 
min = 60*sec 
hour = 60*min 
iTime = 1*min-- Time between each votepoll display 

votetext = "votepoll.txt" --Will be created in the script folder 
oldpolls = "oldpolls.txt" --Will be created in the script folder 

function Main() 
	frmHub:RegBot(Bot)
	SetTimer(iTime) 
	StartTimer() 
end 

function OnTimer() 
	SendToAll(ReadPoll(user, votetext))
end 

function NewUserConnected(user, data) 
	if (vt[user.sName] == nil) then 
		vt[user.sName] = 0 
	end 
	if (nr[user.sName] == nil) then 
		nr[user.sName] = 0 
	end 
end 

function ChatArrival(user, data) 
	data=string.sub(data,1,string.len(data)-1) 
	s,e,cmd = string.find(data,"%b<>%s+(%S+)") 
	if (cmd=="+votehelp") then 
		local msg = "" 
		if (user.iProfile == 0) then 
			msg = msg.."Commands to the Vote-Poll:\r\n" 
			msg = msg.."\r\n" 
			msg = msg.."+createvote  \tCreates a poll (nr = number to give to poll) (q = Poll question)\r\n" 
			msg = msg.."+stopvote \t\tWill end the vote-poll\r\n" 
			msg = msg.."+showvote  \tShow the vote results of the poll (old = old polls) or (new = polls that haven't been closed)\r\n" 
			msg = msg.."+svmain  \tShow the vote results in the mainchat (old = old polls) or (new = polls that haven't been closed)\r\n" 
			msg = msg.."+votelist\t\t\tShow all finished polls\r\n" 
			msg = msg.."+votefor\t\t\tShow the polls that you can vote\r\n" 
			msg = msg.."+vote  \t\tTo vote on the poll (y = yes) (n = no) (nr = number of the poll)\r\n" 
			msg = msg.."+delvote \t\tTo delete old polls (nr = number of the poll)\r\n" 
			msg = msg.."\r\n" 
			user:SendPM(Bot, msg) 
		else 
			msg = msg.."Commands to the Vote-Poll:\r\n" 
			msg = msg.."\r\n" 
			msg = msg.."+votefor\t\t\tShow the polls that you can vote\r\n" 
			msg = msg.."+vote  \t\tTo vote on the poll (y = yes) (n = no) (nr = number of the poll)\r\n" 
			msg = msg.."\r\n" 
			user:SendPM(Bot, msg) 
		end 
		return 1 
	elseif (cmd=="+createvote") then 
		if (user.iProfile == 0) then 
			local s,e,number,question = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(.*)") 
			if (tonumber(number) == nil) then 
				user:SendPM(Bot, "Syntax error, +createvote  , nr must be a number.") 
			else 
				number = tonumber(number) 
				if (question == nil or question == "") then 
					user:SendPM(Bot, "Syntax error, +createvote  , you must write a question to the poll.") 
				else 
					if (CreatePoll(user, number, question) == 1) then 
						user:SendPM(Bot, "The Vote-Poll has been created.") 
					else 
						user:SendPM(Bot, "There is a already a Vote-Poll with the number "..number..".") 
					end 
				end 
			end 
		else 
			user:SendPM(Bot, "You don?t have permision to this command.") 
		end 
		return 1 
	elseif (cmd=="+stopvote") then 
		if (user.iProfile == 0) then 
			local s,e,number = string.find(data,"%b<>%s+%S+%s+(.*)") 
			if (tonumber(number) == nil or number == "") then 
				user:SendPM(Bot, "Syntax error, +stopvote , nr must be a number.") 
			else 
				number = tonumber(number) 
				if (OldPoll(user, number) == 1) then 
					user:SendPM(Bot, "The Vote-Poll has been closed an saved on the Old Polls.") 
				else 
					user:SendPM(Bot, "There is no Vote-Poll with the number "..number..".") 
				end 
			end 
		else 
			user:SendPM(Bot, "You don?t have permision to this command.") 
		end 
		return 1 
	elseif (cmd=="+showvote") then 
		if (user.iProfile == 0) then 
			local s,e,number, opt = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)") 
			if (tonumber(number) == nil) then 
				user:SendPM(Bot, "Syntax error, +showvote  , nr must be a number.") 
			else 
				number = tonumber(number) 
				if (opt == "old") then 
					if (CheckPoll(user, number, oldpolls) == "") then 
						user:SendPM(Bot, "There is no Vote-Poll with the number "..number..".") 
					else 
						user:SendPM(Bot, CheckPoll(user, number, oldpolls)) 
					end 
				elseif(opt == "new") then 
					if (CheckPoll(user, number, votetext) == "") then 
						user:SendPM(Bot, "There is no Vote-Poll with the number "..number..".") 
					else 
						user:SendPM(Bot, CheckPoll(user, number, votetext)) 
					end 
				else 
					user:SendPM(Bot, "Syntax error, +showvote  , must be (old = old polls) or (new = polls that haven't been closed)") 
				end 
			end 
		else 
			user:SendPM(Bot, "You don?t have permision to this command.") 
		end 
		return 1 
	elseif (cmd=="+svmain") then 
		if (user.iProfile == 0) then 
			local s,e,number, opt = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)") 
			if (tonumber(number) == nil) then 
				user:SendPM(Bot, "Syntax error, +svmain  , nr must be a number.") 
			else 
				number = tonumber(number) 
				if (opt == "old") then 
					if (CheckPoll(user, number, oldpolls) == "") then 
						user:SendPM(Bot, "There is no Vote-Poll with the number "..number..".") 
					else 
						SendToAll(Bot, CheckPoll(user, number, oldpolls)) 
					end 
				elseif(opt == "new") then 
					if (CheckPoll(user, number, votetext) == "") then 
						user:SendPM(Bot, "There is no Vote-Poll with the number "..number..".") 
					else 
						SendToAll(Bot, CheckPoll(user, number, votetext)) 
					end 
				else 
					user:SendPM(Bot, "Syntax error, +svmain  , must be (old = old polls) or (new = polls that haven't been closed)") 
				end 
			end 
		else 
			user:SendPM(Bot, "You don?t have permision to this command.") 
		end 
		return 1 
	elseif (cmd=="+votelist") then 
		if (user.iProfile == 0) then 
			local l = io.open(oldpolls, "r")
			if (ReadPoll(user, oldpolls) == "") then 
				user:SendPM(Bot, "There is no closed Vote-Polls") 
			else 
				user:SendPM(Bot, ReadPoll(user, oldpolls)) 
			end 
		else 
			user:SendPM(Bot, "You don?t have permision to this command.") 
		end 
		return 1 
	elseif (cmd=="+votefor") then 
		if (ReadPoll(user, votetext) == "") then 
			user:SendPM(Bot, "There is no Vote-Polls") 
		else 
			user:SendPM(Bot, ReadPoll(user, votetext)) 
		end 
		return 1 
	elseif (cmd=="+vote") then 
		local s,e,number,opt = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)") 
		if (tonumber(number) == nil) then 
			user:SendPM(Bot, "Syntax error, +vote  , nr must be a number.") 
		else 
			number = tonumber(number) 
			if (opt == nil or opt == "" or opt ~= "n" and opt ~= "y") then 
				user:SendPM(Bot, "Syntax error, +vote  , must type (y = yes) or (n = no).") 
		else 
					if (Vote(user, number, opt) == 1) then 
				user:SendPM(Bot, "Your Vote has been registered.") 
					vt[user.sName] = 1 
					nr[user.sName] = number 
				elseif(Vote(user, number, opt) == 2) then 
				user:SendPM(Bot, "You have already made a vote on this Vote-Poll") 
				else 
					user:SendPM(Bot, "There isn?t any Vote-Poll with the number "..number..".") 
				end 
		end 
		end 
		return 1 
	elseif (cmd=="+delvote") then 
		if (user.iProfile == 0) then 
			local s,e,number = string.find(data,"%b<>%s+%S+%s+(%S+)") 
			if (tonumber(number) == nil) then 
				user:SendPM(Bot, "Syntax error, +delvote , nr must be a number.") 
			else 
				number = tonumber(number) 
				if (DelOldPoll(user, number) == 0) then 
					user:SendPM(Bot, "Ther is no Old Polll wtih the number "..number) 
				else 
					user:SendPM(Bot, "The Old Poll has been deleted.") 
				end 
			end 
		else 
			user:SendPM(Bot, "You don?t have permision to this command.") 
		end 
		return 1 
	end 
end 

ToArrival = ChatArrival 


function CreatePoll(user, number, question) 
	local tmp = "" 
	local time = 0 
	local a = io.open(oldpolls, "r")
	if a then
		while 1 do 
			local line = a:read() 
			if (line == nil) then 
				break 
			else 
				local s,e,num = string.find(line,"Nr:%s+(%S+)%s+") 
				if (tonumber(num) ~= nil and tonumber(num) == number) then 
					time = 2 
				else 
				end 
			end 
		end 
		a:close()
	else 
		local m = io.open(oldpolls,"w+")
		m:flush()
		m:close()
	end

	local b = io.open(votetext,"r")
	if b then
		while 1 do 
			local line = b:read() 
			if (line == nil) then 
				if (time == 2) then 
					break 
				else 
					tmp = tmp.."Nr: "..number.." Question: "..question.." Yes: 0 No: 0 Active: Yes\r\n" 
					time = 1 
					break 
				end 
			else 
				local s,e,num = string.find(line,"Nr:%s+(%S+)%s+") 
				if (tonumber(num) ~= nil and tonumber(num) == number) then 
					tmp = tmp..line.."\r\n" 
					time = 2 
				else 
					tmp = tmp..line.."\r\n" 
				end 
			end 
		end 
		b:close()
		local l = io.open(votetext,"w+")
		l:write(tmp)
		l:flush()
		l:close()
		return time 
	else 
		local n = io.open(votetext,"w+")
		n:flush()
		n:close()
	end
	return time 
end 

function OldPoll(user, number) 
	local tmp = "" 
	local tmp2 = "" 
	local time = 0 
	local c = io.open(votetext,"r")
	if c then
		while 1 do 
			local line = c:read() 
			if (line == nil) then 
				break 
			else 
				local s,e, num, question, ny, nn = string.find(line,"Nr:%s+(%S+)%s+(.*)Yes:%s+(%S+)%s+No:%s+(%S+)%s+Active:") 
				if (tonumber(num) ~= nil and tonumber(num) == number) then 
					tmp2 = tmp2.."Nr: "..number.." "..question.."Yes: "..ny.." No: "..nn.." Active: No\r\n" 
					time = 1 
				else 
					tmp = tmp..line.."\r\n" 
				end 
			end 
		end 
		c:close()
		local d = io.open(votetext,"w+")
		d:write(tmp)
		d:flush()
		d:close()
		if (time == 0) then 
		else 
			local e = io.open(oldpolls, "a+") -- "a+"
			e:write(tmp2) 
			e:close()
		end 
		return time 
	else 
	end
end

jiten

Part 2:

function CheckPoll(user, number, file) 
	local tmp = "" 
	local f = io.open(file,"r")
	if f then
		while 1 do 
			local line = f:read() 
			if (line == nil) then 
				break 
			else 
				local s,e, num, question, ny, nn = string.find(line,"Nr:%s+(%S+)%s+(.*)Yes:%s+(%S+)%s+No:%s+(%S+)%s+Active:") 
				if (tonumber(num) ~= nil and tonumber(num) == number) then 
					tmp = tmp.."\r\n-------------------- Vote Poll --------------------\r\n" 
					tmp = tmp.."Results of Vote-Poll Nr: "..num.."\r\n" 
					tmp = tmp.."Vote "..question.."\r\n" 
					tmp = tmp.."------------------------------\r\n" 
					tmp = tmp.."Yes: "..ny.."\r\n" 
					tmp = tmp.."No: "..nn.."\r\n" 
					tmp = tmp.."------------------------------\r\n" 
					if (tonumber(ny) > tonumber(nn)) then 
						tmp = tmp.."Yes is Winnig." 
					elseif (tonumber(ny) < tonumber(nn)) then 
						tmp = tmp.."No is Winnig." 
					elseif (tonumber(ny) == tonumber(nn)) then 
					tmp = tmp.."Yes and No is equal." 
					end 
					break 
				else 
				end 
			end 
		end
		f:close()
		return tmp 
	else 
	end
end 

function ReadPoll(user, file) 
	local tmp = "" 
	local g = io.open(file,"r")
	if g then
		while 1 do 
			local line = g:read() 
			if (line == nil or line == "") then 
				break 
			else 
				local s,e, num, question, ny, nn = string.find(line,"Nr:%s+(%S+)%s+(.*)Yes:%s+(%S+)%s+No:%s+(%S+)%s+Active:") 
				if (num == nil) then 
				else 
					tmp = tmp.."\r\n-------------------- Vote Poll --------------------\r\n" 
					tmp = tmp.."Results of Vote-Poll Nr: "..num.."\r\n" 
					tmp = tmp.."Vote "..question.."\r\n" 
					tmp = tmp.."------------------------------\r\n" 
					tmp = tmp.."Yes: "..ny.."\r\n" 
					tmp = tmp.."No: "..nn.."\r\n" 
					tmp = tmp.."------------------------------\r\n" 
					if (file == oldpolls) then 
						tmp = tmp.."Closed Vote-Poll\r\n" 
					elseif (file == votetext) then 
						tmp = tmp.."Active Vote-Poll\r\n" 
					end 
				end 
			end 
		end 
		g:close()
		return tmp 
	else 
		return 1
	end
end 

function Vote(user, number, opt) 
	local tmp = "" 
	local time = 0 
	if (vt[user.sName] == 1 and nr[user.sName] == number) then 
		time = 2 
	else 

		local h = io.open(votetext,"r")
		if h then
			while 1 do 
				local line = h:read() 
				if (line == nil) then 
					break 
				else 
					local s,e, num, question, ny, nn = string.find(line,"Nr:%s+(%S+)%s+(.*)Yes:%s+(%S+)%s+No:%s+(%S+)%s+Active:") 
					if (tonumber(num) ~= nil and tonumber(num) == number) then 
						if (opt == "y") then 
							ny = tonumber(ny) + 1 
						elseif (opt == "n") then 
							nn = tonumber(nn) + 1 
						end 
						tmp = tmp.."Nr: "..number.." "..question.."Yes: "..ny.." No: "..nn.." Active: Yes\r\n" 
						time = 1 
					else 
						tmp = tmp..line.."\r\n" 
					end 
				end 
			end 
			h:close()
		else 
		end
		local i = io.open(votetext,"w+")
		i:write(tmp)
		i:flush()
		i:close()
	end 
	return time 
end 

function DelOldPoll(user, number) 
	local tmp = "" 
	local time = 0 

	local j = io.open(oldpolls,"r")
	if j then
		while 1 do 
			local line = j:read() 
			if (line == nil) then 
				break 
			else 
				local s,e, num, question, ny, nn = string.find(line,"Nr:%s+(%S+)%s+(.*)Yes:%s+(%S+)%s+No:%s+(%S+)%s+Active:") 
				if (tonumber(num) ~= nil and tonumber(num) == number) then 
					time = 1 
				else 
					tmp = tmp..line.."\r\n" 
				end 
			end 
		end 
		j:close()
	else 
	end
	local k = io.open(oldpolls,"w+")
	k:write(tmp)
	k:flush()
	k:close()
	return time 
end

kash?

I want all vote polls to be shown at different
intervals and SEPERATELY and not together
with different customisable timer for each poll

how's ur name is jiten...r u Indian

The_Fox

Problem is there's only one timer for each script in PtokaX... so if you want the polls to be independent, you'd either have to have each poll in a standalone script or you'd have to make the timer lauch different poll each time, with different timer settings  :D

bastya_elvtars

QuoteOriginally posted by The_Fox
Problem is there's only one timer for each script in PtokaX... so if you want the polls to be independent, you'd either have to have each poll in a standalone script or you'd have to make the timer lauch different poll each time, with different timer settings  :D

I have some timer thingy posted here. Gonna make a HOWTO later.
Everything could have been anything else and it would have just as much meaning.

jiten

QuoteOriginally posted by bastya_elvtars
QuoteOriginally posted by The_Fox
Problem is there's only one timer for each script in PtokaX... so if you want the polls to be independent, you'd either have to have each poll in a standalone script or you'd have to make the timer lauch different poll each time, with different timer settings  :D

I have some timer thingy posted here. Gonna make a HOWTO later.

Roger that, bastya  ;)

Dessamator

well u could always use a multitimer, with tables for each votepoll, but damn, what a lot of programming, gooooooooooooood luck !!!  :D
Ignorance is Bliss.

jiten


kash?

thanx anyways for ur help...........

SMF spam blocked by CleanTalk