PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Quicksilver on 24 September, 2004, 19:29:55

Title: Newb Needs Script
Post by: Quicksilver on 24 September, 2004, 19:29:55
Hello evryone i hope someone can help me.

I need a script for my DCDM++ client that automatically lets the client jon on connect to a chatroom (Yoshihub-Chatroom).
That for it has to send  +join per Pm.
So problem is normal pm (done with raw command) doesn't work  it needs to be send the normal way to function.  (/pm +join).
My problem is that I can't find a script that sends something like this on connect neither do I know which commands to use for this /pm .. thingy nor seems this on connecting mixed with timers or how ever that is done to me so easy.
Well to set the crown to this is that this should be my first lua script that I ever needed (wanted to write) and I am stuck can't find any Api, besides my last piece of programming lies long ago.
So please can anyone show me how to write this script.
I am shure someone who knows lua can write sth like this in less than 5 Minutes, so plz Help.
Title:
Post by: BottledHate on 25 September, 2004, 04:16:38
i made something for you real quick.. sorry i didn't see your post ealier.....

dcdm(0.35-0.38): get this FILE (http://www.stcycles.com/hate/scripts/startup.dcdm_mod.lua)  , rename it to startup.lua and replace yours. (+timer, +raw, +ownchatout)

BCDC4032: get this FILE (http://www.stcycles.com/hate/scripts/startup.4032.raw.mod.lua)  , rename it to startup.lua and replace yours. (+raw)

and here is the script:

--//send a pm to 'ChatBotName' containing 'CommandToSend' shorty after join('SecondsToWait').
--//dcdm startup.lua mod required!!! dl the one i made and replace the one u have. (0.35 - 0.38)

ChatBotName = "?ottledHat?" --//the name to send the pm to on connect.
CommandToSend = "+join" --//the command to send to the name above on join.
SecondsToWait = 3 --//number of seconds to wait before sending command.(if sent too early, command will not go through, 3 seconds as lowest setting.)

-------------------------
dcpp:setListener( "Raw", "joinchat",
   function(h,m)
      if string.sub(m,1,6) == "$Hello" then
         if not sendTable then sendTable = {} end
         sendTable[h] = os.clock() + SecondsToWait
      end
   end
)
sentTo={}
dcpp:setListener( "timer", "joinchat",
   function()
      if sendTable == nil then return end
      for k,v in sendTable do
         if os.clock() > v then
            if not sentTo[k] then
               DC():SendHubMessage(k:getId(), "$To: "..ChatBotName.." From: "..k:getOwnNick().." $<"..k:getOwnNick().."> "..CommandToSend.."|")
               sentTo[k]=1
               k:injectChat("Sending")
            end
            sendTable[k] = nil
         end
      end
   end
)
dcpp:setListener( "disconnected", "joinchat",
   function(h)
      sentTo[h] = nil
   end
)
DC():PrintDebug("Onjoin PM Loaded.")
-------------------------

-BH
Title:
Post by: Quicksilver on 25 September, 2004, 15:03:54
Thanks a lot, it works great!!!
 :]