ScriptUO

Scripting Resources & Utilities => Stealth Client => Topic started by: epsilon2 on October 17, 2016, 07:50:44 AM

Title: [6.7.0 pascal] a simple sell function
Post by: epsilon2 on October 17, 2016, 07:50:44 AM
Code: [Select]
function SellItems(Shop: String; Item: Cardinal; Amount: Integer; Debug : Integer): Integer;

var
i          : integer;
x          : integer;
list2      : TStringList;
UserList   : TStringList;
begin
ClearShopList;
SetAutoSellDelay($0001);
AutoSell(Item,$0000,Amount);
FindDistance:= 9;
FindVertical:= 9;
list2 := TStringList.Create;
FindType($0190,Ground);
wait(100);
UserList := TStringList.Create;
GetFindedList(UserList);
for i:= 0 to UserList.count -1 do
begin
    if Debug = 1 then
    begin
        FillNewWindow('Chars around: ' + GetTooltip(StrToInt('$'+UserList[i]))+ '  $' + UserList[i]);
    end;
    if  0 < pos(Shop, GetTooltip(StrtoInt('$'+UserList[i]))) then
    begin
        if Debug = 1 then
        begin
            FillNewWindow('My Shop found at: ' + InttoStr(i));
        end;
        ClearContextMenu;
        RequestContextMenu(StrtoInt('$'+UserList[i]));
        wait(1000);       
        GetContextMenu(list2);
        for x:= 1 to list2.count do
        begin
            if Debug = 1 then
            begin
                FillNewWindow('Shops ContextMenue: ' + list2[x]);
            end;
            if  0 < pos('Sell', list2[x]) then
            begin
                if Debug = 1 then
                begin
                    FillNewWindow('Shops ContextMenue entry at: ' + InttoStr(x));
                end;
                SetContextMenuHook(StrToInt('$'+UserList[i]), x);                   
            end;
            ClearShopList;
        end;
        ClearContextMenu;       
    end;
end;
UserList.free;
list2.free;
result := 1;

end;