PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: Jazzman on 21 May, 2006, 16:33:52

Title: weblink
Post by: Jazzman on 21 May, 2006, 16:33:52
Hi,

ik zoek n.l het script Web Link voor Ptokax..Kan het nergens vinden.Wie kan me helpen aan dat script, helemaal compleet voor lua 5.0 or higher.
en ik zoek n.l het script woordmix compleet en zonder fouten..in het nederlands..

groeten Jazzman
Title: Re: weblink
Post by: jay-dee on 21 May, 2006, 16:59:18
this is the one i had from timetrav....

----------------------------------------------------------
-- Webber --
-- Made by TiMeTrAVelleR? 02/17/05 --
-- --
-- Add/Delete WebLinks --
----------------------------------------------------------

sBot = "?[??N]?"

Release = {}
sCommands = {}

ReleaseFile = "links.tbl"
TopRelease = 10
MaxReleases = 500 -- Don't set it to high it will give problems
EnableTopRelease = 0 -- 1=on / 0=off
TopReleaseConnect = "main" -- Set to main/pm
ShowRelease = "main" -- Set to main/pm
UserCommands = 1
zMenu = "WeBLinkS"

Allowed = {
[0] = 1, -- Master
[1] = 1, -- Operator
[2] = 1, -- VIPs
[3] = 1, -- Regs
[4] = 1, -- Moderator
[5] = 1, -- Netfounder
}

CmdPrefix = {
["!"]=1,
["?"]=1,
["+"]=1,
}

Main = function()
--frmHub:RegBot(sBot)
dofile(ReleaseFile)
NewReleases = GetReleases(table.getn(Release), table.getn(Release)-TopRelease)
end

NewUserConnected = function(user)
if Allowed[user.iProfile] == 1 then
if EnableTopRelease == 1 then
local disp = "\r\n\t\t?? ?? ?? ??? ??????? ?? ?? ??? ?? The Last "..TopRelease.." Releases Added ?? ?? ?? ??? ??????? ?? ?? ??? ??\r\n\r\n"..NewReleases
disp = disp.."\r\n\t\t?? ?? ?? ??? ??????? ?? ?? ??? ?? The Last "..TopRelease.." Releases Added ?? ?? ?? ??? ??????? ?? ?? ??? ??"
ShowWhere(user, TopReleaseConnect, disp)
end SendCommands(user)
end
end

OpConnected = NewUserConnected

sCommands["addlink"] = function(user, data)
if Allowed[user.iProfile] == 1 then
local s,e,item,descr = string.find(data, "%b<>%s+%S+%s+(.+)%-(.*)")
if s then
if table.getn(Release) < MaxReleases then
table.insert(Release,{user.sName,item,descr,os.date("%x")})
saveTableToFile(ReleaseFile, Release, "Release")
NewReleases = GetReleases(table.getn(Release), table.getn(Release)-TopRelease)
SendToAll(sBot, user.sName.." Added A WebLink ** ["..table.getn(Release).."]. "..item.." - "..descr.." ** ")
else
user:SendMessage(sBot, "*** Database is full, maxium number of WebLinks? are: "..MaxReleases)
end
else
user:SendMessage(sBot, "*** Usage: !addlink Link - Description")
end
end return 1
end

sCommands["remove"] = function(user, data)
if user.bOperator then
local s,e,nr = string.find(data, "%b<>%s+%S+%s+(%d+)")
if s then
if Release[tonumber(nr)] then
table.remove(Release,nr)
saveTableToFile(ReleaseFile, Release, "Release")
NewReleases = GetReleases(table.getn(Release), table.getn(Release)-TopRelease)
user:SendMessage(sBot, "WebLink nr.["..nr.."] is deleted from database!")
else
user:SendMessage(sBot, "*** Link nr."..nr.." is not in database!")
end
else
user:SendMessage(sBot, "*** Usage: !remove nr")
end
end return 1
end


sCommands["showlinks"] = function(user, data)
if Allowed[user.iProfile] == 1 then
local disp = "\r\n\t\t?? ?? ?? ??? ??????? ?? ?? ??? ?? All WebUrls Posted By Users ?? ?? ?? ??? ??????? ?? ?? ??? ??\r\n\r\n"
disp = disp..GetReleases(table.getn(Release), 1)
ShowWhere(user, ShowRelease, disp.."\r\n\t\t?? ?? ?? ??? ??????? ?? ?? ??? ?? All WebUrls Posted By Users ?? ?? ?? ??? ??????? ?? ?? ??? ??")
end return 1
end

sCommands["cleanlinks"] = function(user, data)
if user.bOperator then
local howmuch = table.getn(Release)
if howmuch >= MaxReleases then
for I = 1,howmuch/2 do table.remove(Release,i) end
saveTableToFile(ReleaseFile, Release, "Release")
user:SendMessage(sBot, "The database is cleaned!")
else
user:SendMessage(sBot, "The database doesn't need to be cleaned!")
end
end return 1
end


GetReleases = function(startpos, endpos)
local text = ""
for i = startpos, endpos, -1 do
if Release[i] then
text = text.."\t ["..i.."]? ?"..Release[i][4].."? ?"..Release[i][2].."? ?Description:? ?"..Release[i][3].."\r\n"
end
end return text
end

ChatArrival = function(user, data)
user.SendMessage = user.SendData return GetCommands(user, data)
end

ToArrival = function(user, data)
local s,e,to = string.find(data, "$To: (%S+%s?%S*)%sFrom:")
if to == sBot then
user.SendMessage = user.SendPM return GetCommands(user, data)
end
end

GetCommands = function(user, data)
data=string.sub(data,1,string.len(data)-1)
local s,e,prefix,cmd=string.find(data, "%b<>%s*(%S)(%S+)")
if prefix and CmdPrefix[prefix] and sCommands[cmd] then
return sCommands[cmd](user, data)
end
end

ShowWhere = function(user, where, msg)
if where == "main" then user:SendData(sBot, msg) elseif where == "pm" then user:SendPM(sBot, msg) end
end

SendCommands = function(user)
if UserCommands == 1 then
if user.bUserCommand then -- Is new function to check if client has UserCommand support.
--user:SendData("$UserCommand 255 7")
user:SendData("$UserCommand 0 3")
user:SendData("$UserCommand 1 3 "..zMenu.."\\*** Add ore Find WebLinks Here ***$<%[mynick]> !showlinks&#124;")
user:SendData("$UserCommand 1 3 "..zMenu.."\\Show WebLinks$<%[mynick]> !showlinks&#124;")
user:SendData("$UserCommand 1 3 "..zMenu.."\\Add A WebLink$<%[mynick]> !addlink %[line:WebLink - Description]&#124;")
user:SendData("$UserCommand 1 3 "..zMenu.."\\Delete WebLink (Ops Only)$<%[mynick]> !remove %[line:Number]&#124;")
user:SendData("$UserCommand 1 3 "..zMenu.."\\Clean DataBase (Ops Only)$<%[mynick]> !cleanlinks&#124;")
end
end
end

----------------------------------------------
-- load & save Tables
----------------------------------------------
Serialize = function(tTable, sTableName, hFile)
hFile:write(sTableName.." = {\n")
for key,value in tTable do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key)
if(type(value) == "table") then
Serialize(value,sKey,hFile)
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
hFile:write(sKey.." = "..sValue)
end hFile:write(",\n")
end hFile:write("}")
end
-----------------------------------------------------------
saveTableToFile = function(file, table, tablename)
local handle = io.open(file,"w")
Serialize(table,tablename,handle)
? ? handle:close()
end