DoAfterSpecial, AddTimer and AppendtoNotepad

Posted by Halig on Sun 08 Mar 2015 09:35 PM — 12 posts, 43,141 views.

Portugal #0
Hi to all.
I have a problem with his alias, i know that it is something on the syntax, but can't figure out where.

<aliases>
<alias
match="-reward (.*)"
enabled="y"
group="Newbie"
regexp="y"
send_to="12"
sequence="100"
>
<send>player = "%1"

Send("at " ..player.. " reward " ..player.. " 1500 nice")

DoAfterSpecial (3, AddTimer("Reward", 2, 17, 0, AppendtoNotepad("Notepad", "You can Reward again."\n), timer_flag.Enabled + timer_flag.OneShot, ""), sendto.script)</send>
</alias>
</aliases>

What i want this to do is as follow:
- It sends to the world, the line:
at player reward player 1500 nice.
- When i execute this alias, i can only execute it again after 2 hours and 15 minutes.
- What i was trying to do, is when i can the alias, create a timer that after that time passes it sends to one of the notepads that i have the message "You can Reward again.".

Thank you.
Australia Forum Administrator #1
You need to quote the thing you want done.

For example:


DoAfterSpecial (3 , 'print ("hello")' , sendto.script )


Use single quotes around the thing to be done, so you can use double quotes inside it.
Portugal #2
Hello Nick. Thank you for your answer. I've tryied that, and it send to world this:

'AppendtoNotepad("Notepad", "You can Reward again.")'

Meaning, it doesn't change the send to world to send to script.

<aliases>
<alias
match="-reward (.*)"
enabled="y"
group="Newbie"
regexp="y"
send_to="12"
sequence="100"
>
<send>name = "%1"

Send("at " ..name.. " reward " ..name.. " 1500 nice")

DoAfterSpecial (3, AddTimer("Reward", 2, 17, 0, 'AppendtoNotepad("Notepad", "You can Reward again.")', timer_flag.Enabled + timer_flag.OneShot, ""), sendto.script)
</send>
</alias>
</aliases>


Then i've tryed to change to this:

<aliases>
<alias
match="-reward (.*)"
enabled="y"
group="Newbie"
regexp="y"
send_to="12"
sequence="100"
>
<send>name = "%1"

Send("at " ..name.. " reward " ..name.. " 1500 nice")

DoAfterSpecial (8220, 'AppendtoNotepad("Notepad", "You can Reward again.")', 12)</send>
</alias>
</aliases>


And i got this error:

Error number: 0
Event: Run-time error
Description: [string "Timer: "]:1: attempt to call global 'AppendtoNotepad' (a nil value)

stack traceback:

[string "Timer: "]:1: in main chunk
Called by: Immediate execution


Thank you.
Amended on Mon 09 Mar 2015 07:10 AM by Halig
Australia Forum Administrator #3
Quote:

attempt to call global 'AppendtoNotepad' (a nil value)


Have to get the capitalization right:

http://www.gammon.com.au/scripts/doc.php?function=AppendToNotepad
Amended on Mon 09 Mar 2015 08:39 AM by Nick Gammon
Portugal #4
Hi Nick. Thank you for your answer. I've changed that, and same thing.

AppendToNotepad("Notepad", "You can Reward again.")

It sends this to the world and not to the script.
Australia Forum Administrator #5
Post the whole thing please, not just one line.

http://snippets-r-us.com/
Portugal #6
<aliases>
<alias
match="-reward (.*)"
enabled="y"
group="Newbie"
regexp="y"
send_to="12"
sequence="100"
>
<send>name = "%1"

Send("at " ..name.. " reward " ..name.. " 1500 nice")

DoAfterSpecial (3, AddTimer("Reward", 2, 17, 0, 'AppendToNotepad("Notepad", "You can Reward again.")', timer_flag.Enabled + timer_flag.OneShot, ""), sendto.script)
</send>
</alias>
</aliases>
Australia Forum Administrator #7

DoAfterSpecial (3, AddTimer( ...


You didn't quote it. Why are you doing DoAfterSpecial (which adds a timer) to then add a timer?
Portugal #8
LOL. I know Nick. I thought about that myself earlier the day.
The thing is that i dont know how to add the timer, and sending it to script, because of the command AppendToNotepad.
That is my only problem in here. If i manage to get it recognizing that it is to send to script, eveything will work, i think.
Australia Forum Administrator #9
Let's clarify what you are doing. After 2 hours and 15 minutes from the alias firing you want a note in the notepad (appended) that says: "You can Reward again."

Is that it?
Australia Forum Administrator #10
Something like this would do it:


<aliases>
  <alias
   match="-reward (.*)"
   enabled="y"
   group="Newbie"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>name = "%1"

Send("at " ..name.. " reward " ..name.. " 1500 nice")

DoAfterSpecial (10, 'AppendToNotepad("Notepad", "You can Reward again.\\\\r\\\\n")', sendto.script)
</send>
  </alias>
</aliases>


Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


I set the time limit there to 10 seconds for testing. For 2:15:00 you work out what that is in seconds, eg.


2*60*60 + 15*60 = 8100


Thus you would want:


DoAfterSpecial (8100, 'AppendToNotepad("Notepad", "You can Reward again.\\\\r\\\\n")', sendto.script)


Or to make it clearer:


DoAfterSpecial (2*60*60 + 15*60, 'AppendToNotepad("Notepad", "You can Reward again.\\\\r\\\\n")', sendto.script)
Portugal #11
Thank you Nick for all your help. That works extremely well. Exactly what i wanted. Thank you again for your help on all my doubts.