share Controler
 

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

share Controler

Started by damo, 27 May, 2005, 00:47:08

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

damo

maybe someone can help me with this table conversion please i have changed the script from lua 4 thats if its right

--Requested by jsjen
--Made by nErBoS

Bot = "Share-Controler"

sharertxt = "shares.txt" --Will be created in the script folder
sh = {}

function Main()
   frmHub:RegBot(Bot)
end

function NewUserConnected(user, data)
   local s,e,share = string.find(user.sMyInfoString, "%$%s*(%d+)%$")
   share = string.format("%0.2f", tonumber(share)/(1024*1024*1024))
   CheckShare(user, share)
end

OpConnected = NewUserConnected

function ChatArrival(user, data)
   if (string.sub(data,1,1)=="<") or (string.sub(data,1,5+string.len(Bot))=="$To: "..Bot) then
   data=string.sub(data,1,string.len(data)-1)
   s,e,cmd = string.find(data,"%b<>%s+(%S+)")
      if (cmd=="!sgrw") then
         if (user.bOperator) then
            local s,e,who = string.find(data,"%b<>%s+%S+%s+(%S+)")
            if (who == nil or who == "") then
               user:SendPM(Bot, "Syntax Error, !sgrw , you must write a name.")
            else
               user:SendPM(Bot, CheckUser(who))
            end
         else
            user:SendPM(Bot, "You don?t have permission to use this command.")
         end
         return 1
      end
   end
end

function CheckUser(user)
local tmp = ""
   if (readfrom(sharertxt) == nil) then
      tmp = tmp.."the file hasn't been created yet."
   else
      readfrom(sharertxt)
      while 1 do
      local line = read()
         if (line == nil) then
            tmp = tmp.."The user "..user.." wasn't found in the list, have you write the right name ?"
            break
         else
            local s,e,who,lshare, fshare = string.find(line, "(%S+)%s+%&%s+(%S+)%s+&%s+(%S+)")
            if (who ~= nil and string.lower(who) == string.lower(user) ) then
               if (GetItemByName(user) ~= nil) then
                  tmp = tmp.."The user "..user.." is sharing "..lshare.." GB his last share was "..fshare.." GB."
               else
                  tmp = tmp.."The user "..user.." has shared "..lshare.." GB."
               end
               break
            end
         end
      end
      readfrom()
   end
return tmp
end
      

function CheckShare(user, share)
local tmp = ""
local time = 0
   if (readfrom(sharertxt) == nil) then
      writeto(sharertxt)
      write(user.sName.." & "..share.." & 0\r\n")
      writeto()
   else
      readfrom(sharertxt)
      while 1 do
      local line = read()
         if (line == nil) then
            if (time == 0) then
               tmp = tmp..user.sName.." & "..share.." & 0\r\n"
            end
            break
         else
            local s,e,who,nshare = string.find(line, "(%S+)%s+%&%s+(%S+)%s+&%s+%S+")
            if (who ~= nil and string.lower(who) == string.lower(user.sName)) then
               if (tonumber(nshare) > tonumber(share)) then
                  SendPmToOps(Bot, "The user "..user.sName.." has least share then his last loggin.")
                  SendPmToOps(Bot, "He had "..nshare.." GB and now he has "..share.." GB.")
                  tmp = tmp..user.sName.." & "..share.." & "..nshare.."\r\n"
                  sh[user.sName] = share
                  time = 1
               elseif (tonumber(nshare) < tonumber(share)) then
                  SendPmToOps(Bot, "The user "..user.sName.." has more share then his last loggin.")
                  SendPmToOps(Bot, "He had "..nshare.." GB and now he has "..share.." GB.")
                  tmp = tmp..user.sName.." & "..share.." & "..nshare.."\r\n"
                  sh[user.sName] = share
                  time = 1
               elseif (tonumber(nshare) == tonumber(share)) then
                  tmp = tmp..user.sName.." & "..share.." & "..nshare.."\r\n"
                  sh[user.sName] = share
                  time = 1
               end
            else
               tmp = tmp..line.."\r\n"
            end
         end
      end
      readfrom()
      writeto(sharertxt)
      write(tmp)
      writeto()
   end
end

jiten

