Results 1 to 6 of 6

Thread: Functiopn for each player.

  1. #1
    Join Date
    Nov 2008
    Location
    Norway, Alesund
    Posts
    924
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default Functiopn for each player.

    Example i have 3 players.
    My Own Script fragment
    SCAR Code:
    program ProgramName;
    {.include SRL/SRL.scar}
    {.Include SRL/SRL/Skill/Mining.Scar}
    {.include srl/srl/misc/Reports.scar}

    Procedure DeclarePlayers;
      begin
          HowManyPlayers := 3;
           CurrentPlayer := 0;
           NumberOfPlayers(HowManyPlayers);
           Players[0].Name := '';  //Username
           Players[0].Pass := '';    //Password
           Players[0].Nick := '';     //sern
           Players[0].Active := true; //leave it
     
           Players[1].Name := '';  //Username
           Players[1].Pass := '';    //Password
           Players[1].Nick := '';     //sern
           Players[1].Active := true; //leave it

           Players[2].Name := '';  //Username
           Players[2].Pass := '';    //Password
           Players[2].Nick := '';     //sern
           Players[2].Active := true; //leave it
    end;


    procedure DropAllExcept(W : Array of Integer);
    var i: Integer;
    begin
     For I:=1 To 28 Do
     if not(InIntArray(w, i)) then
     DropItem(i);
    end;
    procedure DropingOre;
    begin
     Disguise('Droping ores');
     DropAllExcept([1]);
    end;

    procedure mineOre;
    var X, Y: Integer;
    begin
     if FindColorSpiral(X, Y, 2437713, MSX1, MSY1, MSX2, MSY2) then
      begin
      Disguise('mining ore');
       mmouse( x, y, 5, 5);
       wait(200+random(360));
       if isuptext('ine') then
        begin
         GetMousePos(X, Y);
         Wait(70+random(150));
         Mouse(X, Y, 5, 5, True);
         Wait(500+random(1350));
        end;
      end;
    end;

    Procedure findShop;
    var x, y: integer;
    Begin
     if FindSymbol(x, y, 'store') then
      begin
      Mouse(X, Y, 5, 5, True);
      WriteLn('FindStoreSymbol. - Complete.');
      FFlag(0);
      end else
     if not FindSymbol(x, y, 'store') then
      begin
        if FindSymbol(x, y, 'water') then
        begin
           Mouse(X, Y, 5, 5, True);
           FFlag(0);
            if FindSymbol(x, y, 'store') then
             begin
              Mouse(X, Y, 5, 5, True);
              WriteLn('FindStoreSymbol. - Complete.');
              FFlag(0);
              end;
        end else
        if not FindSymbol(x, y, 'water') then
        begin
         if FindSymbol(x, y, 'portal') then
         begin
           Mouse(X, Y, 5, 5, True);
           FFlag(0);
            if FindSymbol(x, y, 'store') then
             begin
              Mouse(X, Y, 5, 5, True);
              WriteLn('FindStoreSymbol. - Complete.');
              FFlag(0);
             end;
        end else
        if not FindSymbol(x, y, 'portal') then
        begin
         WriteLn('You are lost.');
         NextPlayer(False);
         Exit;
        end;
      end;
     end;
    end;

    Procedure actionByThePlayerInt;//this procedure should choose action for current player.
    Begin

    end;

    Procedure MainLoop;
    Begin
        actionByThePlayerInt;
    end;
    //-----


    begin
        SetupSRL;
        DeclarePlayers;
        LoginPlayer;
        ClearDebug;
        MainLoop;

    end.
    So i wanna ask how i can do different procedure for each player.
    Procedure called actionByThePlayerInt;

    example: {also if sentence would be best. i like them.}


    Players[0]
    Do
    SCAR Code:
    DropingOre;
    Players[1]
    Do
    SCAR Code:
    mineOre;
    Players[2]

    Do
    SCAR Code:
    findShop;
    Administrator's Warning:
    my code tags not coloring text and no align standarts why?

  2. #2
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    In this case you will need to use a Pointer.

    Example:

    SCAR Code:
    Player = Record
      Action : Procedure();
    End;

    Var Players : Array [0..3] Of Player

    Then do:

    SCAR Code:
    Players[0].Action := @DropingOre;
    Players[1].Action := @MineOre;

    e.t.c

    Check my signature for the Type tutorial, this is when pointers come into play more often.
    See this better tutorial: http://www.villavu.com/forum/showthread.php?t=43158
    Last edited by Naum; 08-22-2009 at 06:28 PM.

  3. #3
    Join Date
    Nov 2008
    Location
    Norway, Alesund
    Posts
    924
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    In this case you will need to use a Pointer.
    can you wrote this function? i am not very advanced at this part.

  4. #4
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Try [scar] tags.
    And I don't really understand what you want.
    Maybe a case?
    SCAR Code:
    case CurrentPlayer of
      0: DropingOre;
      1: mineOre;
      2: findShop;
    end;

    Or I am misunderstand you badly.

  5. #5
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Laimonas171 View Post
    can you wrote this function? i am not very advanced at this part.
    Just did, sorry. I just wanted to secure the first post

  6. #6
    Join Date
    Nov 2008
    Location
    Norway, Alesund
    Posts
    924
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    Just did, sorry. I just wanted to secure the first post
    Tyvm. : )

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
  •