Results 1 to 5 of 5

Thread: Randomize multiple procedure

  1. #1
    Join Date
    Sep 2007
    Location
    British Columbia, Canada
    Posts
    4,047
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default Randomize multiple procedure

    I am not sure if something like this exists so here we go.
    Lets say I have x number of procedures and I would like to lunch them all but in random order. Is there a function or a easy way (without case randoming infinite amount of permutation)?
    Oh Hai Dar

  2. #2
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    I know there is a WaitFunc method, where you'd do WaitFunc(@Something, 100);, so I'm sure I'm sure there's a way. You could look at how MSI does something kinda on topic with full scripts being able to be called in DeclarePlayers I think.

  3. #3
    Join Date
    Sep 2007
    Location
    British Columbia, Canada
    Posts
    4,047
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    I am not sure on what you mean
    This is my problem:
    For example lets say I have like 300 types of antiban (not my case) and I would like to use them all in random order.
    All I can think of is maybe put them in branches of case random, but I think a more efficient way would exist.
    Something like:
    Randomize:
    1:P1;
    2:P2;
    3:P3;
    4:P4;
    ...etc

    If something like that doesn't exist, maybe we can create something like that? It does not have to be like that above but it would be nice too bad there isn't array of procedures (or is there?).
    Last edited by Main; 11-10-2010 at 05:17 AM.
    Oh Hai Dar

  4. #4
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    The is an array of procedure or an array of function. But this requires all your procedures/functions to have the same parameters.

    You could do something like this:

    SCAR Code:
    var ProcArray: array of procedure;

    ProcArray := [@P1, @p2, @p3, @p4];

    //to call a random proc

    ProcArray[Random(Length(ProcArray))]();

    That should work. You still need to define each procedure nomrally, then put each handle into the ProcArray.

  5. #5
    Join Date
    Dec 2009
    Location
    Newcastle, Australia
    Posts
    888
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    If you want all procedures to be done, try this...
    Simba Code:
    Procedure ExecuteProcedures;
    var
      IntArr: TIntegerArray;
      Number, Count, I: Integer;
    begin
      SetArrayLength(IntArr, NumberOfProcedures);
    //from here...
      while InIntArray(NumberOfProcedures, 0) do
      begin
        Number := Random(NumberOfProcedures);
        if InIntArray(NumberOfProcedures, Number) then
          IntArr[Count] := Number;
        Inc(Count);
      end;
    //...to here
    //creates an array of unique integers

      for I := 0 to High(IntArr) do
    //Optionally instead of High(IntArr) use the amount of procedures you want to do, minus 1
        Case IntArr[I] of
          0 : Proc1;
          1 : Proc2;
          2 : Proc3;
          3 : Proc4;
          {and so on}
        end;
    end;

    That should also help me do something, thanks for making me get that idea...
    Last edited by Bad Boy JH; 11-11-2010 at 03:20 AM.

    Current Script Project
    Pot of flour gatherer - 95% done

    Can't get Simba to work? Click here for a tutorial

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
  •