PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: Op on 25 May, 2006, 15:01:12

Title: Help please convert script to lua 5
Post by: Op on 25 May, 2006, 15:01:12
Please convert to lua 5 thank

-----------------------------------------------------------------
-- A.I. Anti Advertising v1.1 - written by Guibs 21th Apr 2003 --
-----------------------------------------------------------------
---------------------
-- Version History --
---------------------
-- Converted to Lua5 By Jelf 10/03/05
-- v1.1 Changes synthax about 'strfind' (Thks to sedulus for the tips), by Guibs 21th Apr 2003
-- v1.1 added +allowedadd, +refusedadd commands (Thks to Dazzler for the ideas), by Guibs 21th Apr 2003
-- v1.0 first version. Greets to sebastiannielsen for the cool idea

-- It works in PM, and on the main chat & blocks the bad addresses
-- Ops can't be kicked
-- Edit the safeadd list, to put your good hub addresses

------------------------------------
-- Sourcecode is below this point --
------------------------------------

safeadd = {
["landofps.ath.cx"]=1,
["landofps2.ath.cx"]=2
}

trigs = {
["dns2go"]=1,
["myftpsite"]=2,
["servebeer"]=3,
["mine.nu"]=4,
["ip.com"]=5,
["dynip"]=6,
["staticip"]=7,
["serveftp"]=8,
["ipactive"]=9,
["ip.org"]=10,
["servegame"]=11,
["ath.cx"]=12,
["dyndns"]=13,
["clanpimp"]=14,
["idlegames"]=15,
["sytes"]=16,
["uni.cc"]=17,
["homeunix"]=18,
["deftonzs.com"]=19,
["flamenap"]=20,
["xs4all"]=21,
["serveftp"]=22,
["myftp"]=23,
["http://www.angelfire.com"]=24,
["hopto.org"]=25,
["orgdns"]=26
}

---------------------
-- Global Settings --
---------------------
returndata = 0
founded = 0
safe = 0
allowedadd = 0
refusedadd = 0
opchat = frmHub:GetOpChatName()
Bot = frmHub:GetHubBotName()
---------------------------------
function ChatArrival(user, data)
if (string.sub(data,1,1)=="<") then
data=string.sub(data,1,string.len(data)-1)
s,e,to,cmd=string.find(data,"<(.*)>%s+(%S+)")
cmd=string.lower(cmd)
s,e,cmd = string.find(data,"%b<>%s+(%S+)")
if user.bOperator then
if (cmd=="+allowedadd") then
user:SendData(Bot, allowedadd.." allowed addresses have been sent on the main chat or in pm")
returndata = 1
return 1
elseif (cmd=="+refusedadd") then
user:SendData(Bot, refusedadd.." refused addresses have been sent on the main chat or in pm")
returndata = 1
return 1
end
end
if user.bOperator then
else
for key,a in trigs do
if(string.find(string.lower(data),key,5,1)) then
founded = 1
break
end
end
if founded == 1 then
for safekey,a in safeadd do
if(string.find(string.lower(data),safekey,5,1)) then
safe = 1
break
end
end
end
if founded == 1 then
if safe == 1 then
allowedadd=allowedadd+1
else
returndata = 1
refusedadd=refusedadd+1
SendPmToOps(opchat, user.sName.." has been disconnected because of advertising: "..data )
user:SendData(Bot, "You have been disconnected because of advertising")
user:Disconnect()
end
end
end
end
end
-----------------------------
function ToArrival(user, data)
if(string.sub(data, 1, 4) == "$To:") then
data=string.sub(data,1,string.len(data)-1)
s,e,whoTo = string.find(data,"$To:%s+(%S+)")
s,e,To,from,cmd = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.*)")
if user.bOperator then
else
for key,a in trigs do
if(string.find(string.lower(data),key,17,1)) then
founded = 1
break
end
end
if founded == 1 then
for safekey,a in safeadd do
if(string.find(string.lower(data),safekey,17,1)) then
safe = 1
break
end
end
end
if founded == 1 then
if safe == 1 then
allowedadd=allowedadd+1
else
returndata = 1
refusedadd=refusedadd+1
SendPmToOps(opchat, user.sName.." has been disconnected because of advertising: "..data )
user:SendData(Bot, "You have been disconnected because of advertising")
user:Disconnect()
end
end
end
end
return returndata
end
Title: Re: Help please convert script to lua 5
Post by: Herodes on 25 May, 2006, 16:20:07
Quote from: Op on 25 May, 2006, 15:01:12
Please convert to lua 5 thank

-----------------------------------------------------------------
-- A.I. Anti Advertising v1.1 - written by Guibs 21th Apr 2003 --
-----------------------------------------------------------------
---------------------
-- Version History --
---------------------
-- Converted to Lua5 By Jelf 10/03/05
-- v1.1 Changes synthax about 'strfind' (Thks to sedulus for the tips), by Guibs 21th Apr 2003
-- v1.1 added +allowedadd, +refusedadd commands (Thks to Dazzler for the ideas), by Guibs 21th Apr 2003
-- v1.0 first version. Greets to sebastiannielsen for the cool idea
Uhm .. read this again ..

Also next time pls don't be so impatient to post..
Use the proper way for posting code.. you should use the [ code] [ /code] formating