Author Topic: Intro/Outro for Specific Users  (Read 2903 times)

0 Members and 1 Guest are viewing this topic.

Offline G?M

  • Junior Member
  • **
  • Posts: 11
  • Karma: +1/-0
Intro/Outro for Specific Users
« on: 15 March, 2004, 05:05:29 »
I'm trying to do Login/Logout messages for specific users.


I've tried this
Code: [Select]

BOT = "Intro"
USER = "G?M?"

function NewUserConnected(curUser)
          if curUser == USER then
          SendToAll(BOT,"Welcome Home G?M?")
          else
          SendToAll(BOT,"Welcome, "..curUser.sName)
          end
end

But i'm not getting it to work, please bear with me this is only my second attempt at a script!
The more I drink, the more I realize I like to Drink.
                                                                          -G?M

PtokaX forum

Intro/Outro for Specific Users
« on: 15 March, 2004, 05:05:29 »

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #1 on: 15 March, 2004, 05:36:45 »
Quote
Originally posted by G?M?
I'm trying to do Login/Logout messages for specific users.


I've tried this
Code: [Select]

BOT = "Intro"
USER = "G?M?"

function NewUserConnected(curUser)
          if curUser == USER then
          SendToAll(BOT,"Welcome Home G?M?")
          else
          SendToAll(BOT,"Welcome, "..curUser.sName)
          end
end

But i'm not getting it to work, please bear with me this is only my second attempt at a script!

go av alook in how-to's 12 lessons or so i did on write a basic bot, i think first few show u how todo accomplish waht u want

'hint

if curUser.iProfile == X then

X = profiles such as

-1 = no reg user

others depend on what profiles.dat u have


but as u want a pacific user to be then hmm yup

Code: [Select]
BOT = "Intro"
USER = "G?M?"

OpConnected = NewUserConnected  --because Gismo status is probably op

function NewUserConnected(curUser)
          if curUser.sName == USER then --dont forget sName because curUser is a table
                  SendToAll(BOT,"Welcome Home G?M?")
          else
                  SendToAll(BOT,"Welcome, "..curUser.sName)
          end
end
Resistance is futile!

Offline G?M

  • Junior Member
  • **
  • Posts: 11
  • Karma: +1/-0
(No subject)
« Reply #2 on: 16 March, 2004, 22:09:25 »
I changed a bit of the script and implimented an associative array for the variables
Thank you for your help and hints (uk-kingdom)pH?tt? !

Code: [Select]
Bot = "Introtest"


function Main()
aarray = { own="G?M?", op1="Operator's nic", op2 ="Another Ops nic",etc="vips, and regs too"}
--frmHub:RegBot(Bot)

end

function OpConnected(user)
  if user.sName == aarray.own then
  SendToAll(Bot,"Welcome msg to hub owner")
  elseif user.sName == aarray.op1  then
  SendToAll(Bot,"Welcome Home OP! :)")
  end
end

I would like to impliment a command for my ops and masters to able to change their intro msg
example !myintro

any hints or suggestions? thanks :)
« Last Edit: 16 March, 2004, 23:20:18 by G?M »
The more I drink, the more I realize I like to Drink.
                                                                          -G?M

Offline ??????Hawk??????

  • Emperor
  • **
  • Posts: 1 044
  • Karma: +12/-2
    • Leeds Laptop Repairs
(No subject)
« Reply #3 on: 17 March, 2004, 00:02:00 »
Heres a starter for you m8




 
Code: [Select]

Bot = "Introtest"
function Main()
aarray = { own="??????Hawk??????", op1="op1", op2 ="op2"}
--frmHub:RegBot(Bot)
end

function DataArrival(user, data)
if user.bOperator ~= nil then
s,e,cmd,Message= strfind(data,"%b<>%s(.+)%s(.+)")
if cmd == "!myintro" then
if Message == "" then
user:SendData("you must enter an onjoin message.  !myintro ")  
return 1
end
if user.sName == aarray.own then
HubOwnerMessage = Message
user:SendData("your Intro message is now set to: "..Message)
return 1
elseif user.sName == aarray.op1 then
userA = Message
user:SendData("your Intro message is now set to: "..Message)
return 1
elseif user.sName == aarray.op2 then
userB = Message
user:SendData("your Intro message is now set to: "..Message)
return 1
end
end
end
end
function OpConnected(user)
if user.sName == aarray.own then
if HubOwnerMessage == nil then
SendToAll(Bot,"Welcome msg to hub owner")
else
SendToAll(Bot,HubOwnerMessage)
end
elseif user.sName == aarray.op1  then
if userA == nil then
SendToAll(Bot,"Welcome Home op1 :)")
else
SendToAll(Bot,userA)
end
elseif user.sName == aarray.op2  then
if userb == nil then
SendToAll(Bot,"Welcome Home op2")
else
SendToAll(Bot,userb)
end
end
end





