Scripts Conflit ?!
 

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

Scripts Conflit ?!

Started by nEgativE, 25 January, 2004, 08:41:54

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nEgativE

Hi there, i think i have here a script conflit or something..
I have these scripts running..



-----------------------------------------------------------------------------
-- 
online user counter by plop v:1.2
-- based on a bot by ....... witch showed basic hub info 2 users on entry
-- (fill in the name pls if you know who this was)
-----------------------------------------------------------------------------
-- 
LEVELSTOT[number] = total number of users with that level
-- LEVELS[number] = total online number of users with that level
-- commands table of triggers used by the hub 2 add/delete users 
-- add the script commands yourself if you use a script 2 add/delete users
-- same can be done if you have more user levels then default
-----------------------------------------------------------------------------
-- 
tables all over but i seem 2 have forgotten 2 add chairssnif snif
-----------------------------------------------------------------------------
-- 
manual stuff
-----------------------------------------------------------------------------
-- 
LEVELSTOT["0"] -- total masters
-- LEVELSTOT["1"] -- total operators
-- LEVELSTOT["2"] -- total VIPs
-- LEVELSTOT["3"] -- total registred users
-- tmp -- total operators and masters
-- frmHub:GetUsersCount() -- total online users
----------
-- 
LEVELS["0"] -- total online masters
-- LEVELS["1"] -- total online operators
-- LEVELS["2"] -- total online VIPs
-- LEVELS["3"] -- total online registered users
-- LEVELS["-1"] -- total online unregistered users
-- tmp3 -- total operators and masters
----------
-- 
offline users
-- LEVELSTOT["0"] - LEVELS["0"] == offline operators
-- tmp1 -- total offline VIPs
-- tmp2 -- total offline registered users
-----------------------------------------------------------------------------


-- 
name of the bot
Bot 
"[operserv]"
Multi "[multihub]=--------------------"

-- couter tables, if you have more levels add there numbers in BOTH tables,
-- 
except unreg usersthose only work in the lower table
LEVELSTOT 
= {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0}
LEVELS = {["0"]=0, ["1"]=0, ["2"]=0, ["3"]=0, ["-1"]=0}

-- 
table holding the commands ptokax uses 2 add/delete users
-- add your bot's commands 2 this table if you use a bot 2 add/delete ppl
commands = {["!addreguser"]=1, ["!delreguser"]=1}

