Results 1 to 5 of 5

Thread: World Switching Epic Failure. help me and ill give you a cookie ;]

  1. #1
    Join Date
    Dec 2006
    Location
    Canada, BC
    Posts
    728
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default World Switching Epic Failure. help me and ill give you a cookie ;]

    Hey ok im trying to learn how to switch worlds, and so far this isnt working at all. I did a surch on my computer for a worldswitching include and found this:
    (i downloaded this a while back, not sure from where but i just found it kicking around in some documents folder)
    SCAR Code:
    //-----------------------------------------------------------------//
    //--               Scar Standard Resource Library                --//
    //--               » WorldSwitch routines                        --//
    //-----------------------------------------------------------------//
    //
    // * Function WorldScreen: Boolean;                                        // by Narcle
    // * Function OpenWorldScreen: Boolean;                                    // by ZephyrsFury & Narcle
    // * Procedure LoadWorldArrays;                                            // by Narcle
    // * Function FindWorld(W: integer): Boolean;                              // by Narcle
    // * Function GetWorldInfo(World: Integer; var WorldRec: TWorld): Boolean; // by Narcle
    // * Function SelectWorld(WorldNumber: Integer): Boolean;                  // by Narcle & ZephyrsFury
    // * function RandomWorld(Members, PvP: Boolean): Integer;                 // by Narcle & mixster

    type
      TWorld = record
        Number, PlayerNo: Integer;
        Members: Boolean;
        Prefix, Location, Activity: String;
        LootShare, QuickChat, PVP: Boolean;
      end;
      TWorldArray = Array of TWorld;
     
    Var
      WorldArray: TWorldArray;
      WorldsOrdered: Boolean;
     
    {*******************************************************************************
    function WorldScreen: Boolean;
    by: Narcle
    Description: Returns true if the World screen is open.
    *******************************************************************************}

    function WorldScreen: Boolean;
    var
      x, y: integer;
    begin
      Result := FindTextTpaEx(16777215, 0, 57, 130, 162, 458, x, y, 'orld ', SmallChars, Nothing);
    end;

    {*******************************************************************************
    Function OpenWorldScreen: Boolean;
    by: ZephyrsFury & Narcle
    Description: Opens the world screen. Returns true if world screen is opened.
    *******************************************************************************}

    function OpenWorldScreen: Boolean;
    var
      T: Integer;
    begin
      if (WorldScreen) then
      begin
        Result := True;
        Exit;
      end;
      if (CountColor(7750, 343, 253, 419, 264) = 138) then
      begin
        MouseBox(361, 243, 403, 249, 1);
        T := GetSystemTime + 60000;
        Repeat
          wait(100);
          if GetSystemTime > T then
           Exit;
          Result := WorldScreen;
        until Result;
      end;
    end;

    {*******************************************************************************
    procedure LoadWorldArrays;
    by: Narcle
    Description: Loads the world array into WorldArray from Worlds.ini
    *******************************************************************************}

    procedure LoadWorldArrays;
    var
      i, H, Hw: integer;
    begin
      H := StrToInt(ReadINI('Worlds', 'High', AppPath + 'includes\SRL\SCSS\worlds.ini'));
      for i := 1 to H do
      begin
        if not (ReadINI('World' + IntToStr(i), 'Prefix', AppPath + 'includes\SRL\SCSS\worlds.ini') = '') then
        begin
          SetArrayLength(WorldArray, Length(WorldArray)+1);
          Hw := High(WorldArray);
          WorldArray[Hw].Number := i;
          WorldArray[Hw].Prefix := ReadINI('World' + IntToStr(i), 'Prefix', AppPath + 'includes\SRL\SCSS\worlds.ini');
          WorldArray[Hw].Members := ReadINI('World' + IntToStr(i), 'Type', AppPath + 'includes\SRL\SCSS\worlds.ini') = 'Members';
          WorldArray[Hw].LootShare := ReadINI('World' + IntToStr(i), 'Lootshare', AppPath + 'includes\SRL\SCSS\worlds.ini') = 'True';
          WorldArray[Hw].QuickChat := ReadINI('World' + IntToStr(i), 'Quickchat', AppPath + 'includes\SRL\SCSS\worlds.ini') = 'True';
          WorldArray[Hw].PVP := ReadINI('World' + IntToStr(i), 'PvP', AppPath + 'includes\SRL\SCSS\worlds.ini') = 'True';
        end;
      end;
    end;

    {*******************************************************************************
    function FindWorld(W: integer): Boolean;
    by: Narcle
    Description: Scrolls to area and returns true if world was found
    *******************************************************************************}

    function FindWorld(W: integer): Boolean;
    Var
      WPos, SPos, i, x, y, H: integer;
    begin
      if not WorldScreen then
       Exit;
      Result := FindTextTpaEx(16777215, 0, 57, 130, 162, 458, x, y, 'orld '+inttostr(W)+' ', SmallChars, Nothing);
      if Result then
       Exit;
      if Length(WorldArray) < 1 then
       LoadWorldArrays;
      H := High(WorldArray);
      for i := 0 to H do
       if (WorldArray[i].Number = W) then
       begin
         WPos := i+1;
         Break;
       end;
      SPos := Round(WPos / (H+1)*100);
      if not WorldsOrdered then
      begin
        Mouse(121, 119, 6, 6, true);//makes them drop down
        WorldsOrdered := true;
        wait(500+random(500));
      end;
      if (W < 11) then SPos := 0;
      if (W > H-9) then SPos := 101;//101 compensate for randomness
      Mouse(698, Round(SPos/100.0*262.0+162), 3, 3, true);
      Result := FindTextTpaEx(16777215, 0, 57, 130, 162, 458, x, y, 'orld '+inttostr(W)+' ', SmallChars, Nothing);
    end;

    {*******************************************************************************
    function GetWorldInfo(World: Integer; var WorldRec: TWorld): Boolean;
    by: Narcle
    Description: Records World info into TWorld record, also Results true if world
    was found
    *******************************************************************************}

    function GetWorldInfo(World: Integer; var WorldRec: TWorld): Boolean;
    var
      xx, yy, x, y: integer;
    begin
      if (WorldScreen) then
      begin
        FindTextTpaEx(16777215, 0, 57, 130, 162, 458, x, y, 'orld '+inttostr(World)+' ', SmallChars, Nothing);
        WorldRec.Number := World;
        WorldRec.PlayerNo := StrToIntDef(Trim(GetTextAtEx(170, y-8, 0, SmallChars, False, False, 0, 2, clWhite, 6, False, tr_Digits)), -1);
        WorldRec.Location := Trim(GetTextAtEx(236, y - 7, 0, SmallChars, False, False, 0, 2, clWhite, 16, False, tr_AllChars));
        WorldRec.Activity := Trim(GetTextAtEx(344, y - 7, 0, SmallChars, False, False, 0, 2, clWhite, 24, False, tr_AllChars));
        WorldRec.LootShare := FindColor(xx, yy, 2913076, 510, y-8, 530, y+8);
        WorldRec.QuickChat := FindColor(xx, yy, 2913076, 557, y-8, 577, y+8);
        WorldRec.PVP := FindColor(xx, yy, 2913076, 582, y-8, 602, y+8);
        WorldRec.Members := (Trim(GetTextAtEx(631, y - 7, 0, SmallChars, False, False, 0, 2, clWhite, 8, False, tr_AllChars)) = 'Members');
        Result := (WorldRec.PlayerNo > 0);
      end;
    end;

    {*******************************************************************************
    Function SelectWorld(W: Integer): Boolean;
    by: Narcle & ZephyrsFury
    Description: Switches to the specified world. Returns true if successful.
    *******************************************************************************}

    function SelectWorld(W: integer): boolean;
    var
      x, y, xx, yy, T: integer;
      WRec: TWorld;
    begin
      if OpenWorldScreen then
      begin
        wait(400+random(200));
        if FindWorld(W) then
        begin
          wait(100+random(100));
          if GetWorldInfo(W, WRec) then
          begin
            Writeln('World: '+inttostr(WRec.Number)+', Players: '+inttostr(WRec.PlayerNo)+', Members: '+Booltostr(WRec.Members)+', PvP: '+Booltostr(WRec.PVP));
            If FindTextTpaEx(16777215, 0, 57, 130, 162, 458, x, y, 'orld '+inttostr(W)+' ', SmallChars, nothing) then
            begin
              MMouse(x, y, 500, 4);
              GetMousePos(x, y);
              if FindColor(xx, yy, 4351095, x-20, y-2, x+20, y+2) then
              begin
                Mouse(x, y, 0, 0, true);//Final click
                T := GetSystemTime;
                while (WorldScreen) and (GetSystemTime - T < 10000) do
                  Wait(100);
                Result := (not(WorldScreen));
              end;
            end;
          end else
            WriteLn('World ' + IntToStr(W) + ' is either OFFLINE or FULL.');
        end else
          WriteLn('Failed to find World ' + IntToStr(W) + '!');
        if (not(Result)) then TypeByte(vk_Escape);
      end;
    end;

    {*******************************************************************************
    function RandomWorld(Members, PvP: Boolean): Integer;
    by: Narcle & mixster
    Description: Returns a random world by paramaters.
    *******************************************************************************}

    function RandomWorld(Members, PvP: Boolean): Integer;
    var
      i, H: integer;
      wArray: TWorldArray;
    begin
      if Length(WorldArray) < 1 then
       LoadWorldArrays;
      H := High(WorldArray);
      for i := 0 to H do
        if (WorldArray[i].Members = Members) and (WorldArray[i].PvP = PvP) then
        begin
          SetArrayLength(wArray, Length(wArray)+1);
          wArray[High(wArray)] := WorldArray[i];
        end;
      Result := wArray[random(High(wArray)+1)].Number;
    end;

    so i took all the functions and just copy/pasted then into another one of my scripts and wrote:

    SCAR Code:
    if(OpenWorldScreen) then SelectWorld(130);

    and ran it, it compiled and the OpenWorldScreen function worked, but when it came to Select world i got the error:
    [Runtime Error] : Exception: '' is not a valid integer value in line 99 in script

    wich turns out to be this line in the LoadWorldArrays function:
    SCAR Code:
    H := StrToInt(ReadINI('Worlds', 'High', AppPath + 'includes\SRL\SCSS\worlds.ini'));

    so yeah... i am still a noob with srl and all, and i was told worldswitching is stuipd and not worth learning but i realy think its something i should know if im gonna make realy good scripts. And if there are any better/easyer ways to switch worlds please list and explain them.

    p.s. i was told that if i want to use this script to apply for srl membership i shouldnt have world switching in it and some people might vote no, because some view it as unessisary? idk that sounds strange to me but just checking, would you guys be able to clearify it for me?
    Lance. Da. Pants.

  2. #2
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    -.-

    try NOT copying it all.. SRL has to be ran collectively..

    >.>

    SCAR Code:
    program New;
    {.include srl/srl.scar}
    {.include srl/srl/misc/worldswitcher.scar}

    begin
      SetupSRL;
      ActivateClient;
      MouseBox(349, 243, 413, 252, 1);
      Wait(RandomRange(500, 1000));
      if(OpenWorldScreen) then SelectWorld(61);
    end.

  3. #3
    Join Date
    Dec 2006
    Location
    Canada, BC
    Posts
    728
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    strange.. and sorry, i didnt know this file was also in the SCAR includes.
    much thanks buddy man guy =D

    Edit: erm... in any case im still getting the same error, even though i am pulling those functions out of the include file now.
    Last edited by Lance; 04-12-2009 at 10:39 PM.
    Lance. Da. Pants.

  4. #4
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    This is a common problem, its the ini setup and its being permanently fixed in next revision. (the ini that I wanted uploaded to the revisions was missed 3 - 5 times...)
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

  5. #5
    Join Date
    Dec 2006
    Location
    Canada, BC
    Posts
    728
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ok... so untill next revision worldswitching is unavailable. thanks narcle [=
    Lance. Da. Pants.

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
  •