[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Aardwolf AFK detection plugin

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Aardwolf AFK detection plugin
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 22 Jul 2008 09:11 PM (UTC)  quote  ]

Amended on Tue 22 Jul 2008 09:13 PM (UTC) by Nick Gammon

Message
Recent versions of MUSHclient have the "check" function built in.

I suggest you download version 4.33, see this page:

http://mushclient.com/forum/?id=8765

If this post is older than a week or so, check for an even later version by going to:

http://mushclient.com/forum/?bbtopic_id=1

Most of the Aardwolf plugins require the new functionality in the latest version.

This particular one can probably be corrected by adding one line:


<script>
<![CDATA[

require "check"  --> add this line



However upgrading MUSHclient is the safer option, if you are planning to use the other plugins.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Solaris   (1 post)  [Biography] bio
Date Tue 22 Jul 2008 09:19 AM (UTC)  quote  ]
Message
I have a problem when i add this script:

Run-time error
Plugin: xAFK_Detector (called from world: aardwolf)
Function/Sub: OnPluginCommand called by Plugin xAFK_Detector
Reason: Executing plugin xAFK_Detector sub OnPluginCommand
[string "Plugin"]:34: attempt to call global 'check' (a nil value)
stack traceback:
[string "Plugin"]:34: in function 'FixTimer'
[string "Plugin"]:14: in function <[string "Plugin"]:13>
Error context in script:
30 : BroadcastPlugin (1, "n")
31 : end
32 :
33 : -- turn timer back on
34*: check (EnableTimer ("afk_timer", 1))
35 :
36 : -- make sure the full time interval elapses
37 : check (ResetTimer ("afk_timer"))
38 :
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Sat 12 Jul 2008 11:34 PM (UTC)  quote  ]
Message
The plugin below detects if you are AFK on the client side. That is, if you have wandered away from the keyboard.

The reason for this is that some of the other plugins I have developed - in particular the spellups one - keep casting spells quite frequently, which can make it look to the MUD that you are there in person, and thus the MUD never times you out. However this is confusing for your friends who wonder why you are not responding, as you appear to be standing there, casting spells, not AFK, but not replying to them.

What it does is detect when you last typed a command, and reset an internal timer. If the timer is not reset, it puts you into "client-side AFK" mode. Other plugins can detect that, and stop issuing commands (like spellups) until you return to the keyboard.


To use it, download the code below and save as AFK_Detector.xml in the Aardwolf subdirectory below your Plugins directory. If you haven't used any Aardwolf plugins before you may need to make the Aardwolf directory.

Alternatively, RH click the link below and choose "Save Link As" (or "Save Linked File As") to save the linked file.

http://www.gammon.com.au/mushclient/plugins/Aardwolf/AFK_Detector.xml

In a standard MUSHclient installation these two files should to into this directory:


C:\Program Files\MUSHclient\worlds\plugins\Aardwolf\




<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient [
  <!ENTITY timer_mins "5" > 
  <!ENTITY timer_secs "0" > 
]>
<!-- Saved on Saturday, June 30, 2007, 10:48  -->
<!-- MuClient version 4.13 -->

<muclient>
<plugin
   name="xAFK_Detector"
   author="Nick Gammon"
   id="0e191dc7829ff2ac2433c2d8"
   language="Lua"
   purpose="Detects if you are AFK"
   date_written="2008-06-24"
   requires="4.28"
   version="1.0"
   >
<description trim="y">

[FOR PLUGIN AUTHORS ONLY]

Detects if you are AFK, for the benefit of other plugins.

Example:

function OnPluginBroadcast (msg, id, name, text)
  if msg == 1 and id == "0e191dc7829ff2ac2433c2d8" then
    AFK = text == "y"
   end -- AFK status changed
end

</description>

</plugin>


<triggers>

  <trigger
   enabled="y"
   match="You are now in AFK mode."
   script="gone_afk"
   sequence="100"
  >
  </trigger>
  
 <trigger
   enabled="y"
   match="You cannot use that command while AFK."
   script="gone_afk"
   sequence="100"
  >
  </trigger>
  
  <trigger
   enabled="y"
   match="^AFK mode removed\."
   script="not_afk"
   regexp="y"
   sequence="100"
  >
  </trigger>
  
</triggers>

<timers>
  <timer name="afk_timer" 
         second="&timer_secs;"  
         minute="&timer_mins;"  
         send_to="12"    
         enabled="y"
>
  <send>
    ColourNote ("salmon", "", "You are now AFK (client-side).")
    SetStatus ("AFK")
    check (EnableTimer ("afk_timer", 0))
    BroadcastPlugin (1, "y")
  </send>
  </timer>
</timers>

<!--  Script  -->


<script>
<![CDATA[

function gone_afk (name, line, wildcards)
  SetStatus ("AFK")
  check (EnableTimer ("afk_timer", 0))
  BroadcastPlugin (1, "y")
end -- gone_afk

function not_afk (name, line, wildcards)
  FixTimer ()
end -- not_afk

-- when they type something, reset AFK status

function OnPluginCommand (sText)
  FixTimer ()
  return true  -- process the command
end

-- when you connect to the MUD, presumably you are not AFK

function OnPluginConnect ()
  FixTimer ()
end

-- shared routine to handle turning AFK off

function FixTimer ()
  if GetTimerOption ("afk_timer", "enabled") == 0 then
    ColourNote ("salmon", "", "You are no longer AFK  (client-side).")
    SetStatus ("Ready")
    BroadcastPlugin (1, "n")
  end

-- turn timer back on
  check (EnableTimer ("afk_timer", 1))

-- make sure the full time interval elapses
  check (ResetTimer ("afk_timer"))

end

assert (GetOption ("enable_timers") == 1, "Timers not enabled")

]]>
</script>
</muclient>



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


1,811 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]