function Message(user)
   local s,e,share = strfind(user.sMyInfoString, "$(%d+)%$")
   share = format("%0.2f", ( share / (1024*1024*1024)))
   local hubshare = format("%0.2f",  ( frmHub:GetCurrentShareAmount() / (1024*1024*1024)))
   local tmp = LEVELSTOT["1"] + LEVELSTOT["0"]  --- total ops  (adding masters 2 ops)
   local tmp1 = (LEVELSTOT["2"] - LEVELS["2"]) if tmp1 < 0 then tmp1 = 0 end --- offline vips (total - online)
   local tmp2 = (LEVELSTOT["3"] - LEVELS["3"]) if tmp2 < 0 then tmp2 = 0 end --- offline regs (total - online)
   local tmp3 = LEVELS["1"] + LEVELS["0"] -- online ops (adding masters 2 the ops)
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-") 
   user:SendData(Multi, "
	
<----------------=[- "..frmHub:GetHubName().." v2004 -]=-") 
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-") 
   user:SendData(Bot, "    
	
? Comunidade Lusobrasileira de ?irect C?nnect ?") 
   user:SendData(Bot, "    
	
? "..user.sName..", bem vindo ao servidor.") 
   user:SendData(Bot, "    
	
? Seu endere?o IP: "..user.sIP) 
   user:SendData(Bot, "    
	
? Seu status no Hub: "..(GetProfileName(user.iProfile) or "N?o registrado")) 
   user:SendData(Bot, "    
	
? Voc? est? compartilhando: "..share.." GB.") 
   user:SendData(Bot, "    
	
? Usu?rios Online no Hub: "..frmHub:GetUsersCount()..".") 
   user:SendData(Bot, "    
	
? Operadores Online no Hub: "..tmp3..". ViPs: "..LEVELS["2"]..".")
   user:SendData(Bot, "    
	
? Total de Operadores registrados no Hub: "..tmp..". ViPs: "..LEVELSTOT["2"]..".")
   user:SendData(Bot, "    
	
? Usu?rios registrados n?o conectados: "..tmp2..".")
   user:SendData(Bot, "    
	
? Compartilhamento atual no Hub: "..hubshare.." GB.") 
   user:SendData(Bot, "    
	
? Lista de comandos, regras, ajuda e informa??o: !ajuda") 
   user:SendData(Bot, "    
	
? Website: www.lusobrasil.rg3.net") 
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-") 
   user:SendData(Multi, "
	
<----------------=[- "..frmHub:GetHubName().." v2004 -]=-") 
   user:SendData(Bot, "-=[?]=-----------------------------------------------------------------------------------------------=[?]=-") 
end

------------- better not 2 touch anything below here if your not sure what your your doing
ALLUSERS={}

function NewUserConnected(user)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   Message(user)
end

function OpConnected(user)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   Message(user)
end

function DataArrival(user, data)
   if ALLUSERS[user.sName]==nil then
      ALLUSERS[user.sName]=1
      LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]+1
   end
   s,e,cmd= strfind(data, "%b<>%s+(%S+)")
   if cmd ~= nil and commands[cmd] then
      SetTimer(5 * 1000) 
      StartTimer()
   end
end

function OnTimer()
   StopTimer()
   OpenRegisterdUsersFile()
end

function UserDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end

function OpDisconnected(user)
   if ALLUSERS[user.sName] then
      ALLUSERS[user.sName]=nil
      if LEVELS[tostring(user.iProfile)] > 0 then
         LEVELS[tostring(user.iProfile)]=LEVELS[tostring(user.iProfile)]-1
      end
   end
end

function Main()
   frmHub:RegBot(Bot)
   OpenRegisterdUsersFile()
end

function OpenRegisterdUsersFile()
   readfrom("../RegisteredUsers.dat")
   for a,b in LEVELSTOT do
      LEVELSTOT[a]=0
   end
   while 1 do
      local line = read()
      local level 
      if line == nil then 
         readfrom()
         break 
      end
      s,e,level = strfind(line,".+|.+|(.+)")
      if LEVELSTOT[level] then
         LEVELSTOT[level] = LEVELSTOT[level] +1
      end
   end  
end



And this one..



-- easyranger
-- tezlo

BotName 
"[operserv]" 

ipRanges = {}

denyMsg "<[operserv]> IP-Range tempor?riamente banido no LusoBrasil Hub, d?vidas informe --> lusobrasil@netcabo.pt"

function compute(ip)
	
local seabcstrfind(ip"^(%d+).(%d+).(%d+).(%d+)$")
	
if 
s then return a*16777216 b*65536 c*256 d end return 0
end

function checkrange(tableip)
	
return 
foreachi(table, function(idtmp)
	
	
if (%
ip >= tmp[1]) and (%ip <= tmp[2]) then return tmp end
	
end)
end

function load(namedata)
	
ipRanges[name] = ipRanges[name] or {}
	
gsub(data"(%S+) %- (%S+)", function(se)
	
	
scompute(s), compute(e)
	
	
tinsert(ipRanges[%name], { s})
	
end)
end

function Main()
	
local f openfile("txt/ranger.dat""r"assert(f"txt/ranger.dat")
	
local file read(f"*a"closefile(f)
	
gsub(file"%[(%S+)%]([%c%d%s%-%.]+)"load)
end

function NewUserConnected(user)
	
if 
user.iProfile ~= -1 then return end
	
local ipblock compute(user.sIP)
	
for 
namerange in ipRanges do
	
	
if 
checkrange(rangeipthen block name break end
	
end if block then
	
	
SendToOps(BotName"Usu?rio "..user.sName.." com o IP: [ "..user.sIP.." ] foi desconectado, motivo: "..block)
	
	
user:SendData(denyMsg
	
	
user:TempBan()
	
end
end



Both working great, but that i have a syntax error when an user with that ipranger tries to connect :(
I think this scripts erros (syntax) are related with the function NewUserConnected(user) i think that they can't read something on user, since he got banned by iprange. don't know :\

Tks in advance, and Plop 4 Moderator Now =)


Syntax error
bad argument #1 to `strfind' (string expected, got nil)
stack traceback:
   
1:  function `strfind' [C]
   2:  function 
`Message' at line 51 [file `...\ptokax\scripts\lusobrasil.onjoin.lua']
   
3:  function `NewUserConnected' at line 86 [file `...\ptokax\scripts\lusobrasil.onjoin.lua']

Syntax error: bad argument #1 to `strfind' 
(string expectedgot nil)
stack traceback:
   
1:  function `strfind' [C]
   2:  function 
`NewUserConnected' at line 365 [file `C:\ptokax\scripts\lusobrasil.hub.lua']


plop

try inserting the next on the line below NewUserConnected

if user.iProfile then

and offcourse a extra end @ the end of the function.

1 more question.
are you running the 0.3.3.0 beta???
as there is a bug in that which can cause errors like this 2 show up, but in fact the scripts work oke.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

SMF spam blocked by CleanTalk