PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: NemeziS on 01 November, 2004, 12:54:43

Title: Turn OFF and ON service
Post by: NemeziS on 01 November, 2004, 12:54:43
Hi, guys!

Who can help me with this?  Here is my connection script:

function NewUserConnected(user)
SendToAll("Someone witn nick "..user.sName.." has just entered the hub!")
end

function OpConnected(user)
SendToAll("Operator "..user.sName.." has just entered the hub!")
end
And here is disconnection script:

oprofiles = {
  ["unreg"] = "Unreg user [user] has left the hub",
  ["Master"] = "Master with nick [user] has left the hub",
  ["Operator"] = "Operator with nick [user] has left the hub",
  ["VIP"] = "VIP with nick [user] has left the hub",
  ["Reg"] = "Reg with nick [user] has left the hub",}

layout = ""

function UserDisconnected(curUser)
  getmessages(curUser, "out")
end

function OpDisconnected(curUser)
  getmessages(curUser, "out")
end

function announce(user, string)
  local arrTmp = substitute(user, string)
  SendToAll(layout..arrTmp)
end

function substitute(user, string)
  local arrTmp = gsub(string, "%[usercount%]", frmHub:GetUsersCount())
  arrTmp = gsub(arrTmp, "%[crlf%]",            "\r\n")

if type(user) == "table" then
    local myinfo = user.sMyInfoString
    local _, _, desc, speed, email, sharesize = strfind(myinfo, "$ALL %S+ (.*)%$ %$(.+)%$(.*)%$(%d+)%$");
    arrTmp = gsub(arrTmp, "%[user%]",        user.sName)
end
  return arrTmp
end

function getmessages(user, io)
  local userprofile = GetProfileName(user.iProfile)
  if user.iProfile == -1 then
    userprofile = "unreg"
  end
  if userprofile == nil then userprofile = "LOL" end

    if oprofiles["$"..user.sName] then
        announce(user, oprofiles["$"..user.sName])

    elseif oprofiles[userprofile] then
      announce(user, oprofiles[userprofile])
    end
 end


So I wanted every user could Turn ON and OFF this functions on my hub for himself.

If somebody writes !turn off  he will never see both connection and disconnection messages again (but other users will see them)

If somebody writes !turn on  he will see this messages again (and the other users will see them too).

So I wanted a script that will write names of the users  (on !turn off) who don't want to see both connection and disconnection messages to a file  (for example users.dat).
And If the name of the user is written in this file, he will never see this messages again.
But If there are no user name in a file (on !turn on) he will see this messages every time somebody connects/disconnects.




Title:
Post by: BoJlk on 01 November, 2004, 13:22:49
There is Such a Script!
And you Can make it thru DC++ settings

And i don't think you want that :)

[*edit]
Funny...
Title:
Post by: NemeziS on 01 November, 2004, 15:02:47
So, who can help me with that? I need it very much. Plizzzzzzzzzzzzzzz help me :(
Title:
Post by: plop on 02 November, 2004, 00:41:02
it's posible but not a good idea.
it would increase the used resources a lot.
instead of 1 send command you need 1 for every user who has it enabled.

plop
Title:
Post by: NemeziS on 02 November, 2004, 01:18:10
But I don't really know how to make that script. Can you help me with it?

[*edit]  

Plizzzz :)
Title:
Post by: plop on 02 November, 2004, 21:30:04
QuoteOriginally posted by NemeziS
But I don't really know how to make that script. Can you help me with it?

[*edit]  

Plizzzz :)
i don't mind helping but it's gone be the long way home.
you're gone make it from scratch.
and pls folow my leads so this topic ends up in a good lesson for other ppl.

1st task is very simple (you need some basic skills before starting pattern matching which is needed for the on/off switch).
drop the 2nd script you posted for now, whe'll get back 2 that later.
use the 1st script as a lead and add the same kind of msg for when a user/op leaves.

plop