Try Adding  save to file and read from file functions to keep messages on hub restart/reboot

Offline G?M

  • Junior Member
  • **
  • Posts: 11
  • Karma: +1/-0
(No subject)
« Reply #4 on: 17 March, 2004, 02:23:49 »
Great Thanks M8!
Also is an array the best way to go for optimizing?
The more I drink, the more I realize I like to Drink.
                                                                          -G?M

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #5 on: 17 March, 2004, 16:34:46 »
check here for more info/hints.

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 <----<<

Offline G?M

  • Junior Member
  • **
  • Posts: 11
  • Karma: +1/-0
(No subject)
« Reply #6 on: 17 March, 2004, 22:58:00 »
Thanks a ton plop this cleared up alot of questions I had!
The more I drink, the more I realize I like to Drink.
                                                                          -G?M

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #7 on: 17 March, 2004, 23:35:09 »
Quote
Originally posted by G?M?
Thanks a ton plop this cleared up alot of questions I had!
yw.
pls keep on posting any adjustments/addon's 2 your script, nice 2 see if you learned something from it.

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 <----<<

Offline Corayzon

  • Lord
  • ***
  • Posts: 464
  • Karma: +1/-0
(No subject)
« Reply #8 on: 24 March, 2004, 03:25:00 »
once again thats what cSlave is all about...  8)

this is a complex and long example of a fully operational in\out system (and their is some bugs yes i know...but their nothing major and i will fix them soonies)...that allows random intros\outros...

Code: [Select]
From settings.lua
-- Intro/Outro Messages
randomintro = "yes"
randomoutro = "no"
introprofilelevel = 8
outroprofilelevel = 8
opconnectmsg = "[USERNAME] has just connected"
opdisconnectmsg = "[USERNAME] has just disconected"
connectmsg = "[USERNAME] has just connected"
disconnectmsg = "[USERNAME] has just disconnected"
Code: [Select]
-- cSlave 0.2.2 :: inoutmessages.lua :: writin by Corayzon
-------------------------------------------------------------------------------------

intros = {
"[USERNAME] Comes in crawling On Their Hands And Knees.",
"[USERNAME] Enters With A Corayzie Look In Their Eyes",
"Sir [USERNAME] Of My Lucid Dreams Has Arrived.",
"[USERNAME] Runs In Raving On Like A Maniac.",
"[USERNAME] Has Been Droped Off By Aliens.",
"[USERNAME] Appears Out Of Nowhere And Begins Speaking In Tongues.",
"[USERNAME] Arrives And Immediately Heads For The Light Like A Moth.",
"[USERNAME] Climbs In Through The Window And Trips Over The Desk.",
"[USERNAME] Enters the Room Via The Chimney.",
"After Alot Of Loud Groaning [USERNAME] Comes Waltzing Out Of Janines Room...",
"[USERNAME] Has Arrived On The Scene Looking More Corayzie Than Usual.",
"[USERNAME] Walks In With What Looks To Be A Mighty Fine Spliff.",
"[USERNAME] Arrives With A Keg Under Each Arm",
"[USERNAME] Appears Out Of Thin Air.",
"[USERNAME] Parachutes In From An Airplane.",
"[USERNAME] Runs In, Stubs Their Toe On A Couch And Falls Over A Table Landing On A Dog Which Then Bites His Attacker.",}

outros = {
"[USERNAME] Has Left The Hub",
"[USERNAME] Has Gone On A Search For Aliens",
"[USERNAME] Has Been Found And Abducted By Aliens",
"[USERNAME] Begins Shrinking, And Eventually Disappears From The Hub.",
"[USERNAME] Leaps Out The Window With Cat Like Reflexes.",
"The Lights Momentarily Dim, And When They Come Back On [USERNAME] Is Gone.",
"Three Giant Men In White Coats March In And Haul Away [USERNAME] Kicking and Screaming.",
"[USERNAME] Leaves Through The Basement Door",
"Suddenly [USERNAME] Leaps Up And Bolts For The Door.",
"[USERNAME] Runs Around The Room Screaming And Then Leaps Out The Window.",}

function doInOutCommand(user, cmd)

pName = GetProfileName(user.iProfile)
if pName == nil then pName = "none" end

if cmd == "opconnect" then
if randomintro then
if protag[pName] ~= nil then
if introprofilelevel > profiles[pName] then
local sTag = protag[pName]
if strlower(user.sName) == "corayzon" then sTag = "ThE ArcHiTecT" end
intro, x = gsub(intros[random(1,getn(intros))], "%b[]", user.sName)
SendToAll(sTag, intro)
return 1
end
end
else
if protag[pName] ~= nil then
if introprofilelevel > profiles[pName] then
local sTag = protag[pName]
if strlower(user.sName) == "corayzon" then sTag = "ThE ArcHiTecT" end
intro, x = gsub(opconnectmsg, "%b[]", user.sName)
SendToAll(sTag, intro)
return 1
end
end
end

elseif cmd == "opdisconnect" then
if randomoutro then
if protag[pName] ~= nil then
if outroprofilelevel > profiles[pName] then
local sTag = protag[pName]
if strlower(user.sName) == "corayzon" then sTag = "ThE ArcHiTecT" end
outro, x = gsub(outros[random(1,getn(outros))], "%b[]", user.sName)
SendToAll(sTag, outro)
return 1
end
end
else
if protag[pName] ~= nil then
if introprofilelevel > profiles[pName] then
local sTag = protag[pName]
if strlower(user.sName) == "corayzon" then sTag = "ThE ArcHiTecT" end
outro, x = gsub(opdisconnectmsg, "%b[]", user.sName)
SendToAll(sTag, outro)
return 1
end
end
end

elseif cmd == "connect" then
if randomintro then
if pName ~= nil then
if introprofilelevel > profiles[pName] then
local sTag = protag[pName]
if strlower(user.sName) == "corayzon" then sTag = "ThE ArcHiTecT" end
intro, x = gsub(intros[random(1,getn(intros))], "%b[]", user.sName)
SendToAll(sTag, intro)
return 1
end
else
if introprofilelevel > profiles["none"] then
local sTag = protag["none"]
if strlower(user.sName) == "corayzon" then sTag = "ThE ArcHiTecT" end
intro, x = gsub(intros[random(1,getn(intros))], "%b[]", user.sName)
SendToAll(sTag, intro)
return 1
end
end
else
if pName ~= nil then
if introprofilelevel > profiles[pName] then
local sTag = protag[pName]
if strlower(user.sName) == "corayzon" then sTag = "ThE ArcHiTecT" end
intro, x = gsub(connectmsg, "%b[]", user.sName)
SendToAll(sTag, intro)
return 1
end
else
if introprofilelevel > profiles["none"] then
local sTag = protag["none"]
if strlower(user.sName) == "corayzon" then sTag = "ThE ArcHiTecT" end
intro, x = gsub(connectmsg, "%b[]", user.sName)
SendToAll(sTag, intro)
return 1
end
end
end

elseif cmd == "disconnect" then
if randomoutro then
if pName ~= nil then
if outroprofilelevel > profiles[pName] then
local sTag = protag[pName]
if strlower(user.sName) == "corayzon" then sTag = "ThE ArcHiTecT" end
outro, x = gsub(outros[random(1,getn(outros))], "%b[]", user.sName)
SendToAll(sTag, outro)
return 1
end
else
if outroprofilelevel > profiles["none"] then
local sTag = protag["none"]
if strlower(user.sName) == "corayzon" then sTag = "ThE ArcHiTecT" end
outro, x = gsub(outros[random(1,getn(outros))], "%b[]", user.sName)
SendToAll(sTag, outro)
return 1
end
end
else
if pName ~= nil then
if outroprofilelevel > profiles[pName] then
local sTag = protag[pName]
if strlower(user.sName) == "corayzon" then sTag = "ThE ArcHiTecT" end
outro, x = gsub(disconnectmsg, "%b[]", user.sName)
SendToAll(sTag, outro)
return 1
end
else
if outroprofilelevel > profiles["none"] then
local sTag = protag["none"]
if strlower(user.sName) == "corayzon" then sTag = "ThE ArcHiTecT" end
outro, x = gsub(disconnectmsg, "%b[]", user.sName)
SendToAll(sTag, outro)
return 1
end
end
end
end
end

 

hope this is what ur looking for! =]

PtokaX forum

(No subject)
« Reply #8 on: 24 March, 2004, 03:25:00 »