Author Topic: Script Snippets  (Read 8994 times)

0 Members and 1 Guest are viewing this topic.

Offline Crome969Topic starter

  • Moderator
  • *
  • *****
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +559
  • Referrals: 10
    • View Profile
    • ScriptSDK
Script Snippets
« on: January 20, 2012, 01:31:16 PM »
+1
Code: [Select]
program SimpleConnect;
begin
   while ( true) do
   begin
      if Connected() = false then  
      begin
        Connect();  
        Wait(5000);
      end;
   end;
end.
This is just a Simple Reconnection Method for the used profile. You could use as well the Autoreconnect Setting to autoreconnect the selected Profile.
« Last Edit: January 30, 2012, 10:24:58 AM by Crome969 »

Offline Crome969Topic starter

  • Moderator
  • *
  • *****
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +559
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: Script Snippets
« Reply #1 on: January 30, 2012, 10:35:09 AM »
-1
This is a simple Snipped to expand FindTypeEx. FindTypeEx only can scan 1 Type, 1 Color, 1 Location. With this Snipped you can Scan Multiple Types, in Multiple Colors at Multiple Places.
Code: [Select]
function FindTypeArray(TypeList:Array of Cardinal;ColorList:Array of Cardinal;ContainerList:Array of Cardinal;Distance:Integer;UseSubContainer:Boolean):Integer;
var
  TypeArray:Integer;
  ColorArray:Integer;
  ContainerArray:Integer; 
  TmpResult:Integer;
begin
  for TypeArray:=0 to Length(TypeList) do
  begin
    for ColorArray:=0 to Length(ColorList) do
    begin
    for ContainerArray:=0 to Length(ContainerList) do
      begin
        Finddistance:=Distance;
        if (FindTypeEx(TypeList[TypeArray],ColorList[ColorArray],ContainerList[ContainerArray],UseSubContainer)>0)then
        begin
          Result:=FindItem();
          exit;
        end;
      end;   
    end;
  end;
  Result:=TmpResult;
end;

Example of Using:
Code: [Select]
PetID:=FindTypeArray([22,33,44,55],[0,100,250,9999],[Ground(),BackPack()],1,false);
the Syntax is:
Code: [Select]
FindTypeArray(Array of Types,Array of Color,Array of Container,GroundmaxDistance,ScanSubContainer);for those who wondering:
-GroundmaxDistance must be 0 or greater(max 25), if you dont want to scan grounds you can set it how you like. If grounds are on your list it will use the maxdistance
-ScanSubContainer is a setting for the special ability of FindTypeEx. It can scan all Items in all Sub Containers inside the ID.
Best example would be the Giant Beetle. In my experimental Code i scan for Ressources in beetle, using the ID of beetle.No real need for Exevent Popup like Easyuo;)

Offline Crome969Topic starter

  • Moderator
  • *
  • *****
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +559
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: Script Snippets
« Reply #2 on: February 07, 2012, 08:58:51 AM »
+1
More Advanced Method to scan for Informations:
 
Code: [Select]
type Item = record
ItemID:Cardinal;
ItemType:Cardinal;
ItemLocation:Cardinal;
ItemDistance:Integer;
ItemColor:Cardinal;
ItemName:String;
ItemProperty:String;
end;
function ScanRoutine(TypeList:Array of Cardinal;ColorList:Array of Cardinal;LocationList:Array of Cardinal;Distance:Integer;UseSubLocation:Boolean):Array of Item;
var ItemList:Array of Item;
aType,aColor,aLocation,DataLength:Integer;
begin
  DataLength:=1;
  for aType := 0 to (Length(TypeList) - 1)do
  begin
    for aColor := 0 to (Length(ColorList) - 1)do
    begin
      for aLocation:= 0 to (Length(LocationList) - 1) do
      begin
        while(FindTypeEx(TypeList[aType],ColorList[aColor],LocationList[aLocation],UseSubLocation)>1)do
        begin
          SetLength(ItemList,DataLength)
          ItemList[(DataLength - 1)].ItemID:=FindItem;
          ItemList[(DataLength - 1)].ItemType:=TypeList[aType];
          ItemList[(DataLength - 1)].ItemLocation:=LocationList[aLocation];
          ItemList[(DataLength - 1)].ItemDistance:= FindDistance;
          ItemList[(DataLength - 1)].ItemColor:=ColorList[aColor];
          ItemList[(DataLength - 1)].ItemName:=GetName(Finditem);
          ItemList[(DataLength - 1)].ItemProperty:=GetCliloc(FindItem);
          Ignore(FindItem);
          DataLength:=DataLength + 1;
        end;
      end;
    end;
  end;
  for aType:= 0 to (Length(ItemList) -1) do
  begin
    IgnoreOff(ItemList[aType].ItemID);
  end;
  Result:= ItemList;
end;

Here is an Example how to use it:
Code: [Select]
var MyData:Array of Item;
i:Integer;
begin
MyData:=ScanRoutine([$FFFF],[$FFFF],[backpack],25,true);
for i :=0 to (Length(MyData)-1)do
begin
   AddToJournal(MyData[i].ItemProperty);
end;
end.
I declare an Own Type and you can make an Data Array of it.
Code: [Select]
ItemID:Cardinal;
ItemType:Cardinal;
ItemLocation:Cardinal;
ItemDistance:Integer;
ItemColor:Cardinal;
ItemName:String;
ItemProperty:String;
are the Supported Informations.

How to use:
1)Copy and paste Scriptcode
2)Form an Array of Item in your Main
3)Use your Array of Item Variable and call my Method arguments are:
Code: [Select]
(TypeList:Array of Cardinal;ColorList:Array of Cardinal;LocationList:Array of Cardinal;Distance:Integer;UseSubLocation:Boolean)So you can add multiple Types,Colors,location,Give a Scan Distance for Ground location and enable Subcontainer Scanning.
4)Result will be the List of Foundet Items, with Name,ID,Type,Location,Color,Property as Simple String

My Personal Next Step will be a method to insert Your Array of Item into a new Method and getting a list of
ID,Propertys with amount. My Last Step will be a Method insert Itemlist with propertys and getting ID and Score for each Item:)
« Last Edit: February 07, 2012, 09:02:12 AM by Crome969 »

Tags: