PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: plop on 28 February, 2005, 17:46:33

Title: loginlogout
Post by: plop on 28 February, 2005, 17:46:33
function OpConnected(curUser)
    if curUser.iProfile == 0 then
SendToAll(frmHub:GetHubSecAliasName(), "Master "..curUser.sName.." login.")
    elseif curUser.iProfile == 1 then
SendToAll(frmHub:GetHubSecAliasName(), "Op "..curUser.sName.." login.")
    end
end

function OpDisconnected(curUser)
    if curUser.iProfile == 0 then
SendToAll(frmHub:GetHubSecAliasName(), "Master "..curUser.sName.." logout.")
    elseif curUser.iProfile == 1 then
SendToAll(frmHub:GetHubSecAliasName(), "Op "..curUser.sName.." logout.")
    end
end

plop
Title:
Post by: blackwings on 01 March, 2005, 17:58:01
Added VIP = function OpConnected(curUser)
    if curUser.iProfile == 0 then
SendToAll(frmHub:GetHubSecAliasName(), "Master "..curUser.sName.." login.")
    elseif curUser.iProfile == 1 then
SendToAll(frmHub:GetHubSecAliasName(), "Op "..curUser.sName.." login.")
    elseif curUser.iProfile == 2 then
SendToAll(frmHub:GetHubSecAliasName(), "VIP "..curUser.sName.." login.")
    end
end

function OpDisconnected(curUser)
    if curUser.iProfile == 0 then
SendToAll(frmHub:GetHubSecAliasName(), "Master "..curUser.sName.." logout.")
    elseif curUser.iProfile == 1 then
SendToAll(frmHub:GetHubSecAliasName(), "Op "..curUser.sName.." logout.")
    elseif curUser.iProfile == 2 then
SendToAll(frmHub:GetHubSecAliasName(), "VIP "..curUser.sName.." logout.")
    end
end

OpConnected=NewUserConnected
OpDisconnected=UserDisconnected
Title:
Post by: the_pest on 01 March, 2005, 20:10:06
or for exact nicks (http://www.pestypest.info/emoticons/kuru.gif)
-- made on Earth

TableIn = {
["nick"]="Message on login.",
["Rm."]="Attention, battybwoy in the hub.", --example
}

TableOut = {
["nick"]="Message on logout.",
["Rm."]="OK air is clean again.", --example
}

function NewUserConnected(curUser)
if TableIn[curUser.sName] then
Sub = string.gsub(TableIn[curUser.sName],"curUser",curUser.sName)
SendToAll(frmHub:GetHubBotName(), Sub)
end
end

function UserDisconnected(curUser)
if TableOut[curUser.sName] then
Sub = string.gsub(TableOut[curUser.sName],"curUser",curUser.sName)
SendToAll(frmHub:GetHubBotName(), Sub)
end
end

OpConnected=NewUserConnected
OpDisconnected=UserDisconnected
Title:
Post by: DorianG on 04 March, 2005, 22:34:09
or random mode  :D

Bot = "EnterMessage"

message = {
" Hi!! [USER]. ",
" [USER] is entered in the hub.",
}

function Main()
frmHub:RegBot(Bot)
end

function NewUserConnected(user)
mex = string.gsub(message[math.random(1, table.getn(message))], "%b[]", user.sName)
SendToAll(Bot, mex)
end

OpConnected = NewUserConnected
Title:
Post by: [_XStaTiC_] on 04 March, 2005, 23:49:04
DorianG
or random mode :D

for i,v in message do

What does this do ?!?!
Title:
Post by: Herodes on 05 March, 2005, 09:35:58
QuoteOriginally posted by [_XStaTiC_]
for i,v in message do

What does this do ?!?!

It is on of the way to traverse ( go through ) the indexes (i) and values (v) of a table ( message ) in lua...
If you look closer you'll find that there is a table named 'messages' in the script above ...

so I hope the following general example now makes sense :
for index, value in aTable do
-- whatever you wanna do ... example :
if index*2 == value then
SendToAll("Its double alright")
else
SendToAll("Not double this time ...")
end
end
Title:
Post by: DorianG on 05 March, 2005, 10:37:19
Thanks Herodes for your attenction.
Title:
Post by: [_XStaTiC_] on 05 March, 2005, 10:40:28
Thanks

Works fine :)