PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: juda on 23 August, 2004, 08:46:20

Title: Change in & out messages !!!
Post by: juda on 23 August, 2004, 08:46:20
HAY & thanks for help.....

I look and I try a lot of INTRO-OUTRO scripts...
I didn`t notice for script for normal user...EXEMPLE:_
OLD WELCOME MESSAGE:
- When user enter the hub now,say: Welcome user xxxxx
- When user leave hub,say: Nothing

Now I like something like this:
[INTRO]
Welcome "jonny" my old friend...
Welcome "stella" to my romantic place

[OUTRO]
Goodbye "jonny" see you soon...
Goodbye "stella" & be back soon...

I like to set for myself all in & out messages.....
xxxxx [nickname] - I can put the name of the user
I have a loot friends on the hub 20-30 and I like to set them in & out message [every day or two something else]


   Please for your help !!!!
Title:
Post by: nErBoS on 23 August, 2004, 14:08:13
Hi,

Here you go....

--## Intro Bot
--## Requested by juda
--## Made by nErBoS

sBot = "Intro"

arrIntro = {

--## Example Table for a User
["nErBoS"] = {
["IN"] = {
"Hi nErBoS....",
"nErBoS has arrived....",
},
["OUT"] = {
"See you nErBoS",
"BYe BYE nErBoS",
},
},

}

function Main()
frmHub:RegBot(sBot)
end

function NewUserConnected(user)
if (arrIntro[user.sName] ~= nil) then
SendToAll(sBot, arrIntro[user.sName]["IN"][random(1, getn(arrIntro[user.sName]["IN"]))])
end
end

function UserDisconnected(user)
if (arrIntro[user.sName] ~= nil) then
SendToAll(sBot, arrIntro[user.sName]["OUT"][random(1, getn(arrIntro[user.sName]["OUT"]))])
end
end

OpConnected = NewUserConnected
OpDisconnected = UserDisconnected

Best regards, nErBoS
Title: HAY TO PORTUGAL !!!
Post by: juda on 23 August, 2004, 17:00:28
Thanks for your script and I tested already.....
All work fine no errors....
How can I put more users in...I try some triks & cant work !? Please for help....

Users:
  smart-by
  Wu-Tang-Clan
  [SI][dsl]prfox
  SAMURAI
  XXXXXX
  XXXXXX
  XXXXXX .....and all users different in & out

 BAY & THANKS....
Title:
Post by: Psycho_Chihuahua on 23 August, 2004, 17:42:57
Try this:

-----------------------------------------------------------------------------------------
--                                                                                     --
--                                       usertext                                      --
--                                                                                     --
-----------------------------------------------------------------------------------------
        -- ???????????????????????????????????????????????????????????????????????????
????
--?                 ???????????? Der Name des Bots ????????????                 ?
        -- ???????????????????????????????????????????????????????????????????????????
????
--???????????????????????????????????????
BotName  = frmHub:GetHubBotName() --? <<<<< Here comes the Botname        ?
--???????????????????????????????????????
BotOnOff = "Off" --? <<<<< Here Bot On/Off               ?
--???????????????????????????????????????
savetime = 60 --? <<< Here Save Frequency             ?
--???????????????????????????????????????
bubu = "!" --? <<<<< Here the Prefix         ?
--???????????????????????????????????????
lala = "join" --? <<<<< Here the JoinTextEdit Cmd     ?
--???????????????????????????????????????
poo  = "part" --? <<<<< Here the PartTextEdit Cmd     ?
--???????????????????????????????????????
part = "Your Disconnect Text is : " --? <<<<< Text for control message      ?
--???????????????????????????????????????
join = "Your new Connect Text is : " --? <<<<< Text for control message      ?
--???????????????????????????????????????
        -- ???????????????????????????????????????????????????????????????????????????
????
--?         ???????????? nothing more to set ;) ????????????           ?
        -- ???????????????????????????????????????????????????????????????????????????
????
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
--------------------------------------------CODE-----------------------------------------
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
username={}
usertext1={}
usertext2={}
function NewUserConnected(user)
if (not (usertext1[user.sName]==nil)) then
if (BotOnOff == "On") then
SendToAll(BotName,usertext1[user.sName])
else
SendToAll(usertext1[user.sName])
end
end
end
function OpConnected(user)
NewUserConnected(user)
end
function UserDisconnected(user)
if (not (usertext2[user.sName]==nil)) then
if (BotOnOff == "On") then
SendToAll(BotName,usertext2[user.sName])
else
SendToAll(usertext2[user.sName])
end
end
end
function OpDisconnected(user)
UserDisconnected(user)
end
function DataArrival(user,data)
if( strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
if (cmd=="GoodNightHub") then
SendToAll("HUB","Good Night "..user.sName)
end
if (cmd== bubu..lala) then
s,e,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(.*)")
user:SendData(data)
username[user.sName]=user.sName
usertext1[user.sName]=arg
user:SendData(BotName,join..arg)
return 1
elseif (cmd== bubu..poo) then
s,e,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(.*)")
user:SendData(data)
username[user.sName]=user.sName
usertext2[user.sName]=arg
user:SendData(BotName,part..arg)
return 1
end
end
end
function OnTimer()
if (date("%M") == "00") or (date("%M") == "20") or (date("%M") == "40")then
Call = savefile()
end
end
function savefile()
writeto("usertext")
for a,b in username do
savelist=username[a].."|"..usertext1[a].."|"..usertext2[a].."\r\n"
write(savelist)
end
writeto()
end
function Main()
datencheck()
dataload()
StartTimer()
SetTimer(1*60000)
end
function OnExit()
savefile()
end
function dataload()
readfrom("usertext")
while 1 do
line = read()
if line == nil then break end
s,e,NICK,TEXT1,TEXT2=strfind(line,"(.-)|(.-)|(%S+)")
username[NICK]=NICK
usertext1[NICK]=TEXT1
usertext2[NICK]=TEXT2
end
readfrom()
end
function datencheck()
local handle=openfile("usertext","a")
write(handle,"")
closefile(handle)
end
Title:
Post by: nErBoS on 23 August, 2004, 19:28:05
Hi,

I have given you a example table with my nick, you just need to add this...

--## Example Table for a User
["the_nick"] = {
["IN"] = {
"IN MSG 1",
"IN MSG 2",
},
["OUT"] = {
"OUT MSG 1",
"OUT MSG 2",
},
},

.... to the arrInfo Table.

Best regards, nErBoS
Title: Ciao !!!
Post by: juda on 24 August, 2004, 18:58:01
Thanks...work good !!!
If I had any idea,Ill send post !

By