Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ Timer Triggers (Help needed for version 2)

Timer Triggers (Help needed for version 2)

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Valhart   (14 posts)  Bio
Date Sat 04 Aug 2001 11:34 AM (UTC)
Message
Current script is as follow:


sub OnSpell (strTriggerName, strTriggerLine, aryWildcards)
dim chant
dim spellname
dim minutes

  ' spell chant was from previous trigger
  chant = world.GetVariable ("LastSpellName")

  ' work out spell duration based on chant
  Select Case chant
      Case "Voluntas ferrum!"
           minutes = 15
           spellname = "IW"
      Case "Voluntas movimas!"
	   minutes = 16
	   spellname = "PfH"
      Case "Rubber"
           minutes = 4
           spellname = "MiPR"
      Case "Major kretsz rex xero"
           minutes = 4
           spellname = "MaPR"
      Case "Air"
	   minutes = 4
	   spellname = "MiXR"
      Case "Major lossa aiir"
	   minutes = 4
	   spellname = "MaXR"
      Case "Flesh and Blood"
	   minutes = 4
	   spellname = "MiHR"
      Case "grrrwm grrrwm"
	   minutes = 4
	   spellname = "MaHR"
      Case Else
           minutes = 0
           spellname = "Unknown spell"
  End Select

  call NewSpell (spellname, aryWildcards (1), minutes)
end sub

sub NewSpell (spellname, target, minutes)

dim number

' get a unique number

  number = world.GetUniqueNumber

' Flags: 
'    1 = enabled
'    4 = one shot (once only)
' 1024 = replace any of same name

' add a timer to go off after the appropriate time

  world.AddTimer "SpellTimer_" & number, 0, minutes - 1, 30, "",  _
                 1 + 4 + 1024,  "OnSpellTimer"

' remember when the spell expires, the target and the spell name
   
  world.setvariable "SpellTimer_Time_" & number, _ 
DateAdd ("n", minutes, Now)
  world.setvariable "SpellTimer_Name_" & number, target
  world.setvariable "SpellTimer_Spellname_" & number, spellname

end sub

sub OnSpellTimer (strTimerName)
dim splitname
dim spellname
dim mylist
dim number
dim i
dim character

splitname = split (strTimerName, "_")

number = CInt (splitname (1))  ' find our unique number

mylist = world.GetVariableList

' scan variables list to find timer number

if not IsEmpty (mylist) then
  for i = lbound (mylist) to ubound (mylist)
    splitname = split (mylist (i), "_")
    if ubound (splitname) = 2 then
      if splitname (0) = "spelltimer" and splitname (1) = "name" then
        if CInt (splitname (2)) = number then
          ' work out character name
          character = world.GetVariable (mylist (i))
          spellname = world.GetVariable _ 
              (splitname (0) & "_SpellName_" & splitname (2))
          ' tell them time is up
          world.send "party say " & spellname & " spell on " _
                     & character & ", left 30 seconds (DANGER)"
          ' delete associated variables
          world.deletevariable splitname (0) & "_Name_" & splitname (2)
          world.deletevariable splitname (0) & "_Time_" & splitname (2)
          world.deletevariable splitname (0) & "_SpellName_" & splitname (2)
                end if
      end if  ' found a spelltimer variable
    end if    ' split into 3 pieces
  next        ' end of loop
End If        ' have any variables

end sub

sub OnSpellQuery (thename, theoutput, thewildcards)
dim mylist
dim i
dim splitname
dim spellname
dim endtime
dim timeleft
dim character

mylist = world.GetVariableList


if not IsEmpty (mylist) then
  for i = lbound (mylist) to ubound (mylist)
    splitname = split (mylist (i), "_")
    if ubound (splitname) = 2 then
      if splitname (0) = "spelltimer" and splitname (1) = "name" then
         endtime = CDate (world.GetVariable _
                           (splitname (0) & "_Time_" & splitname (2)))
         spellname = world.GetVariable _ 
             (splitname (0) & "_SpellName_" & splitname (2))
         character = world.GetVariable (mylist (i))
         timeleft = DateDiff("s", Now, endtime)
	 if timeleft > 0 then
           world.send "party say " & spellname & " spell on " _
                      & character & ", left " _
                      & timeleft & " seconds (TIMER)"
         end if  
      end if  ' found a spelltimer variable
    end if    ' split into 3 pieces
  next        ' end of loop
End If        ' have any variables

end sub



Requirements:

I am looking forward to do a OnSpellQuery that lets me use a command of report X, where X is the alias 'spellname' to report. It's really too spamming when i used over four spells on a target and i want to see the time remaining. ^_^

If by doing the method above, how do I go about doing a report where which spell is up, which spell is not. (I am getting the hang of it but I am still greenhorn)

Sorry for the trouble I caused and really hope that I will have a good nifty script to call upon. Many thanks!
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 04 Aug 2001 10:26 PM (UTC)

Amended on Sat 04 Aug 2001 10:27 PM (UTC) by Nick Gammon

Message
You would just change it slightly to test for the spell name which you pass down as a wildcard to the alias. eg. the alias could be:


Match on: Report *


That * will be passed down as wildcard 1, so just change as shown in bold:



sub OnSpellQuery (thename, theoutput, thewildcards)
dim mylist
dim i
dim splitname
dim spellname
dim endtime
dim timeleft
dim character

mylist = world.GetVariableList


if not IsEmpty (mylist) then
  for i = lbound (mylist) to ubound (mylist)
    splitname = split (mylist (i), "_")
    if ubound (splitname) = 2 then
      if splitname (0) = "spelltimer" and splitname (1) = "name" then
         endtime = CDate (world.GetVariable _
                           (splitname (0) & "_Time_" & splitname (2)))
         spellname = world.GetVariable _ 
             (splitname (0) & "_SpellName_" & splitname (2))
         if spellname = thewildcards (1) then
           character = world.GetVariable (mylist (i))
           timeleft = DateDiff("s", Now, endtime)
           if timeleft > 0 then
             world.send "party say " & spellname & " spell on " _
                        & character & ", left " _
                        & timeleft & " seconds (TIMER)"
            end if  
        end if
      end if  ' found a spelltimer variable
    end if    ' split into 3 pieces
  next        ' end of loop
End If        ' have any variables

end sub




As for reporting on whether the spell is still going, when the timer fires the variables are deleted, so it only ever reports on spells that are still active.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Valhart   (14 posts)  Bio
Date Reply #2 on Sun 05 Aug 2001 03:47 AM (UTC)

Amended on Sun 05 Aug 2001 04:30 AM (UTC) by Valhart

Message
funny that when using this new script, i lost the ability to call all spells and duration on all spells, what happen? Can I have a spell timer that report one spell and one on all queries with two different alias and how do I initiate a trigger to respond to another players like

Admonius says, 'Report IW.'

Valhart (party say): IW spell on Admonius, left XX seconds (Timer)

Thanks for the help again. ^_^
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 05 Aug 2001 04:23 AM (UTC)

Amended on Sun 05 Aug 2001 04:49 AM (UTC) by Nick Gammon

Message
Well, you could change the line I added to read something like this:


if spellname = thewildcards (1) or thewildcards (1) = "all" then


Then just say: report all

To tell the other players you could make a trigger like this:


Match on: Admonius says, 'Report *'
Label: PlayerReport
Script: OnSpellQuery


... and change "world.note" to "world.send" and add the word "say" in front of the message.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


16,963 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.