Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Sayild Library 12/08/2012 --
- function qs1(tablename, left, right)
- if type(tablename) == 'table' then
- left = left or 1
- right = right or #tablename
- local i,j,x
- if right-left+1 <= 25 then
- for i=left+1, right do
- x=tablename[i]
- j=i-1
- while j>=left and x<tablename[j] do
- tablename[j+1]=tablename[j]
- j=j-1
- end
- tablename[j+1]=x
- end
- else
- i,j,x = left, right, tablename[math.floor((left+right)/2)]
- local temp
- repeat
- while tablename[i]<x and i < right do
- i = i+1
- end
- while tablename[j]>x and j > left do
- j = j-1
- end
- if (i <= j) then
- temp = tablename[i]
- tablename[i] = tablename[j]
- tablename[j] = temp
- i = i+1
- j = j-1
- end
- until i > j
- if (left < j) then
- qs1(tablename, left, j)
- end
- if (right > i) then
- qs1(tablename, i, right)
- end
- end
- end
- end
- function qs2(tablename, left, right, argument)
- if type(tablename) == 'table' then
- left = left or 1
- right = right or #tablename
- local i,j,x
- if right-left+1 <= 25 then
- for i=left+1, right do
- x=tablename[i]
- j=i-1
- while j>=left and x[argument] < tablename[j][argument] do
- tablename[j+1]=tablename[j]
- j=j-1
- end
- tablename[j+1]=x
- end
- else
- i,j,x = left, right, tablename[math.floor((left+right)/2)][argument]
- local temp
- repeat
- while tablename[i][argument]<x and i < right do
- i = i+1
- end
- while tablename[j][argument]>x and j > left do
- j = j-1
- end
- if (i <= j) then
- temp = tablename[i]
- tablename[i] = tablename[j]
- tablename[j] = temp
- i = i+1
- j = j-1
- end
- until i > j
- if (left < j) then
- qs2(tablename, left, j, argument)
- end
- if (right > i) then
- qs2(tablename, i, right, argument)
- end
- end
- end
- end
- function qs3(tablename, left, right)
- if type(tablename) == 'table' then
- left = left or 1
- right = right or #tablename
- local i,j,x
- if right-left+1 <= 25 then
- for i=left+1, right do
- x=tablename[i]
- j=i-1
- while j>=left and x>tablename[j] do
- tablename[j+1]=tablename[j]
- j=j-1
- end
- tablename[j+1]=x
- end
- else
- i,j,x = left, right, tablename[math.floor((left+right)/2)]
- local temp
- repeat
- while tablename[i]>x and i < right do
- i = i+1
- end
- while tablename[j]<x and j > left do
- j = j-1
- end
- if (i <= j) then
- temp = tablename[i]
- tablename[i] = tablename[j]
- tablename[j] = temp
- i = i+1
- j = j-1
- end
- until i > j
- if (left < j) then
- qs3(tablename, left, j)
- end
- if (right > i) then
- qs3(tablename, i, right)
- end
- end
- end
- end
- function qs4(tablename, left, right, argument)
- if type(tablename) == 'table' then
- left = left or 1
- right = right or #tablename
- local i,j,x
- if right-left+1 <= 25 then
- for i=left+1, right do
- x=tablename[i]
- j=i-1
- while j>=left and x[argument]>tablename[j][argument] do
- tablename[j+1]=tablename[j]
- j=j-1
- end
- tablename[j+1]=x
- end
- else
- i,j,x = left, right, tablename[math.floor((left+right)/2)][argument]
- local temp
- repeat
- while tablename[i][argument]>x and i < right do
- i = i+1
- end
- while tablename[j][argument]<x and j > left do
- j = j-1
- end
- if (i <= j) then
- temp = tablename[i]
- tablename[i] = tablename[j]
- tablename[j] = temp
- i = i+1
- j = j-1
- end
- until i > j
- if (left < j) then
- qs4(tablename, left, j, argument)
- end
- if (right > i) then
- qs4(tablename, i, right, argument)
- end
- end
- end
- end
- function seq1(tablename,value)
- if type(tablename) == 'table' then
- for i,j in ipairs(tablename) do
- if j == value then
- return i
- end
- end
- end
- return
- end
- function seq2(tablename,value,argument)
- if type(tablename) == 'table' then
- for i,j in ipairs(tablename) do
- if j[argument] == value then
- return i
- end
- end
- end
- return
- end
- function bin1(tablename,value)
- if type(tablename) == 'table' then
- local left,right = 1, #tablename
- while left <= right do
- local mid = math.floor((right+left)/2)
- if tablename[mid] == value then
- return mid
- end
- if tablename[mid] > value then
- right = mid-1
- else
- left = mid+1
- end
- end
- end
- return
- end
- function bin2(tablename,value,argument)
- if type(tablename) == 'table' then
- local left,right = 1, #tablename
- while left <= right do
- local mid = math.floor((right+left)/2)
- if tablename[mid][argument] == value then
- return mid
- end
- if tablename[mid][argument] > value then
- right = mid-1
- else
- left = mid+1
- end
- end
- end
- return
- end
- function table:find(value,argument) --Working
- if argument then
- return seq2(self,value,argument)
- end
- return seq1(self,value)
- end
- function table:newsort(argument, order) --Working
- if argument == 'asc' or argument == 'desc' then
- order = argument
- argument = false
- end
- order = order or 'asc'
- if order == 'asc' then
- if argument then
- qs2(self,1,#self,argument)
- else
- qs1(self,1,#self)
- end
- else
- if argument then
- qs4(self,1,#self,argument)
- else
- qs3(self,1,#self)
- end
- end
- end
- function table:binaryfind(value,argument) --Working
- if argument then
- return bin2(self,value,argument)
- end
- return bin1(self,value)
- end
- function dropflask()
- dropitems(283,284,285)
- end
- function depositall()
- say("Hi")
- wait(1500,2500)
- npcsay("Deposit all")
- wait(300,500)
- npcsay("yes")
- wait(200,300)
- end
- function travelabdendriel()
- say("Hi")
- wait(1500,2500)
- npcsay("A'bdendriel")
- wait(300,500)
- npcsay("yes")
- wait(200,300)
- end
- function travelvenore()
- say("Hi")
- wait(1500,2500)
- npcsay("Venore")
- wait(300,500)
- npcsay("yes")
- wait(200,300)
- end
- function travelsvargrond()
- say("Hi")
- wait(1500,2500)
- npcsay("Svargrond")
- wait(300,500)
- npcsay("yes")
- wait(200,300)
- end
- function traveledron()
- say("Hi")
- wait(1500,2500)
- npcsay("Edron")
- wait(300,500)
- npcsay("yes")
- wait(200,300)
- end
- function travelcarlin()
- say("Hi")
- wait(1500,2500)
- npcsay("Carlin")
- wait(300,500)
- npcsay("yes")
- wait(200,300)
- end
- function travelthais()
- say("Hi")
- wait(1500,2500)
- npcsay("Thais")
- wait(300,500)
- npcsay("yes")
- wait(200,300)
- end
- function traveldarashia()
- say("Hi")
- wait(1500,2500)
- npcsay("Darashia")
- wait(300,500)
- npcsay("yes")
- wait(200,300)
- npcsay("yes")
- wait(200,300)
- end
- function travelankrahmun()
- say("Hi")
- wait(1500,2500)
- npcsay("Ankrahmun")
- wait(300,500)
- npcsay("yes")
- wait(200,300)
- end
- function travellibertybay()
- say("Hi")
- wait(1500,2500)
- npcsay("Liberty Bay")
- wait(300,500)
- npcsay("yes")
- wait(200,300)
- end
- function travelyalahar()
- say("Hi")
- wait(1500,2500)
- npcsay("Yalahar")
- wait(300,500)
- npcsay("yes")
- wait(200,300)
- end
- function travelporthope()
- say("Hi")
- wait(1500,2500)
- npcsay("Port Hope")
- wait(300,500)
- npcsay("yes")
- wait(200,300)
- end
- function travelfarmine()
- say("Hi")
- wait(1500,2500)
- npcsay("Farmine")
- wait(300,500)
- npcsay("yes")
- wait(200,300)
- end
- function travelgoroma()
- say("Hi")
- wait(1500,2500)
- npcsay("Goroma")
- wait(300,500)
- npcsay("yes")
- wait(200,300)
- end
- function opentrade()
- if not tradeopen then
- say("Hi")
- wait(1500,2500)
- npcsay("Trade")
- wait(600,800)
- updateworld()
- end
- end
- function softequip()
- if boots ~= 6529 then
- if itemcount("soft boots") < 0 then
- moveitems("soft boots","all","boots",1)
- end
- end
- end
- function ssondeath()
- local takess = true
- if hppc == 0 then
- if takess then
- screenshot()
- end
- takess = false
- else
- takess = true
- end
- end
- function lifering()
- if itemcount('life ring') < 0 then
- moveitem('life ring', 'all', 'ring', 1)
- end
- end
- function sdalert()
- if itemcount(3155) <= 10 then
- playsound ('alert.wav')
- end
- end
- function getbpindex(bpcolor) --by golfinhu
- local bpcolors = {'beach', 'blue', 'brocade', 'brown', 'camouflage', 'crown', 'demon', 'dragon', 'expedition', 'fur', 'golden', 'green', 'grey', 'heart', 'holding', 'minotaur', 'moon', 'orange', 'pirate', 'purple', 'red', 'santa', 'yellow', 'jewelled'}
- local bpcolor = bpcolor:lower()
- if bpcolor:find('holding') then
- bpcolor = 'holding'
- elseif bpcolor:token(1) == 'backpack' then
- bpcolor = 'brown'
- end
- local color = bpcolor:token(1)
- if not table.find(bpcolors, color) then
- printerror('Bp color not valid')
- return false
- end
- local bps = {}
- for i = 0, windowcount() - 1 do
- local bpname = getcontainer(i).name:lower()
- if bpname == 'backpack of holding' then
- bpname = 'holding backpack'
- elseif bpname == 'backpack' then
- bpname = 'brown backpack'
- end
- if bpname == color..' backpack' then
- if color == 'holding' then
- table.insert(bps, 'backpack of holding '..i)
- else
- table.insert(bps, color..' backpack '..i)
- end
- end
- end
- return bps
- end
- function closebpcolor(bpcolor, indexs, indexe) --by golfinhu
- if not bpcolor then
- return false
- elseif not indexs then
- if bpcolor:find('holding') then
- return closewindows('backpack of holding')
- else
- return closewindows(bpcolor:token(1)..' backpack')
- end
- end
- local indexe = indexe or indexs
- local indexs, indexe = tonumber(indexs) + 1, tonumber(indexe) + 1
- local index = getbpindex(bpcolor)
- if table.isempty(index) or #index < indexs then return false end
- for i = indexs, math.lowest(indexe,#index) do
- closewindows(index[i])
- end
- end
- function arguments(function_name, function_arguments) -- Working
- for i = 1, #function_arguments, 2 do
- if (type(function_arguments[i + 1]) ~= function_arguments[i]) then
- return false, error('bad argument #' .. math.ceil(i / 2) .. ' to \'' .. function_name .. '\' (' .. function_arguments[i] .. ' expected, got ' .. type(function_arguments[i + 1]) .. ')', 3)
- end
- end
- end
- _PRINT = _PRINT or print
- function print(...)
- local msgs = {...}
- local toprint = ''
- for i,j in ipairs(msgs) do
- if type(j) == 'table' then
- toprint = toprint..table.stringformat(j)..' '
- else
- toprint = toprint..tostring(j)..' '
- end
- end
- _PRINT(toprint:sub(1, #toprint-1))
- end
- _PRINTERROR = _PRINTERROR or printerror
- function printerror(...)
- local msgs = {...}
- local toprint = ''
- for i,j in ipairs(msgs) do
- if type(j) == 'table' then
- toprint = toprint..table.stringformat(j)..' '
- else
- toprint = toprint..tostring(j)..' '
- end
- end
- _PRINTERROR(toprint:sub(1, #toprint-1))
- end
- function opengrounditem(id)
- if id then
- id = itemid(id)
- end
- for i=SCREEN_LEFT, SCREEN_RIGHT do
- for j=SCREEN_TOP, SCREEN_BOTTOM do
- local x,y,z = posx+i, posy+j, posz
- local topid = topitem(x,y,z).id
- if tilereachable(x,y,z) and (not id and itemproperty(topid, ITEM_ISCONTAINER)) or topid == id then
- reachlocation(x,y,z)
- openitem(topid, ground(x,y,z)) waitcontainer() return true
- end
- end
- end
- return false
- end
- function eatfood(location, ...)
- location = location or ''
- local foodtable = {3583, 3731, 3726, 3582, 3725, 3593, 3589, 12310, 3580, 3594, 3577, 3586, 3729, 3578, 8010, 3579, 3600, 3727, 3592, 3597, 3723, 3607, 5678, 3587, 3602, 3728, 3606, 3596, 3585, 3595, 3732, 3584, 3724, 3581, 3601, 3730, 3599, 3598, 3591, 3590, 3588}
- if (type(location) == 'number') then
- if location <= 15 then
- location = tostring(location)
- else
- foodtable = {location, ...}
- location = ''
- end
- elseif select("#", ...) > 0 then
- foodtable = {...}
- end
- if location == 'ground' then
- local foundfood = false
- for j=-1, 1 do
- for i=-1, 1 do
- local topid = topitem(posx+i, posy+j, posz).id
- local foodtime = getfoodtime(topid)
- if isfood(topid) and foodtime+gethungrytime() <= 1200000 then
- useitem(topid, ground(posx+i, posy+j, posz)) wait(100) increasehungrytime(foodtime) return true
- end
- end
- end
- elseif location:sub(1,6) == 'ground' then
- local coord = (location:sub(8)):token()
- coord[1],coord[2],coord[3] = tonumber(coord[1]),tonumber(coord[2]),tonumber(coord[3])
- local topid = topitem(table.unpack(coord)).id
- local foodtime = getfoodtime(topid)
- if isfood(topid) and foodtime+gethungrytime() <= 1200000 then
- useitem(topid, ground(table.unpack(coord))) increasehungrytime(foodtime) wait(100) return true
- end
- else
- for i,j in ipairs(foodtable) do
- local foodtime = getfoodtime(j)
- if itemcount(j, location) > 0 and foodtime+gethungrytime() <= 1200000 then
- useitem(j, location) increasehungrytime(foodtime) wait(100) return true
- end
- end
- end
- return false
- end
- function firewalkerequip()
- if itemcount("firewalker boots") > 0 then
- moveitems("firewalker boots","all","boots",1)
- end
- end
- function cursorinfo() -- Credits to Anonymickey, for doing the calculations.
- local temp = {x,y,z,id,msg}
- if cursor.x >= worldwin.left and cursor.x <= worldwin.right and cursor.y <= worldwin.bottom and cursor.y >= worldwin.top then
- local sqmWidth = (worldwin.bottom - worldwin.top)/11
- temp.x, temp.y, temp.z = posx - 8 + math.ceil((cursor.x - worldwin.left)/sqmWidth), posy - 6 + math.ceil((cursor.y - worldwin.top)/sqmWidth), posz
- temp.id = topitem(temp.x, temp.y, temp.z).id
- temp.msg = temp.x..', '..temp.y..', '..temp.z..' / '..temp.id
- else
- temp.x, temp.y, temp.z, temp.id, temp.msg = 0,0,0,0,'dontlist'
- end
- return temp
- end
- function press(keys) -- Working
- local i = 1
- while i <= #keys do
- local key = ''
- if string.sub(keys, i, i) == '[' then
- i2 = i + string.find(string.sub(keys, i), ']')
- key = string.sub(keys, i+1, i2-2)
- keyevent(keyid(key))
- i = i2
- elseif string.sub(keys, i, i) ~= ']' then
- keyevent(keyid(string.sub(keys, i, i)))
- i = i + 1
- end
- end
- end
- function pm(message, ...) -- Working
- local players = {...}
- if #players > 1 then
- for k, v in ipairs(players) do
- pm(message, v)
- end
- elseif #players == 1 then
- local player = players[1]
- if ischannel(player) then
- say(player, message)
- else
- for i = 1, #player-1 do
- if ischannel(string.sub(player, 1, i) .. "...") then
- say(string.sub(player, 1, i) .. "...", message)
- return
- end
- end
- say('*' .. player .. '* ' .. message)
- end
- end
- end
- function time(secs, pattern) -- Working
- local times = {dd = math.floor(secs / 86400), hh = math.floor(secs / 3600) % 24, mm = math.floor(secs / 60) % 60, ss = secs % 60}
- if not pattern then
- if times.dd > 0 then
- pattern = 'dd:hh:mm:ss'
- elseif times.hh > 0 then
- pattern = 'hh:mm:ss'
- else
- pattern = 'mm:ss'
- end
- end
- pattern = pattern:lower()
- for k, v in pairs(times) do
- pattern = string.gsub(pattern, k, math.format(v, "00"))
- end
- return pattern
- end
- function keyid(key) -- Working -- Find full list at: http://api.farmanager.com/en/winapi/virtualkeycodes.html
- local keys = {MOUSELEFT = 0x01, MOUSERIGHT = 0x02, MOUSEMIDDLE = 0x04, BACKSPACE = 0x08, TAB = 0x09, CLEAR = 0x0C, ENTER = 0x0D, SHIFT = 0x10, CTRL = 0x11, ALT = 0x12, PAUSE = 0x13, CAPSLOCK = 0x14, ESC = 0x1B, SPACE = 0x20, PAGEUP = 0x21, PAGEDOWN = 0x22, END = 0x25, HOME = 0x24, LEFTARROW = 0x25, UPARROW = 0x26, RIGHTARROW = 0x27, DOWNARROW = 0x28, SELECT = 0x29, PRINT = 0x2A, ExECUTE = 0x2B, PRINTSCREEN =0x2C, INSERT = 0x2D, DELETE = 0x2E, HELP = 0x2F, A = 0x41, B = 0x42, C = 0x43, D = 0x44, E = 0x45, F = 0x46, G = 0x47, H = 0x48, I = 0x49, J = 0x4A, K = 0x4B, L = 0x4C, M = 0x4D, N = 0x4E, O = 0x4F, P = 0x50, Q = 0x51, R = 0x52, S = 0x53, T = 0x54, U = 0x55, V = 0x56, W = 0x57, x = 0x58, Y = 0x59, Z = 0x5A, SLEEP = 0x5F, NUM0 = 0x60, NUM1 = 0x61, NUM2 = 0x62, NUM3 = 0x63, NUM4 = 0x64, NUM5 = 0x65, NUM6 = 0x66, NUM7 = 0x67, NUM8 = 0x68, NUM9 = 0x69, MULTIPLY = 0x6A, ADD = 0x6B, SEPARATOR = 0x6C, SUBTRACT = 0x6D, DECIMAL = 0x6E, DIVIDE = 0x6F, F1 = 0x70, F2 = 0x71, F3 = 0x72, F4 = 0x73, F5 = 0x74, F6 = 0x75, F7 = 0x76, F8 = 0x77, F9 = 0x78, F10 = 0x89, F11 = 0x7A, F12 = 0x7B, F13 = 0x7C, F14 = 0x7D, F15 = 0x7E, F16 = 0x7F, F17 = 0x80, F18 = 0x81, F19 = 0x82, F20 = 0x83, F21 = 0x84, F22 = 0x85, F23 = 0x86, F24 = 0x87, NUMLOCK = 0x90, SCROLLLOCK = 0x91, COMMA = 0xBC, HIFFEN = 0xBD, DOT = 0xBE, BAR = 0xBF, SINGLEQUOTE = 0xD3}
- local numberkeys = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39}
- if tonumber(key) then
- return numberkeys[key + 1]
- end
- return keys[string.upper(key)]
- end
- function dropvials()
- if itemcount(284)+itemcount(283)+itemcount(285) > 50 then
- moveitems(284,'ground')
- moveitems(283,'ground')
- moveitems(285,'ground')
- end
- end
- function flasks() -- By Raphael
- return itemcount(283) + itemcount(284) + itemcount(285)
- end
- function sellflasks()
- opentrade()
- if tradeopen then
- for i=283,285 do
- local count = countitem(i)
- while count > 0 do
- sellitems(i,count)
- wait(200,300)
- count = countitem(i)
- end
- end
- end
- end
- function staminalow()
- while stamina < 60*16 do
- if battlesigned then
- pausewalking(500)
- else
- closeclient()
- end
- wait(100)
- end
- function repairsoft()
- say('hi')
- wait(2000, 3000)
- while itemcount(6530) > 0 do
- npcsay('repair')
- wait(500, 1500)
- npcsay('yes')
- wait(500, 1500)
- end
- function windowcount(item)
- item = item or "all"
- return wincount(item)
- end
- function openitem(item, origem, next, index)
- index = index or 0
- next = next or false
- return openitemindex(item, origem, next, index)
- end
- function wait(time1, time2)
- time2 = time1 or time2
- sleep(time1, time2)
- end
- function islocation(value)
- value = value or 0
- return isloc(value)
- end
- function islocationxyz(x,y,z,distance)
- distance= distance or 0
- return _islocationxyz(x,y,z,distance)
- end
- function moveitems(item, origem, destino, count)
- if destino == nil and count == nil then
- moveitemsb(item, origem, 100)
- return
- end
- if count == nil then
- moveitemsb(item, origem, destino)
- return
- end
- moveitemsa(item, origem, destino, count)
- end
- function buyitemsupto(itemname, amount, currentamount)
- currentamount = currentamount or itemcount(itemname)
- amount = amount-currentamount
- while amount > 0 do
- buyitems(itemname, amount)
- wait(200,300)
- amount = amount-100
- end
- end
- function sellitemsupto(itemname, amount, currentamount)
- currentamount = currentamount or itemcount(itemname)
- amount = amount-currentamount
- while amount > 0 do
- sellitems(itemname, amount)
- wait(200,300)
- amount = amount-100
- end
- end
- function entermachine(item)
- local currentamount = itemcount(item)
- amount = currentamount - 20
- count = 0
- maxtry = 50
- while itemcount(item) > amount and count < maxtry do
- count = count + 1
- if islocationxyz(33268, 31830, 10, 5) then
- if toptileitem(33268, 31830, 10) == 846 then
- useitem(846, 33268, 31830, 10)
- wait(400,600)
- end
- useitemon(item, 33268, 31830, 10)
- wait(500,600)
- if(currentamount == itemcount(item)) then
- if toptileitem(33268, 31830, 10) == 842 then
- useitem(842, 33268, 31830, 10)
- wait(400,600)
- end
- else
- currentamount = itemcount(item)
- end
- else
- break
- end
- end
- if toptileitem(33268, 31830, 10) == 842 then
- useitem(842, 33268, 31830, 10)
- wait(400,600)
- end
- end
- function printonadvance()
- local ss = {Level = true,
- magic = true,
- fist = false,
- axe = false,
- club = false,
- sword = false,
- distance = false,
- shielding = false,
- fishing = false}
- foreach newmessage m do
- if m.type == 16 then
- local c = m.content
- local adv = string.match(c, 'You advanced .- (.-)[%s%.].-')
- if adv then
- if ss[adv] then
- if $minimized then
- restoreclient()
- wait(400, 600)
- screenshot()
- wait(400, 600)
- minimizeclient()
- else
- wait(400, 600)
- screenshot()
- end
- end
- end
- end
- end
- function waitandlogout()
- while connected do
- while battlesigned do
- foreach creature m 'ms' do
- if iscreaturereachable(m) then
- setattackmode('none', 'chase')
- attack(m)
- break
- end
- end
- pausewalking(300)
- wait(100)
- end
- logout()
- wait(100)
- end
- end
- function randomize(ttable)
- local value = 0
- if type(ttable) == 'table' then
- value = math.random(table.unpack(ttable))
- end
- return value
- end
- function dropitems(pos,...)
- local items = {...}
- if type(pos) == 'number' then
- table.insert(items,pos)
- pos = 'ground'
- end
- for i,j in ipairs(items) do
- while itemcount(j) > 0 do
- moveitemsb(j,pos,100)
- end
- end
- end
- function levitate(direction,updown)
- local dir = {x = {n = 0, s = 0, w = -1, e = 1}, y = {n = -1, s = 1, w = 0, e = 0}}
- if direction == 'w' or direction == 'e' or direction == 'n' or direction == 's' then
- local startposz,tries,maxtries = posz,0,math.random(4,6)
- if not updown or (updown ~= 'up' and updown ~= 'down') then
- local toptileid = toptileitem(posx+dir.x[direction],posy+dir.y[direction],posz)
- updown = 'up'
- if toptileid == 0 or itemproperty(toptileid).isUnpassable == true then
- updown = 'down'
- end
- end
- while mp >= 50 and level >= 12 and posz == startposz and tries < maxtries do
- turn(direction)
- cast('exani hur '..updown)
- wait(1000,1500)
- tries=tries+1
- if posz ~= startz then
- return true
- end
- end
- end
- return false
- end
- function depotdeposit(bptomove,...)
- lastonto = 0
- local items = {...}
- local _nexti = true
- for i,j in pairs(items) do
- _nexti = true
- while itemcount(items[i]) > 0 and _nexti do
- _nexti = moveitemsonto(items[i], "all", bptomove, 100, lastonto)
- wait(400,500)
- end
- end
- end
- function itemcount(item, origem)
- origem = origem or "all"
- return _itemcount(item, origem)
- end
- function countitem(item, origem)
- origem = origem or "all"
- return _itemcount(item, origem)
- end
- function higherwindows(name)
- name = name or "all"
- _controlwindows(name, true)
- end
- function minimizeequip()
- minimizewindows(equip)
- end
- function minimizewindows(name)
- name = name or "all"
- _controlwindows(name, false)
- end
- function haste()
- if not hasted then
- cast("utani hur")
- end
- end
- function antiidle()
- turn("n")
- turn("e")
- turn("s")
- turn("w")
- end
- function manashield()
- if not manashielded then
- cast("utamo vita")
- end
- end
- function charge()
- if not hasted then
- cast("utani tempo hur")
- end
- end
- function stronghaste()
- if not hasted then
- cast("utani gran hur")
- end
- end
- function maround(range,allfloors,...)
- local names = {...}
- range = range or 7
- allfloors = allfloors or false
- if type(range) == 'string' then
- table.insert(names,range)
- range = 7
- end
- if type(allfloors) == 'string' then
- table.insert(names,allfloors)
- allfloors = false
- end
- local name = ''
- for i,j in pairs(names) do
- name = name..names[i]..';'
- end
- return _maround(range,allfloors,name)
- end
- function paround(range,allfloors,...)
- local names = {...}
- range = range or 7
- allfloors = allfloors or false
- if type(range) == 'string' then
- table.insert(names,range)
- range = 7
- end
- if type(allfloors) == 'string' then
- table.insert(names,allfloors)
- allfloors = false
- end
- local name = ''
- for i,j in pairs(names) do
- name = name..names[i]..';'
- end
- return _paround(range,allfloors,name)
- end
- function pickupitems(dir,...)
- local items = {...}
- local dire = {dirs = {'c', 'n', 's', 'w', 'e', 'nw', 'ne', 'sw', 'se'},
- x = {c = 0, n = 0, s = 0, w = -1, e = 1, nw = -1, ne = 1, sw = -1, se = 1},
- y = {c = 0, n = -1, s = 1, w = 0, e = 0, nw = -1, ne = -1, sw = 1, se = 1}}
- if not dir or not table.find(dire.dirs,dir) then
- if dir ~= nil then
- table.insert(items,dir)
- end
- dir = 'c'
- end
- local pos = {x = posx+dire.x[dir], y = posy+dire.y[dir], z = posz}
- local topid = toptileitem(pos.x,pos.y,pos.z)
- local id = topid
- local item = itemproperty(topid)
- if #items == 0 then
- if topid ~= 0 and item.isTakeable then
- moveitems(topid,ground(pos.x,pos.y,pos.z),'all',100)
- end
- else
- for i,j in pairs(items) do
- if type(j) == 'number' then
- id = j
- else
- id = itemid(j)
- end
- if topid == id and item.isTakeable then
- moveitems(topid,ground(pos.x,pos.y,pos.z),'all',100)
- break
- end
- end
- end
- end
- function gotolabel(label)
- if type(label) == 'number' then
- _gotolabeln(label)
- else
- _gotolabels(label)
- end
- end
- function useitem(item, x, y, z)
- x = x or 'all'
- if type(x) == 'number' then
- _useitemxyz(item, x, y, z)
- else
- _useitem(item, x)
- end
- end
- function useitemon(item, x, y, z)
- if z == nil then
- y = y or 'all'
- useitemonitem(item, x, y)
- else
- _useitemon(item, x, y, z)
- end
- end
- function say(text, channel)
- if channel == nil then
- _say(text)
- else
- anysay(text, channel)
- end
- end
- function underattack(type)
- type = type or 'all'
- return _underattack(type)
- end
- function gold()
- return itemcount(3031) + (itemcount(3035) * 100) + (itemcount(3043) * 10000)
- end
- function waitping(base)
- local base = base or 200
- if ping == 0 then ping = base end
- wait(2 * ping, 4 * ping)
- end
- _LISTAS = _LISTAS or listas
- function listas(...)
- local msgs = {...}
- local toprint = ''
- for i,j in ipairs(msgs) do
- if type(j) == 'table' then
- toprint = toprint..table.stringformat(j)..' '
- else
- toprint = toprint..tostring(j)..' '
- end
- end
- _LISTAS(toprint:sub(1, #toprint-1))
- end
- function dontlist()
- listas('dontlist')
- end
- function withdraw(amount, npc, sayhi)
- if not amount or amount == 0 then
- return true
- end
- if say('hi') == true then
- npcsay('hi', 'withdraw ' .. amount, 'yes')
- else
- npcsay('withdraw ' .. amount, 'yes')
- end
- waitping()
- foreach newmessage m do
- if m.content == 'There is not enough gold on your account.' then
- if (not npc) or (npc == '') or (m.sender == npc) then
- return false
- end
- end
- end
- return true
- end
- function antifurnituretrap(weapontouse)
- weapontouse = weapontouse or 3308 -- machete
- local blockwalkids = {2025, 2029, 2030, 2043, 2044, 2045, 2046, 2047, 2048, 2059, 2060, 2061, 2445, 2446, 2447, 2448, 2449, 2450, 2451, 2452, 2453, 2454, 2465, 2466, 2467, 2468, 2524, 2904, 2959, 2960, 2961, 2962, 2963, 2964, 2975, 2976, 2979, 2982, 2986, 2997, 2998, 2999, 3000, 3484, 3485, 3486, 3487, 3510, 3511, 3512, 3513, 5046, 5055, 5056, 6109, 6110, 6111, 6112, 6367, 6368, 6369, 6370, 7860, 7861, 7862, 7863, 9132, 9141, 10208, 10210, 10211, 10212, 10213, 10214, 10215}
- for i=-7,7 do
- for j=-5,5 do
- local x,y,z = posx+i,posy+j,posz
- if table.binaryfind(blockwalkids,toptileitem(x,y,z)) then
- if tilereachable(x,y,z) then
- pausewalking(10000)
- local topid = toptileitem(x,y,z)
- while tilereachable(x,y,z) and (math.abs(posx-x) > 1 or math.abs(posy-y) > 1) do
- reachlocation(x,y,z)
- wait(100,200)
- updateworld()
- end
- while toptileitem(x,y,z) == topid and posz == z and (math.abs(posx-x) <= 1 and math.abs(posy-y) <= 1) do
- useitemon(weapontouse,toptileitem(x,y,z),ground(x,y,z))
- pausewalking(5000)
- wait(400,500)
- updateworld()
- end
- pausewalking(0)
- end
- end
- end
- end
- end
- function getcreatures(filter)
- filter = filter or 'pmfs'
- return _getcreatures(filter)
- end
- function openhole(x,y,z,holes)
- x,y,z = x or wptx, y or wpty, z or wptz
- holes = holes or {{593,594}, {606, 607}, {608, 609}, {867, 868}}
- reachlocation(x,y,z)
- if x and y and z and math.abs(posx-x) <= 7 and math.abs(posy-y) <= 5 and posz == z then
- local v = 1
- while v <= #holes and not isitemontile(holes[v][1],x,y,z) do
- v = v+1
- end
- if v <= #holes then
- local id = toptileitem(x,y,z)
- while id ~= holes[v][2] do
- if id == holes[v][1] then
- if iscreatureontile(x,y,z) then
- local dir = wheretomove(x,y,z)
- moveitems(99,ground(x,y,z),ground(dir.x,dir.y,z),100)
- wait(1400,1600)
- else
- useitemon(shovel,x,y,z)
- wait(900,1100)
- end
- else
- local dir = wheretomove(x,y,z)
- moveitems(id,ground(x,y,z),ground(dir.x,dir.y,z),100)
- wait(500,700)
- end
- id = topitem(x,y,z)
- end
- return true
- end
- end
- return false
- end
- function opensand(x,y,z)
- return openhole(x,y,z, {{231,615}})
- end
- function uselever(x,y,z,id)
- x,y,z = x or wptx, y or wpty, z or wptz
- local levers = {2771, 2772}
- if id then
- levers = {id}
- end
- reachlocation(x,y,z)
- if x and y and z and math.abs(posx-x) <= 7 and math.abs(posy-y) <= 5 and posz == z then
- local v = 1
- while v <= #levers and not isitemontile(levers[v],x,y,z) do
- v = v+1
- end
- if v <= #levers then
- local id = toptileitem(x,y,z)
- while isitemontile(levers[v],x,y,z) do
- if id == levers[v] then
- if iscreatureontile(x,y,z) then
- local dir = wheretomove(x,y,z)
- moveitems(99,ground(x,y,z),ground(dir.x,dir.y,z),100)
- wait(1400,1600)
- else
- useitem(levers[v],ground(x,y,z))
- wait(500,700)
- end
- else
- local dir = wheretomove(x,y,z)
- moveitems(id,ground(x,y,z),ground(dir.x,dir.y,z),100)
- wait(500,700)
- end
- id = toptileitem(x,y,z)
- end
- return true
- end
- end
- return false
- end
- function getitems(...)
- local items = {...}
- local item = ''
- for i,j in pairs(items) do
- item = item..items[i]..';'
- end
- return _getitems(item)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement