Intro/Outro for Specific Users
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Intro/Outro for Specific Users

Started by G?M, 15 March, 2004, 05:05:29

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

G?M

I'm trying to do Login/Logout messages for specific users.


I've tried this
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

pHaTTy

QuoteOriginally posted by G?M?
I'm trying to do Login/Logout messages for specific users.


I've tried this
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

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!

G?M

#2
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? !

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 :)
The more I drink, the more I realize I like to Drink.
                                                                          -G?M

??????Hawk??????

Heres a starter for you m8




 
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

G?M

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

plop

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

G?M

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

plop

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

Corayzon

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

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"
-- 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! =]

SMF spam blocked by CleanTalk