PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: TRANCEMASTER on 14 November, 2005, 19:48:59

Title: Error in Awayer4
Post by: TRANCEMASTER on 14 November, 2005, 19:48:59
Hi there

I have an error in the awayer v4

"[19:20] Syntax D:\Horror Hub\scripts\Horror Away.lua:187: malformed pattern (missing `]')"


plllleeeeaaase heeelpppp


The code:

--- v 4a --

-- removed myinfo arrival (not needed)

-- Debugged ToArrival

--- --- --- Awayer v 4 --- ---

--lua 5 version

--By jiten and Dessamator

-- enabled it for normal users (not recommended)

--- --- --- --- --- --- ---

---  Awayer v3 --- idea by QuitckThinker

--- by Herodes

--- This bot has been writen offline and based on no other script

--- Although the initial idea for the AwayBot is from tezlo's RetroBot...

--- This diplays a prefix for those operators and above that are away

--- It also places the Away message in the users description ...

--- --- --- This script works only for Operators (as intended) --- --- ---

--- !away   --- is optional

--- !back

--- !awaylist

--- feel free to develop this further ...  

--- --- v 2 --- ---

--- currently has a problem with the following path ..

--- 1) !away

--- 2) user reconnnects

--- 3) !back

--- this produces a lot of shity names in the list ... dunno y ...:(

--- --- v 3 --- ---

--- fixed v2 problem but has abother one ...

--- following path ..

--- 1) !away

--- 2) or !back

--- 3) user disconnects ...

--- 4) user receives nickname reserved message (???)

--- --- all other scenarios I have tested and work fine ...

--- --- --- --- --- --- ---

tAways = {}



awpref = "[AWAY]"

defmsg = "Ich bin nicht da, schreib einfach, ich antworte dann"

allowuser = false --(allows use of awayer for normal regged users,true/false )--> true not recommended might cause myinfo spam



function Main()

   Bot = "]-[orror_Grabstein"

   SetTimer(1000)

   StartTimer()

end



function OnExit()

   for nick, msg in tAways do

      SendToAll("$Quit "..awpref..nick)

      if GetItemByName(nick).bOperator then

         SendToAll("$OpList "..nick)

      end

      if  GetItemByName(nick) then

         SendToAll(GetItemByName(nick).sMyInfoString)

      end

   end

end



function NewUserConnected(user)

   for nick, msg in tAways do

      if GetItemByName(nick).bOperator then

         user:SendData("$OpList "..awpref..nick)

      end

      if not GetItemByName(nick).bOperator  then

         user:SendData(user.sMyInfoString)

      end

   end

end



OpConnected =NewUserConnected



function OnTimer()

   for nick, msg in tAways do

      if GetItemByName(nick) then

         SendToAll("$Quit "..nick)

         SendToAll("$Quit "..nick)

      end

   end

end



