Results 1 to 2 of 2

Thread: threadsafecall

  1. #1
    Join Date
    Oct 2011
    Posts
    422
    Mentioned
    15 Post(s)
    Quoted
    116 Post(s)

    Default threadsafecall

    Hi,


    Simba Code:
    program New;
     {$DEFINE SRL5}
     {$DEFINE SMART}

    {$i srl/srl.simba}

    var
       Timer1: TTimer;
       V: TVariantArray;
       t: integer;

    Procedure DeleteTimer;

    Begin
      Timer1.Enabled := False;
      Timer1.Free;
    End;
    Procedure ScriptTerminate;

    Begin
      SetLength(V, 0);
      ThreadSafeCall('DeleteTimer', V);
     AddOnTerminate('DeleteTimer');
    End;
    procedure CrashSMART;
    begin
    //freeObjs;
      Writeln('You are using CRASHSMART, so we are going to reload your client after the RS update!');
      SmartgetFieldObject(1488,'crash');
       // will crash SMART (and Simba).
      // IF THIS DOES NOT CRASH YOUR SIMBA, YOU ARE NOT USING THE PROPER PLUGIN
      // AN ACCESS VIOLATION HERE IS NOT THE CRASH; MAKE SURE YOU MOVED THE EDITED PLUGIN
      Wait(5000);
      WriteLn('CRASHSMART Failed: Make sure you are using the proper plugin!');
      WriteLn('Read more about this feature at villavu.com/forum/showthread.php?t=67864');
     // SetLength(V, 0);
    //  ThreadSafeCall('ScriptTerminate',V);
      SetLength(V, 0);
      ThreadSafeCall('TerminateScript',V);
     // TerminateScript;
    end;
    Procedure hi(Sender: TObject);
    var sock: integer;
    begin
       CrashSMART;
    end;
    Procedure CreateTimer;

    Begin
      Timer1 := TTimer.Create(nil);
      Timer1.Interval := 1000;
      Timer1.Enabled := True;
      Timer1.OnTimer := @hi;
    End;
    begin
    ClearDebug;
    SetupSRL;
      SetLength(V, 0);
      ThreadSafeCall('CreateTimer', V);
      t := getsystemtime;
      Repeat
        Wait(100);
        writeln('Time elapse: ' + inttostr(getsystemtime - t));
      Until getsystemtime - t > 8000;
    end.

    For example, in that above code, I am trying to create a threaded Idle watchdog timer- so if the script detects if a person isn't doing anything for too long, it will kill the client for e.g.


    I have a rather hard time trying to fathom on when threadsafecall() should be used D:.

  2. #2
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    TTimers are broken afaik, and it is not currently possible to code anything threaded.
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •