-- V1.3 local timetable = {}; --[[ This function transport your char with the help from of a spell @pre spell must be ready and your char/class must have it @post change your chars position @arg _spell choose the destination take a look at the code you can use names or numbers @arg _wpfile (optional) you can at a waypoint file that should loaded afterward @arg _holdonerror (optinal) you can choose to stop the script or logout if you use 1 the char will logout anyother value will besides nil or 1 will stop the script in chase of an error if nil or zero the function returns false @return if no _holdonerror is specified and not zero, true if it worked and false if not. example: TransportBySpell(0,"StartPointWP") This will use recall to transport your char and then load the path "StartPointWP" ]]-- function TransportBySpell( _spell, _wpfile, _holdonerror) local realName = nil; if( string.lower(_spell) == "recall" or _spell == 0)then realName = GetIdName(540001) elseif( string.lower(_spell) == "reifort" or _spell == 1)then realName = GetIdName(540191) --tal of preparation ? elseif( string.lower(_spell) == "tal of preparation" or _spell == 2)then realName = GetIdName(540192) elseif( string.lower(_spell) == "heffner" or _spell == 3)then realName = GetIdName(540193) -- Their are a gap of 2 some startplaces we don't know? elseif( string.lower(_spell) == "morfatas" or _spell == 4)then realName = GetIdName(540195) else error("Unknown transport spell") end if( realName == nil)then error("No matching value for transport spell") end releaseKeys() SlashCommand("/cast "..realName..""); if( _wpfile == nil)then return waitForLoadingScreen(120); else if( waitForLoadingScreen(120))then loadPaths(_wpfile); return true; else if _holdonerror and _holdonerror ~= 0 then if _holdonerror == 1 then player:logout(); end if _holdonerror ~= 1 then error("Wasn't able to transport") end else return false; end end end end --[[ This function will transport your chat to your house @pre enough Home-sweet-home runes and have a house @modify change your chars position to your house @arg _wpfile (optional) you can add a waypoint file that will be loaded afterwards @arg _holdonerror (optinal) you can choose to stop the script or logout if you use 1 the char will logout anyother value will besides nil or 1 will stop the script in chase of an error if nil or zero the function returns false @return if no _holdonerror is specified and not zero, true if it worked and false if not. example: TransportToHouse() --]] function TransportToHouse( _wpfile, _holdonerror) local item = inventory:findItem(202435) if item == nil then if _holdonerror and _holdonerror ~= 0 then if _holdonerror == 1 then player:logout(); end if _holdonerror ~= 1 then error("Missing Home-sweet-home rune") end else return false; end else item:use(); if( waitForLoadingScreen(120))then if( _wpfile ~= nil)then loadPaths(_wpfile); end return true; else if _holdonerror and _holdonerror ~= 0 then if _holdonerror == 1 then player:logout(); end if _holdonerror ~= 1 then error("Wasn't able to transport") end else return false; end end end end --[[ This function will transport your chat to your gild @pre enough Guild Castle Transport Stone and have a gild @post change your chars position to your gild @arg _wpfile (optional) you can add a waypoint file that will be loaded afterwards @arg _holdonerror (optinal) you can choose to stop the script or logout if you use 1 the char will logout anyother value will besides nil or 1 will stop the script in chase of an error if nil or zero the function returns false @return if no _holdonerror is specified and not zero, true if it worked and false if not. example: TransportToGild() --]] function TransportToGild( _wpfile, _holdonerror) local item = inventory:findItem(203784) if item == nil then if _holdonerror and _holdonerror ~= 0 then if _holdonerror == 1 then player:logout(); end if _holdonerror ~= 1 then error("Missing Guild Castle Transport Stone") end else return false; end else item:use(); if( waitForLoadingScreen(120))then if( _wpfile ~= nil)then loadPaths(_wpfile); end return true; else if _holdonerror and _holdonerror ~= 0 then if _holdonerror == 1 then player:logout(); end if _holdonerror ~= 1 then error("Wasn't able to transport") end else return false; end end end end --[[ This function transport your char with the help from of the TB and a item @pre you must have enough runes for the transport @post change your chars position @arg _item choose transport methode take a look at the code you can use names or numbers @arg _transporttotarget choose the target of your destination you can use the name of the titel in TB or the index nummber from the TB @arg _wpfile (optional) you can at a waypoint file that should loaded afterward @arg _holdonerror (optinal) you can choose to stop the script or logout if you use 1 the char will logout anyother value will besides nil or 1 will stop the script in chase of an error if nil or zero the function returns false @return if no _holdonerror is specified and not zero, true if it worked and false if not. @notice if you have the userfunction gotoportal the bot will jump into the portal example: TransportByTB(0,25,"StartnewWP") This will use transport runes and the spot in your TB with the index 28 to transport you char away and then load the path "StartnewWP" ]]-- function TransportByTB( _item, _transporttotarget, _wpfile, _holdonerror) local whichtransport = nil; if( _item == nil )then error("No transport methode defined"); end if( string.lower(_item) == "transportrune" or _item == 0)then whichtransport = 0; elseif( string.lower(_item) == "portalrune" or _item == 1)then whichtransport = 1; elseif( string.lower(_item) == "passagewayrune" or _item == 2)then whichtransport = 2; else error("Unknow transport Methode"); end local i = 1 if(type( _transporttotarget ) ~="number")then local TB_ID,note,ZoneID,X,Y,Z,Name,icon; repeat TB_ID,note,ZoneID,X,Y,Z,Name,icon = RoMScript("TB_GetTeleportInfo("..i..")") if note == _name then break; elseif TB_ID == 0 then break; else i = i + 1 end until false if( TB_ID == 0)then error("Didn't find destionation in transport-book"); else _transporttotarget = i; end end errorflag = false; if( whichtransport == 0)then if( not(inventory:itemTotalCount(202903) > 0))then errorflag = true; end end if( whichtransport == 1)then if( not(inventory:itemTotalCount(202904) > 0))then errorflag = true; end end if( whichtransport == 2)then if( not(inventory:itemTotalCount(202905) > 0))then errorflag = true; end end if(errorflag == true)then if _holdonerror and _holdonerror ~= 0 then if _holdonerror == 1 then player:logout(); end if _holdonerror ~= 1 then error("Wasn't able to transport") end else return false; end end if( whichtransport == 0)then releaseKeys() RoMScript("TB_Teleport("..whichtransport..",".._transporttotarget..")"); if( _wpfile == nil)then return waitForLoadingScreen(120); else if( waitForLoadingScreen(120))then loadPaths(_wpfile); return true; else if _holdonerror and _holdonerror ~= 0 then if _holdonerror == 1 then player:logout(); end if _holdonerror ~= 1 then error("Wasn't able to transport") end else return false; end end end end if( whichtransport == 1 or whichtransport == 2)then releaseKeys() RoMScript("TB_Teleport("..whichtransport..",".._transporttotarget..")"); if( GoThroughPortal ~= nil)then local j = 0 local transportflag = false; repeat if(GoThroughPortal)then transportflag = true; break; end j = j + 1; until j >= 3 if( transportflag == false)then if _holdonerror and _holdonerror ~= 0 then if _holdonerror == 1 then player:logout(); end if _holdonerror ~= 1 then error("Wasn't able to transport") end else return false; end end end if( _wpfile ~= nil)then loadPaths(_wpfile); end return true; end return 0; end --[[ This function transport your char away if you not in the specified spot at max secure @pre spell must be ready or have the specific item @post change your chars position @arg __sX,_sZ,_sY, the waypoint that you should be in range @arg _dist how far away you can bevor the transport triggers @arg _wpfile the waypointfile that should load afterwards @arg _bookentry the TB entry which will used, you can use the name of the titel in TB or the index nummber from the TB @arg _holdonerror (optinal) you can choose to stop the script or logout if you use 1 the char will logout anyother value will besides nil or 1 will stop the script in chase of an error if nil or zero the function returns -1 @arg _altitemuse (optional) The typ of runes for you TB you want to use als alternative if nothing specificed it will be transport runes. @arg _altspelluse (optional) The typ of spell you want to try first if nothing specificed it will be recall @return true if transport was needed if not false in case of an error -1 example: SafeNotInSpotTransport(-15134 , 11548 , 160 , 150 ,"ReturnWP", 28) This will transport you away if you are not near the res-spot from KS ]]-- function SafeNotInSpotTransport(_sX,_sZ,_sY,_dist, _wpfile, _bookentry, _holdonerror, _altitemuse, _altspelluse ) if( _altitemuse == nil)then _altitemuse = 0; end if ( _altspelluse == nil)then _altspelluse = 0; end player:update(); if( distance(player.X, player.Z, player.Y,_sX,_sZ ,_sY) >_dist )then printf("We are outside of range we try recall \n"); releaseKeys() if( not(TransportBySpell( _altspelluse , _wpfile))) then if( _bookentry ~= nil)then printf("Recall failed we try transport by a rune \n"); if( not(TransportByTB( _altitemuse, _bookentry, _wpfile)))then if( _holdonerror == nil)then return -1; else if( _holdonerror == 1)then player:logout(); end if( _holdonerror ~= 1)then error("All tries failed to transport"); end end else return true; end end if( _holdonerror == nil)then return -1; else if( _holdonerror == 1)then player:logout(); end if( _holdonerror ~= 1)then error("All tries failed to transport"); end end else return true; end else return false; end return 0; end --[[ This function transport your char away if you in the specified spot at max secure @pre spell must be ready or have the specific item @post change your chars position to the given values @arg __sX,_sZ,_sY, the waypoint that you should be in range @arg _dist how far away you can bevor the transport triggers @arg _wpfile the waypointfile that should load afterwards @arg _bookentry the TB entry which will used, you can use the name of the titel in TB or the index nummber from the TB @arg _holdonerror (optinal) you can choose to stop the script or logout if you use 1 the char will logout anyother value will besides nil or 1 will stop the script in chase of an error if nil or zero the function returns -1 @arg _altitemuse (optional) The typ of runes for you TB you want to use als alternative if nothing specificed it will be transport runes. @arg _altspelluse (optional) The typ of spell you want to try first if nothing specificed it will be recall @return true if transport was needed if not false in case of an error -1 @notice This function is the opposite of SafeNotInSpotTransport I added because someone may need it and it was easy to do. example: SafeSpotTransport(-15134 , 11548 , 160 , 150 ,"ReturnWP", 28) This will transport you away if you are near the res-spot from KS ]]-- function SafeSpotTransport(_sX,_sZ,_sY,_dist, _wpfile, _bookentry, _holdonerror, _altitemuse, _altspelluse ) if( _altitemuse == nil)then _altitemuse = 0; end if ( _altspelluse == nil)then _altspelluse = 0; end player:update(); if( not(distance(player.X, player.Z, player.Y,_sX,_sZ ,_sY) >_dist) )then printf("We are inside of range we try recall \n"); if( not(TransportBySpell( _altspelluse, _wpfile))) then if( _bookentry ~= nil)then printf("Recall failed we try transport by a rune \n"); if( not(TransportByTB( _altitemuse, _bookentry, _wpfile)))then if( _holdonerror == nil)then return -1; else if( _holdonerror == 1)then player:logout(); end if( _holdonerror ~= 1)then error("All tries failed to transport"); end end else return true; end end if( _holdonerror == nil)then return -1; else if( _holdonerror == 1)then player:logout(); end if( _holdonerror ~= 1)then error("All tries failed to transport"); end end else return true; end else return false; end return 0; end --[[ This function scheduele a alarm trigger. In this version it can be only one hook at the time @pre make sure you don't overwritte the time @post timer is set @arg _hour Hour to tigger @arg _minutes minutes to tigger @arg _delayhour The time(hours) until the alarm will be stop triggering. This more simpel becasue a full and real Scheduler be much more code @arg _delayminutes Same as top only minutes this time. @return nil example: hookSchedulerTime( 14,30,15,40) This will set a alarm that start at 14:30 and will go on until 15:40 ]]-- function hookSchedulerTime(_hour,_minutes, _delayhour ,_delayminutes) timetable ={hour = _hour, minutes = _minutes, dhour = _delayhour, dminutes = _delayminutes } end --[[ Check if alarm is triggerd @pre hookSchedulerTime must be set @arg _wpfile (optional) the waypointfile that should load if the alarm is on @return true if the alarm is on, false if it is not. example 1: checkScheduler("nextwp") Will load the the wp file "nextwp" if the alarm is on example 2: if(checkScheduler() == true)then alarmflag = true; end ]]-- function checkScheduler(_wpfile ) if( timetable == nil or timetable.hour == nil or timetable.minutes == nil)then print("No Time is set ignore request"); return false; end datec = os.date("*t") if datec.hour >= timetable.hour and datec.hour < (timetable.dhour) and ((datec.min >= timetable.minutes and datec.hour == timetable.hour) or datec.hour > timetable.hour) then if( datec.hour == (timetable.dhour) and not( datec.min < (timetable.dminutes ))) then return false; else if( _wpfile ~= nil )then loadPaths(_wpfile); end return true; end if( _wpfile ~= nil )then loadPaths(_wpfile); end return true; else return false; end return 0; end --[[ This function can mount your char with an different mount @pre have a mount @post mounted or dismounted @arg _dismount (optinal) if true we will dismount if false or nil we will mount @arg _numhorse (optinal) the number of your horse in your bag if nil we will use 1 @arg _holdonerror (optinal) you can choose to stop the script or logout if you use 1 the char will logout anyother value will besides nil or 1 will stop the script in chase of an error if nil or zero the function returns false @return true if it was an sucess fasle it not except you choose some other error handling with _holdonerror example : AdvancedMount( false,2,) mounted the char with mount 2te in your bag ]]-- function AdvancedMount( _dismount, _numhorse , _holdonerror ) player:updateMounted() if( _numhorse == nil)then _numhorse = 1; end if( _dismount == nil)then _dismount = false end if( (not _dismount) and player.Mounted ) then printf("Already mounted.\n"); return true; end if( _dismount == true and (not player.Mounted) ) then printf("Already dismounted.\n"); return true; end player:updateSwimming() if player.Swimming then printf("Swimming. Can't mount.\n") return true; end local mountMethod = false local mount -- Find mount if RoMScript("PartnerFrame_GetPartnerCount(2)") > 0 then -- There is a mount in the partner bag. Assign the mountmethod. mountMethod = "partner" elseif inventory then -- Make sure inventory has been mapped. inventory:update(); mount = inventory:getMount(); if mount then mountMethod = "inventory" end end -- Mount found? if(not mountMethod ) then if _holdonerror and _holdonerror ~= 0 then if _holdonerror == 1 then player:logout(); end if _holdonerror ~= 1 then error("Wasn't able to transport") end else return false; end end -- Make sure we are not battling before trying to mount if not _dismount and not (player.Current_waypoint_type == WPT_TRAVEL) then player:updateBattling(); while( player.Battling ) do if player:target(player:target(player:findEnemy(true, nil, evalTargetDefault))) then player:fight(); else break end player:updateBattling(); end end -- if _dismount and mountmethod is inventory then assume buff name equals item name and cancel buff if exists. Mainly needed for 15m and 2h mounts if _dismount == true and mountMethod == "inventory" then player:updateBuffs() for index, buff in pairs(player.Buffs) do if string.find(mount.Name,buff.Name,1, true) then sendMacro("CancelPlayerBuff("..index..");") return true; end end end -- mount/dismount if mountMethod == "partner" then RoMScript("PartnerFrame_CallPartner(2,".._numhorse..")") else mount:use() yrest(5000) end yrest(500) repeat yrest(100); player:updateCasting(); until player.Casting == false -- Just in case you mounted a different mount instead of dismounting player:updateMounted() if( (not _dismount) and not player.Mounted ) then if _holdonerror and _holdonerror ~= 0 then if _holdonerror == 1 then player:logout(); end if _holdonerror ~= 1 then error("Wasn't able to mount") end else return false; end end if _dismount == true and player.Mounted then -- second try dismount yrest(1000) if mountMethod == "partner" then RoMScript("PartnerFrame_CallPartner( 2,".._numhorse..")") else mount:use() end end if _dismount == true and player.Mounted then if _holdonerror and _holdonerror ~= 0 then if _holdonerror == 1 then player:logout(); end if _holdonerror ~= 1 then error("Wasn't able to mount") end else return false; end end yrest(500) return true; end --[[ This function can mount your char with an diffrent mount and if you havent a mount it will try to find a Temporary Mount Use Voucher or a Horse Rental Ticket to get a mount @pre have a mount or some "Temporary Mount Use Voucher or Horse Rental Ticket" to get a mount @post mounted @arg _numhorse (optinal) the number of your horse in your bag we will try if nil we will use 1 @arg _holdonerror (optinal) you can choose to stop the script or logout if you use 1 the char will logout anyother value will besides nil or 1 will stop the script in chase of an error if nil or zero the function returns false @return true if it was an sucess false it not except you choose some other error handling with _holdonerror example : SafeMount( 2,1) mounted the toon with 2te mount in your bag if failed the player logout ]]-- function SafeMount( _numhorse , _holdonerror) local starttime = os.time() repeat local mountflag; repeat mountflag = AdvancedMount(false,_numhorse); yrest(500) player:updateMounted() inventory:update(); until player.Mounted == true or (mountflag == false and mountflag ~=nil); if(mountflag == false and mountflag ~=nil and player.Mounted == false) then for i, item in pairs(inventory.BagSlot) do if(item.Id == 205821 or item.Id == 203033) then item:use(); break; end end repeat mountflag = AdvancedMount(_numhorse); player:updateMounted() inventory:update(); until player.Mounted == true or (mountflag == false and mountflag ~=nil); end until player.Mounted == true or (os.time() - starttime) > 30 if( player.Mounted == false) then if _holdonerror and _holdonerror ~= 0 then if _holdonerror == 1 then player:logout(); end if _holdonerror ~= 1 then error("Wasn't able to mount") end else return false; end else return true; end end