function ToArrival(user, data)

   local s,e,whoTo,from = string.find(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s%$")

   local _,__,msg = string.find(data, "%b<>%s+(%S+)")

   if string.find(whoTo, awpref) then

      SendPmToNick((string.sub(whoTo, string.len(awpref)+1, string.len(whoTo))),from, msg)   

   end

   if tAways[whoTo] then

      if tAways[whoTo]["reason"] then

         SendPmToNick(from,awpref..whoTo, tAways[whoTo]["reason"].." ")

      end

   end



   for nick,message in tAways do

      if string.find(from, nick) then

         SendPmToNick(whoTo,awpref..from, msg)

         return 1

      end

   end

end

function MyINFOArrival(user, data)

   if (tAways[user.sName]) then

      SendToAll("$Quit "..user.sName)

      if user.bOperator then

         SendToAll("$OpList "..awpref..user.sName)

      end

      return 1

   end

end

function ChatArrival(user, data)

   data =string.sub(data, 1, string.len(data)-1)

   local s,e,cmd = string.find(data, "%b<>%s+(%S+)")



tCmds = { ["!away"] = function(user,data)

      local s,e,arg = string.find(data, "%b<>%s+"..cmd.."%s(.*)")

      if arg == nil or arg == "" then arg = defmsg end

      if not tAways[user.sName] then

         local s,e,name,desc,tag, con,email,share   = string.find(user.sMyInfoString, "$MyINFO $ALL (%S+)%s+(.*)<([^$]+)$ $([^$]*)$([^$]*)$([^$]+)")

         tAways[user.sName] = {}

         if desc == nil then desc = "" end

         tAways[user.sName]["d"] = desc

         tAways[user.sName]["t"] = "<"..tag

         tAways[user.sName]["c"] = con

         if email == nil then email = "" end

         tAways[user.sName]["e"] = email

         tAways[user.sName]["s"] = share

         tAways[user.sName]["reason"] = arg

         user:SendData("Awayer", "Du bist nun im AWAY Modus ..")

         SendToAll("$MyINFO $ALL "..awpref..user.sName.." AwayMsg: "..arg..tAways[user.sName]["t"].."$ $"..tAways[user.sName]["c"].." $"..tAways[user.sName]["e"].."$"..tAways[user.sName]["s"].."$")

         if user.bOperator then

            SendToAll("$OpList "..awpref..user.sName)

         end

         SendToAll("$Quit "..user.sName)

      else

         user:SendData("Awayer", "Du bist bereits AWAY ... ")

         SendToAll("$Quit "..awpref..user.sName)

      end

   end,

["!back"] = function(user,data)

      if tAways[user.sName] then

         SendToAll("$Quit "..awpref..user.sName)

         SendToAll("Awayer", user.sName.." hats zur?ck gepfiffen in den Main .. wb mein kleiner Hosenscheisser.. :)")

         SendToAll(user.sMyInfoString)

         if user.bOperator then

            SendToAll("$OpList "..user.sName)

         end

         tAways[user.sName] = nil

      else

         user:SendData("Awayer", "lol ... tu nicht so als ob du Abwesend warst... :)")

      end

   end,

["!awaylist"] = function(user,data)

         local list = "These users are set to away\r\n"

         local cnt = 0

         for nick, msg in tAways do

            cnt = cnt + 1

            list = list.."\t"..cnt..". "..nick.."\tAway Msg :"..msg.."\r\n"

         end

         user:SendData(list)

      end, }

   if tCmds[cmd] then

      if  user.bOperator or (user.bRegistered and allowuser) then

         return tCmds[cmd](user,data),1

      else

         user:SendData(Bot,"Thou art not worthy of thee mighty AWAYER!")

      return 1

      end

   end

   if tAways[user.sName] then

      SendToAll("$Quit "..awpref..user.sName)

      user:SendData("Awayer", "Du sprichst im Main? ... OK ... Ich entziehe dir deinen AWAY Status ... haste davon.")

      SendToAll(user.sMyInfoString)

      if user.bOperator then

         SendToAll("$OpList "..user.sName)

      end

         tAways[user.sName] = nil

   end

end   
Title:
Post by: Dessamator on 14 November, 2005, 20:46:56
I copied and tried using ur script, and found no errors with it. But you could paste that "line 187" maybe there something there .
Title:
Post by: TRANCEMASTER on 14 November, 2005, 21:26:21
this error comes when one or more users are in AWAY mod. In the awaymod i can not klick thrue the rightklickmen?. My dc client is hanging or he open a message window from a rightklick command.

I don?t know what i can do dessamator  ;(

sorry for my english


greatz trance
Title:
Post by: Dessamator on 14 November, 2005, 21:40:45
are u sure that script is the awayer?, maybe its another script, i tried using right click menu, and it works too.
Title:
Post by: TRANCEMASTER on 14 November, 2005, 23:19:49
yes dessamator i am realy shure ... anyone goes away ... script brings error. but i don?t think that the script are in conflict with an other script.

have you tested your rightclickmenue with any commands in away modus ? alone or with other people too?

... mh .. difficultly situation
Title:
Post by: Dessamator on 15 November, 2005, 10:44:08
Try running the script by itself and post the line with the error here.