There's a similar script I posted some while ago.
Check this link.

Cheers

damo

i did try that one but it disconected all me users

jiten

Here goes a fast one then:
-- Lua 5 version by jiten
--Requested by jsjen
--Made by nErBoS

Bot = "Share-Controler"

sharertxt = "shares.txt" --Will be created in the script folder
sh = {}

function Main()
	frmHub:RegBot(Bot)
end

function NewUserConnected(user, data)
	local share = user.iShareSize
	local i = string.format("%0.2f", tonumber(share)/(1024*1024*1024))
	CheckShare(user, i)
end

OpConnected = NewUserConnected

function ChatArrival(user, data)
	local data = string.sub(data, 1, -2) 
	local s,e,cmd = string.find(data,"%b<>%s+(%S+)")
	if cmd == "!sgrw" then
		if (user.bOperator) then
			local s,e,who = string.find(data,"%b<>%s+%S+%s+(%S+)")
			if (who == nil or who == "") then
				user:SendPM(Bot, "Syntax Error, !sgrw , you must write a name.")
			else
				user:SendPM(Bot, CheckUser(who))
			end
		else
			user:SendPM(Bot, "You don?t have permission to use this command.")
		end
		return 1
	end
end

ToArrival = ChatArrival

function CheckUser(user)
	local tmp = ""
	if (Verify(sharertxt) == nil) then
		tmp = tmp.."the file hasn't been created yet."
	else
		local e = io.open(sharertxt,"r")
		while 1 do
			local line = e:read("*l")
			if (line == nil) then
				tmp = tmp.."The user "..user.." wasn't found in the list, have you write the right name ?"
				break
			else
				local s,e,who,lshare, fshare = string.find(line, "(%S+)%s+%&%s+(%S+)%s+&%s+(%S+)")
				if (who ~= nil and string.lower(who) == string.lower(user) ) then
					if (GetItemByName(user) ~= nil) then
						tmp = tmp.."The user "..user.." is sharing "..lshare.." GB his last share was "..fshare.." GB."
					else 
						tmp = tmp.."The user "..user.." has shared "..lshare.." GB."
					end
					break
				end
			end
		end
		e:read()
		e:close()
	end
	return tmp
end
		

function CheckShare(user, share)
	local tmp, time = "",0
	if (Verify(sharertxt) == nil) then
		local f = io.open(sharertxt,"w+")
		f:write(user.sName.." & "..share.." & 0\r\n")
		f:close()
	else
		local g = io.open(sharertxt,"r")
		while 1 do
			local line = g:read("*l")
			if (line == nil) then
				if (time == 0) then
					tmp = tmp..user.sName.." & "..share.." & 0\r\n"
				end
				break
			else
				local s,e,who,nshare = string.find(line, "(%S+)%s+%&%s+(%S+)%s+&%s+%S+")
				if (who ~= nil and string.lower(who) == string.lower(user.sName)) then
					if (tonumber(nshare) > tonumber(share)) then
						SendPmToOps(Bot, "The user "..user.sName.." has least share then his last loggin.")
						SendPmToOps(Bot, "He had "..nshare.." GB and now he has "..share.." GB.")
						tmp = tmp..user.sName.." & "..share.." & "..nshare.."\r\n"
						sh[user.sName] = share
						time = 1
					elseif (tonumber(nshare) < tonumber(share)) then
						SendPmToOps(Bot, "The user "..user.sName.." has more share then his last loggin.")
						SendPmToOps(Bot, "He had "..nshare.." GB and now he has "..share.." GB.")
						tmp = tmp..user.sName.." & "..share.." & "..nshare.."\r\n"
						sh[user.sName] = share
						time = 1
					elseif (tonumber(nshare) == tonumber(share)) then
						tmp = tmp..user.sName.." & "..share.." & "..nshare.."\r\n"
						sh[user.sName] = share
						time = 1
					end
				else
					tmp = tmp..line.."\r\n"
				end
			end
		end
		g:read()
		g:close()
		local h = io.open(sharertxt,"w+")
		h:write(tmp)
		h:close()
	end
end

function Verify(filename)
	local f = io.open(filename, "r")
	if f then
		f:close()
		return true
	end
end

SMF spam blocked by CleanTalk