PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Cain on 22 August, 2004, 09:45:29

Title: New to scripting
Post by: Cain on 22 August, 2004, 09:45:29
Hi, I run a hub on my LAN, I don't have any prior programming experience except just a little bit of C [only uptil loops]

I could appreciate some help on LUA scripting solely for ptokax, I read somewhere on these forums that plop.nl may be what I was looking for but for some reason the site is'nt opening for me......can anyone direct me to some other place that I can use as a starting point?

By the way I'd like to know if there are scripts to -

Add a release which can be deleted by an OP or the user whi created the release

Offline message to a user so when he comes on he'll recieve the message

And

A !seen command showing the date and time the user was last seen but the one which I got is heavily case sensetive.....

Thanx,

|Cain|
Title:
Post by: Herodes on 22 August, 2004, 12:36:55
case sensitive ? how do you mean ?

The rest of the list of scripts you need is around the forum for sure ...

The best to know about Lua for PtokaX is ppl's scripts ... ;))

Also keep looking in the How To section on this Forum and the Scripting.txt in the PtokaX/docs folder ...
Title:
Post by: Cain on 22 August, 2004, 18:17:26
:D It's been quite some time since I am using ptokax and it never occured to me to look in the docs folder - DUH  :O

By case sensetive I mean when I type !seen cain the info does'nt come but when I type !seen Cain it shows the required info.

I will look out for the how to's on the forum, they sound to be exactly what I am looking for, thanx for the help :)

|Cain|
Title:
Post by: Cain on 23 August, 2004, 11:57:08
LOL! My username actually comes from the main character of Bourne identity ;)

here is the script.......

QuoteBotName = "LeonBot"
SeenTrigger = "!seen"

minLen = 4
maxLen = 20
seenArray={}

function Main()
frmHub:RegBot(BotName)
end

function NewUserConnected(curUser)
local boolDisc = 0
if strlen(curUser.sName) < minLen then
curUser:SendPM(BotName, "Your nick is to short, a minimum of "..minLen.." chars is required!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
elseif strlen(curUser.sName) > maxLen then
curUser:SendPM(BotName, "Your nick is to long, a maximum of "..maxLen.." chars is required!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
elseif ( strfind (curUser.sName, " ", 1, 1) ) then
curUser:SendPM(BotName, "Spaces not allowed in nicknames!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
end
if (boolDisc == 0) then
seenArray[curUser.sName]=date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
end
end

function OpConnected(curUser)
seenArray[curUser.sName]=date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
end

function OpDisconnected(curUser)
seenArray[curUser.sName]=date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
end

function UserDisconnected(curUser)
seenArray[curUser.sName]=date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
end

function DataArrival(curUser, data)
seenArray[curUser.sName]=date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")
if( strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
_,_,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(%S+)" )
if (cmd == SeenTrigger) then
if (arg == curUser.sName) then
SendToAll(BotName, "You should not do #seen's for yourself ;)" )
elseif (seenArray[arg] ~= nil) then
SendToAll(BotName, "User: "..seenArray[arg] )
else
SendToAll(BotName, "I have not seen "..arg.."!" )
end
end
end
end

Thanx,

|Cain|
Title:
Post by: nErBoS on 23 August, 2004, 13:49:22
Hi,

This will deal with case sensative...

BotName = "LeonBot"
SeenTrigger = "!seen"

minLen = 4
maxLen = 20
seenArray={}

function Main()
frmHub:RegBot(BotName)
end

function NewUserConnected(curUser)
local boolDisc = 0
if strlen(curUser.sName) < minLen then
curUser:SendPM(BotName, "Your nick is to short, a minimum of "..minLen.." chars is required!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
elseif strlen(curUser.sName) > maxLen then
curUser:SendPM(BotName, "Your nick is to long, a maximum of "..maxLen.." chars is required!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
elseif ( strfind (curUser.sName, " ", 1, 1) ) then
curUser:SendPM(BotName, "Spaces not allowed in nicknames!")
curUser:SendPM(BotName, "Disconnecting...")
curUser:Disconnect()
boolDisc = 1
end
if (boolDisc == 0) then
seenArray[strlower(curUser.sName)]=date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
end
end

function OpConnected(curUser)
seenArray[strlower(curUser.sName)]=date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
end

function OpDisconnected(curUser)
seenArray[strlower(curUser.sName)]=date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
end

function UserDisconnected(curUser)
seenArray[strlower(curUser.sName)]=date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
end

function DataArrival(curUser, data)
seenArray[strlower(curUser.sName)]=date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")
if( strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
_,_,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(%S+)" )
if (cmd == SeenTrigger) then
if (strlower(arg) == strlower(curUser.sName)) then
SendToAll(BotName, "You should not do #seen's for yourself ;)" )
elseif (seenArray[strlower(arg)] ~= nil) then
SendToAll(BotName, "User: "..seenArray[strlower(arg)] )
else
SendToAll(BotName, "I have not seen "..arg.."!" )
end
end
end
end

If you ever get problem because case sensative use strlower(string) in all. This will put all characters with their smal letter.

Best regards, nErBoS
Title:
Post by: Cain on 24 August, 2004, 11:48:28
Thanx a bunch :)

|Cain|