[Server Scripting] Unmuting with sys.setTimer()

Discussion in 'Server and Client Scripting' started by Garma, Jun 3, 2013.

  1. Garma

    Garma Member

    Joined:
    Nov 23, 2011
    Messages:
    80
    Likes Received:
    0
    Is it possible to unmute someone using a timer function? I've tried something like this:
    Code (js):
    1. var timer = sys.setTimer('SESSION.users(src).muted = false', 60000, false);
    src is of course, defined and the current player ID. This line is part of an automute script and the user shall be unmuted after 60s. But the unmute just won't get executed. So any ideas?
     
  2. Crystal Moogle

    Crystal Moogle Ayaya~ Administrator Administrator

    Joined:
    Jul 19, 2010
    Messages:
    3,205
    Likes Received:
    531
    PO Trainer Name:
    Hanako
    Actually src isn't defined at that point, since it gets called in the global scope, not the current scope. However doing sys.setTimer(function(){/*stuff*/}, time, bool) should work.
     
  3. Garma

    Garma Member

    Joined:
    Nov 23, 2011
    Messages:
    80
    Likes Received:
    0
    Oh, I was near the solution. I had tried passing an anonymous function as first argument too, but defined a function parameter which is wrong. It works now, thanks.