Advertisement
ackerzin

Untitled

Feb 19th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 18.99 KB | None | 0 0
  1. function doPlayerSetSkills(cid, value)
  2.     for i = 0, 8 do
  3.         doPlayerSetRate(cid, i, value)
  4.     end
  5. end
  6. InitArenaScript = 0
  7. arena_room_max_time = 240
  8. arenaKickPosition = {x=32222, y=31080, z=6}
  9. arena_monsters = {}
  10. arena_monsters[42300] = 'frostfur' -- first monster from 1 arena
  11. arena_monsters[42301] = 'bloodpaw'
  12. arena_monsters[42302] = 'bovinus'
  13. arena_monsters[42303] = 'achad'
  14. arena_monsters[42304] = 'colerian the barbarian'
  15. arena_monsters[42305] = 'the hairy one'
  16. arena_monsters[42306] = 'axeitus headbanger'
  17. arena_monsters[42307] = 'rocky'
  18. arena_monsters[42308] = 'cursed gladiator'
  19. arena_monsters[42309] = 'orcus the cruel'
  20. arena_monsters[42310] = 'avalanche' -- first monster from 2 arena
  21. arena_monsters[42311] = 'kreebosh the exile'
  22. arena_monsters[42312] = 'the dark dancer'
  23. arena_monsters[42313] = 'the hag'
  24. arena_monsters[42314] = 'slim'
  25. arena_monsters[42315] = 'grimgor guteater'
  26. arena_monsters[42316] = 'drasilla'
  27. arena_monsters[42317] = 'spirit of earth'
  28. arena_monsters[42318] = 'spirit of water'
  29. arena_monsters[42319] = 'spirit of fire'
  30. arena_monsters[42320] = 'webster' -- first monster from 3 arena
  31. arena_monsters[42321] = 'darakan the executioner'
  32. arena_monsters[42322] = 'norgle glacierbeard'
  33. arena_monsters[42323] = 'the pit lord'
  34. arena_monsters[42324] = 'svoren the mad'
  35. arena_monsters[42325] = 'the masked marauder'
  36. arena_monsters[42326] = 'gnorre chyllson'
  37. arena_monsters[42327] = "fallen mooh'tah master ghar"
  38. arena_monsters[42328] = 'deathbringer'
  39. arena_monsters[42329] = 'the obliverator'
  40.  
  41. function getArenaMonsterIdByName(name)
  42.     name = string.lower(tostring(name))
  43.     for i = 42300, 42329 do
  44.         if tostring(arena_monsters[i]) == name then
  45.             return i
  46.         end
  47.     end
  48.     return 0
  49. end
  50.  
  51. function doPlayerGiveItem(cid, itemid, amount, subType)
  52.     local item = 0
  53.     if(isItemStackable(itemid)) then
  54.         item = doCreateItemEx(itemid, amount)
  55.         if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
  56.             return false
  57.         end
  58.     else
  59.         for i = 1, amount do
  60.             item = doCreateItemEx(itemid, subType)
  61.             if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
  62.                 return false
  63.             end
  64.         end
  65.     end
  66.  
  67.     return true
  68. end
  69.  
  70. function doPlayerGiveItem(cid, itemid, amount, subType)
  71.     local item = 0
  72.     if(isItemStackable(itemid)) then
  73.         item = doCreateItemEx(itemid, amount)
  74.         if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
  75.             return false
  76.         end
  77.     else
  78.         for i = 1, amount do
  79.             item = doCreateItemEx(itemid, subType)
  80.             if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
  81.                 return false
  82.             end
  83.         end
  84.     end
  85.  
  86.     return true
  87. end
  88.  
  89. function doPlayerGiveItemContainer(cid, containerid, itemid, amount, subType)
  90.     for i = 1, amount do
  91.         local container = doCreateItemEx(containerid, 1)
  92.         for x = 1, getContainerCapById(containerid) do
  93.             doAddContainerItem(container, itemid, subType)
  94.         end
  95.  
  96.         if(doPlayerAddItemEx(cid, container, true) ~= RETURNVALUE_NOERROR) then
  97.             return false
  98.         end
  99.     end
  100.  
  101.     return true
  102. end
  103.  
  104. function doPlayerTakeItem(cid, itemid, amount)
  105.     return getPlayerItemCount(cid, itemid) >= amount and doPlayerRemoveItem(cid, itemid, amount)
  106. end
  107.  
  108. function doPlayerBuyItem(cid, itemid, count, cost, charges)
  109.     return doPlayerRemoveMoney(cid, cost) and doPlayerGiveItem(cid, itemid, count, charges)
  110. end
  111.  
  112. function doPlayerBuyItemContainer(cid, containerid, itemid, count, cost, charges)
  113.     return doPlayerRemoveMoney(cid, cost) and doPlayerGiveItemContainer(cid, containerid, itemid, count, charges)
  114. end
  115.  
  116. function doPlayerSellItem(cid, itemid, count, cost)
  117.     if(not doPlayerTakeItem(cid, itemid, count)) then
  118.         return false
  119.     end
  120.  
  121.     if(not doPlayerAddMoney(cid, cost)) then
  122.         error('[doPlayerSellItem] Could not add money to: ' .. getPlayerName(cid) .. ' (' .. cost .. 'gp).')
  123.     end
  124.  
  125.     return true
  126. end
  127.  
  128. function doPlayerWithdrawMoney(cid, amount)
  129.     if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
  130.         return false
  131.     end
  132.  
  133.     local balance = getPlayerBalance(cid)
  134.     if(amount > balance or not doPlayerAddMoney(cid, amount)) then
  135.         return false
  136.     end
  137.  
  138.     doPlayerSetBalance(cid, balance - amount)
  139.     return true
  140. end
  141.  
  142. function doPlayerDepositMoney(cid, amount)
  143.     if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
  144.         return false
  145.     end
  146.  
  147.     if(not doPlayerRemoveMoney(cid, amount)) then
  148.         return false
  149.     end
  150.  
  151.     doPlayerSetBalance(cid, getPlayerBalance(cid) + amount)
  152.     return true
  153. end
  154.  
  155. function doPlayerAddStamina(cid, minutes)
  156.     return doPlayerSetStamina(cid, getPlayerStamina(cid) + minutes)
  157. end
  158.  
  159. function isPremium(cid)
  160.     return (isPlayer(cid) and (getPlayerPremiumDays(cid) > 0 or getBooleanFromString(getConfigValue('freePremium'))))
  161. end
  162.  
  163. function getMonthDayEnding(day)
  164.     if(day == "01" or day == "21" or day == "31") then
  165.         return "st"
  166.     elseif(day == "02" or day == "22") then
  167.         return "nd"
  168.     elseif(day == "03" or day == "23") then
  169.         return "rd"
  170.     end
  171.  
  172.     return "th"
  173. end
  174.  
  175. function getMonthString(m)
  176.     return os.date("%B", os.time{year = 1970, month = m, day = 1})
  177. end
  178.  
  179. function getArticle(str)
  180.     return str:find("[AaEeIiOoUuYy]") == 1 and "an" or "a"
  181. end
  182.  
  183. function isNumeric(str)
  184.     return tonumber(str) ~= nil
  185. end
  186.  
  187. function doNumberFormat(i)
  188.     local str, found = string.gsub(i, "(%d)(%d%d%d)$", "%1,%2", 1), 0
  189.     repeat
  190.         str, found = string.gsub(str, "(%d)(%d%d%d),", "%1,%2,", 1)
  191.     until found == 0
  192.     return str
  193. end
  194.  
  195. function doPlayerAddAddons(cid, addon)
  196.     for i = 0, table.maxn(maleOutfits) do
  197.         doPlayerAddOutfit(cid, maleOutfits[i], addon)
  198.     end
  199.  
  200.     for i = 0, table.maxn(femaleOutfits) do
  201.         doPlayerAddOutfit(cid, femaleOutfits[i], addon)
  202.     end
  203. end
  204.  
  205. function doPlayerWithdrawAllMoney(cid)
  206.     return doPlayerWithdrawMoney(cid, getPlayerBalance(cid))
  207. end
  208.  
  209. function doPlayerDepositAllMoney(cid)
  210.     return doPlayerDepositMoney(cid, getPlayerMoney(cid))
  211. end
  212.  
  213. function doPlayerTransferAllMoneyTo(cid, target)
  214.     return doPlayerTransferMoneyTo(cid, target, getPlayerBalance(cid))
  215. end
  216.  
  217. function playerExists(name)
  218.     return getPlayerGUIDByName(name) ~= nil
  219. end
  220.  
  221. function getTibiaTime()
  222.     local minutes, hours = getWorldTime(), 0
  223.     while (minutes > 60) do
  224.         hours = hours + 1
  225.         minutes = minutes - 60
  226.     end
  227.  
  228.     return {hours = hours, minutes = minutes}
  229. end
  230.  
  231. function doWriteLogFile(file, text)
  232.     local f = io.open(file, "a+")
  233.     if(not f) then
  234.         return false
  235.     end
  236.  
  237.     f:write("[" .. os.date("%d/%m/%Y %H:%M:%S") .. "] " .. text .. "\n")
  238.     f:close()
  239.     return true
  240. end
  241.  
  242. function getExperienceForLevel(lv)
  243.     lv = lv - 1
  244.     return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
  245. end
  246.  
  247. function doMutePlayer(cid, time)
  248.     local condition = createConditionObject(CONDITION_MUTED)
  249.     setConditionParam(condition, CONDITION_PARAM_TICKS, time == -1 and time or time * 1000)
  250.     return doAddCondition(cid, condition)
  251. end
  252.  
  253. function getPlayerGroupName(cid)
  254.     return getGroupInfo(getPlayerGroupId(cid)).name
  255. end
  256.  
  257. function getPlayerVocationName(cid)
  258.     return getVocationInfo(getPlayerVocation(cid)).name
  259. end
  260.  
  261. function getPromotedVocation(vid)
  262.     return getVocationInfo(vid).promotedVocation
  263. end
  264.  
  265. function doPlayerRemovePremiumDays(cid, days)
  266.     return doPlayerAddPremiumDays(cid, -days)
  267. end
  268.  
  269. function getPlayerMasterPos(cid)
  270.     return getTownTemplePosition(getPlayerTown(cid))
  271. end
  272.  
  273. function getHouseOwner(houseId)
  274.     return getHouseInfo(houseId).owner
  275. end
  276.  
  277. function getHouseName(houseId)
  278.     return getHouseInfo(houseId).name
  279. end
  280.  
  281. function getHouseEntry(houseId)
  282.     return getHouseInfo(houseId).entry
  283. end
  284.  
  285. function getHouseRent(houseId)
  286.     return getHouseInfo(houseId).rent
  287. end
  288.  
  289. function getHousePrice(houseId)
  290.     return getHouseInfo(houseId).price
  291. end
  292.  
  293. function getHouseTown(houseId)
  294.     return getHouseInfo(houseId).town
  295. end
  296.  
  297. function getHouseDoorsCount(houseId)
  298.     return table.maxn(getHouseInfo(houseId).doors)
  299. end
  300.  
  301. function getHouseBedsCount(houseId)
  302.     return table.maxn(getHouseInfo(houseId).beds)
  303. end
  304.  
  305. function getHouseTilesCount(houseId)
  306.     return table.maxn(getHouseInfo(houseId).tiles)
  307. end
  308.  
  309. function getItemNameById(itemid)
  310.     return getItemDescriptionsById(itemid).name
  311. end
  312.  
  313. function getItemPluralNameById(itemid)
  314.     return getItemDescriptionsById(itemid).plural
  315. end
  316.  
  317. function getItemArticleById(itemid)
  318.     return getItemDescriptionsById(itemid).article
  319. end
  320.  
  321. function getItemName(uid)
  322.     return getItemDescriptions(uid).name
  323. end
  324.  
  325. function getItemPluralName(uid)
  326.     return getItemDescriptions(uid).plural
  327. end
  328.  
  329. function getItemArticle(uid)
  330.     return getItemDescriptions(uid).article
  331. end
  332.  
  333. function getItemText(uid)
  334.     return getItemDescriptions(uid).text
  335. end
  336.  
  337. function getItemSpecialDescription(uid)
  338.     return getItemDescriptions(uid).special
  339. end
  340.  
  341. function getItemWriter(uid)
  342.     return getItemDescriptions(uid).writer
  343. end
  344.  
  345. function getItemDate(uid)
  346.     return getItemDescriptions(uid).date
  347. end
  348.  
  349. function getTilePzInfo(pos)
  350.     return getTileInfo(pos).protection
  351. end
  352.  
  353. function getTileZoneInfo(pos)
  354.     local tmp = getTileInfo(pos)
  355.     if(tmp.pvp) then
  356.         return 2
  357.     end
  358.  
  359.     if(tmp.nopvp) then
  360.         return 1
  361.     end
  362.  
  363.     return 0
  364. end
  365.  
  366. function doShutdown()
  367.     return doSetGameState(GAMESTATE_SHUTDOWN)
  368. end
  369.  
  370. function doSummonCreature(name, pos, displayError)
  371.     local displayError, cid = displayError or true, doCreateMonster(name, pos, displayError)
  372.     if(not cid) then
  373.         cid = doCreateNpc(name, pos, displayError)
  374.     end
  375.  
  376.     return cid
  377. end
  378.  
  379. function getOnlinePlayers()
  380.     local players = {}
  381.     for i, cid in ipairs(getPlayersOnline()) do
  382.         table.insert(players, getCreatureName(cid))
  383.     end
  384.  
  385.     return players
  386. end
  387.  
  388. function getPlayerByName(name)
  389.     local cid = getCreatureByName(name)
  390.     return isPlayer(cid) and cid or nil
  391. end
  392.  
  393. function isPlayer(cid)
  394.     return isCreature(cid) and cid >= AUTOID_PLAYERS and cid < AUTOID_MONSTERS
  395. end
  396.  
  397. function isPlayerGhost(cid)
  398.     return isPlayer(cid) and (getCreatureCondition(cid, CONDITION_GAMEMASTER, GAMEMASTER_INVISIBLE) or getPlayerFlagValue(cid, PLAYERFLAG_CANNOTBESEEN))
  399. end
  400.  
  401. function isMonster(cid)
  402.     return isCreature(cid) and cid >= AUTOID_MONSTERS and cid < AUTOID_NPCS
  403. end
  404.  
  405. function isNpc(cid)
  406.     return isCreature(cid) and cid >= AUTOID_NPCS
  407. end
  408.  
  409. function doPlayerSetExperienceRate(cid, value)
  410.     return doPlayerSetRate(cid, SKILL__LEVEL, value)
  411. end
  412.  
  413. function doPlayerSetMagicRate(cid, value)
  414.     return doPlayerSetRate(cid, SKILL__MAGLEVEL, value)
  415. end
  416.  
  417. function doPlayerAddLevel(cid, amount, round)
  418.     local experience, level, amount = 0, getPlayerLevel(cid), amount or 1
  419.     if(amount > 0) then
  420.         experience = getExperienceForLevel(level + amount) - (round and getPlayerExperience(cid) or getExperienceForLevel(level))
  421.     else
  422.         experience = -((round and getPlayerExperience(cid) or getExperienceForLevel(level)) - getExperienceForLevel(level + amount))
  423.     end
  424.  
  425.     return doPlayerAddExperience(cid, experience)
  426. end
  427.  
  428. function doPlayerAddMagLevel(cid, amount)
  429.     for i = 1, amount do
  430.         doPlayerAddSpentMana(cid, getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid), false)
  431.     end
  432.  
  433.     return true
  434. end
  435.  
  436. function doPlayerAddSkill(cid, skill, amount, round)
  437.     local amount = amount or 1
  438.     if(skill == SKILL__LEVEL) then
  439.         return doPlayerAddLevel(cid, amount, round)
  440.     elseif(skill == SKILL__MAGLEVEL) then
  441.         return doPlayerAddMagLevel(cid, amount)
  442.     end
  443.  
  444.     for i = 1, amount do
  445.         doPlayerAddSkillTry(cid, skill, getPlayerRequiredSkillTries(cid, skill, getPlayerSkillLevel(cid, skill) + 1) - getPlayerSkillTries(cid, skill), false)
  446.     end
  447.  
  448.     return true
  449. end
  450.  
  451. function getPartyLeader(cid)
  452.     local party = getPartyMembers(cid)
  453.     if(type(party) ~= 'table') then
  454.         return 0
  455.     end
  456.  
  457.     return party[1]
  458. end
  459.  
  460. function isInParty(cid)
  461.     return type(getPartyMembers(cid)) == 'table'
  462. end
  463.  
  464. function isPrivateChannel(channelId)
  465.     return channelId >= CHANNEL_PRIVATE
  466. end
  467.  
  468. function doPlayerResetIdleTime(cid)
  469.     return doPlayerSetIdleTime(cid, 0)
  470. end
  471.  
  472. function doBroadcastMessage(text, class)
  473.     local class = class or MESSAGE_STATUS_WARNING
  474.     if(type(class) == 'string') then
  475.         local className = MESSAGE_TYPES[class]
  476.         if(className == nil) then
  477.             return false
  478.         end
  479.  
  480.         class = className
  481.     elseif(class < MESSAGE_FIRST or class > MESSAGE_LAST) then
  482.         return false
  483.     end
  484.  
  485.     for _, pid in ipairs(getPlayersOnline()) do
  486.         doPlayerSendTextMessage(pid, class, text)
  487.     end
  488.  
  489.     print("> Broadcasted message: \"" .. text .. "\".")
  490.     return true
  491. end
  492.  
  493. function doPlayerBroadcastMessage(cid, text, class, checkFlag, ghost)
  494.     local checkFlag, ghost, class = checkFlag or true, ghost or false, class or TALKTYPE_BROADCAST
  495.     if(checkFlag and not getPlayerFlagValue(cid, PLAYERFLAG_CANBROADCAST)) then
  496.         return false
  497.     end
  498.  
  499.     if(type(class) == 'string') then
  500.         local className = TALKTYPE_TYPES[class]
  501.         if(className == nil) then
  502.             return false
  503.         end
  504.  
  505.         class = className
  506.     elseif(class < TALKTYPE_FIRST or class > TALKTYPE_LAST) then
  507.         return false
  508.     end
  509.  
  510.     for _, pid in ipairs(getPlayersOnline()) do
  511.         doCreatureSay(cid, text, class, ghost, pid)
  512.     end
  513.  
  514.     print("> " .. getCreatureName(cid) .. " broadcasted message: \"" .. text .. "\".")
  515.     return true
  516. end
  517.  
  518. function getBooleanFromString(input)
  519.     local tmp = type(input)
  520.     if(tmp == 'boolean') then
  521.         return input
  522.     end
  523.  
  524.     if(tmp == 'number') then
  525.         return input > 0
  526.     end
  527.  
  528.     local str = string.lower(tostring(input))
  529.     return (str == "yes" or str == "true" or (tonumber(str) ~= nil and tonumber(str) > 0))
  530. end
  531.  
  532. function doCopyItem(item, attributes)
  533.     local attributes = ((type(attributes) == 'table') and attributes or { "aid" })
  534.  
  535.     local ret = doCreateItemEx(item.itemid, item.type)
  536.     for _, key in ipairs(attributes) do
  537.         local value = getItemAttribute(item.uid, key)
  538.         if(value ~= nil) then
  539.             doItemSetAttribute(ret, key, value)
  540.         end
  541.     end
  542.  
  543.     if(isContainer(item.uid)) then
  544.         for i = (getContainerSize(item.uid) - 1), 0, -1 do
  545.             local tmp = getContainerItem(item.uid, i)
  546.             if(tmp.itemid > 0) then
  547.                 doAddContainerItemEx(ret, doCopyItem(tmp, true).uid)
  548.             end
  549.         end
  550.     end
  551.  
  552.     return getThing(ret)
  553. end
  554.  
  555. function doRemoveThing(uid)
  556.     if(isCreature(uid)) then
  557.         return doRemoveCreature(uid)
  558.     end
  559.  
  560.     return doRemoveItem(uid)
  561. end
  562.  
  563. function setAttackFormula(combat, type, minl, maxl, minm, maxm, min, max)
  564.     local min, max = min or 0, max or 0
  565.     return setCombatFormula(combat, type, -1, 0, -1, 0, minl, maxl, minm, maxm, -min, -max)
  566. end
  567.  
  568. function setHealingFormula(combat, type, minl, maxl, minm, maxm, min, max)
  569.     local min, max = min or 0, max or 0
  570.     return setCombatFormula(combat, type, 1, 0, 1, 0, minl, maxl, minm, maxm, min, max)
  571. end
  572.  
  573. function doChangeTypeItem(uid, subtype)
  574.     local thing = getThing(uid)
  575.     if(thing.itemid < 100) then
  576.         return false
  577.     end
  578.  
  579.     local subtype = subtype or 1
  580.     return doTransformItem(thing.uid, thing.itemid, subtype)
  581. end
  582.  
  583. function doSetItemText(uid, text, writer, date)
  584.     local thing = getThing(uid)
  585.     if(thing.itemid < 100) then
  586.         return false
  587.     end
  588.  
  589.     doItemSetAttribute(uid, "text", text)
  590.     if(writer ~= nil) then
  591.         doItemSetAttribute(uid, "writer", tostring(writer))
  592.         if(date ~= nil) then
  593.             doItemSetAttribute(uid, "date", tonumber(date))
  594.         end
  595.     end
  596.  
  597.     return true
  598. end
  599.  
  600. function doItemSetActionId(uid, aid)
  601.     return doItemSetAttribute(uid, "aid", aid)
  602. end
  603.  
  604. function getFluidSourceType(itemid)
  605.     local item = getItemInfo(itemid)
  606.     return item and item.fluidSource or false
  607. end
  608.  
  609. function getDepotId(uid)
  610.     return getItemAttribute(uid, "depotid") or false
  611. end
  612.  
  613. function getItemDescriptions(uid)
  614.     local thing = getThing(uid)
  615.     if(thing.itemid < 100) then
  616.         return false
  617.     end
  618.  
  619.     local item = getItemInfo(thing.itemid)
  620.     return {
  621.         name = getItemAttribute(uid, "name") or item.name,
  622.         plural = getItemAttribute(uid, "pluralname") or item.plural,
  623.         article = getItemAttribute(uid, "article") or item.article,
  624.         special = getItemAttribute(uid, "description") or "",
  625.         text = getItemAttribute(uid, "text") or "",
  626.         writer = getItemAttribute(uid, "writer") or "",
  627.         date = getItemAttribute(uid, "date") or 0
  628.     }
  629. end
  630.  
  631. function getItemWeightById(itemid, count, precision)
  632.     local item, count, precision = getItemInfo(itemid), count or 1, precision or false
  633.     if(not item) then
  634.         return false
  635.     end
  636.  
  637.     if(count > 100) then
  638.         -- print a warning, as its impossible to have more than 100 stackable items without "cheating" the count
  639.         print('[Warning] getItemWeightById', 'Calculating weight for more than 100 items!')
  640.     end
  641.  
  642.     local weight = item.weight * count
  643.     --[[if(precision) then
  644.         return weight
  645.     end
  646.  
  647.     local t = string.explode(tostring(weight), ".")
  648.     if(table.maxn(t) == 2) then
  649.         return tonumber(t[1] .. "." .. string.sub(t[2], 1, 2))
  650.     end]]--
  651.  
  652.     return weight
  653. end
  654.  
  655. function getItemWeaponType(uid)
  656.     local thing = getThing(uid)
  657.     if(thing.itemid < 100) then
  658.         return false
  659.     end
  660.  
  661.     return getItemInfo(thing.itemid).weaponType
  662. end
  663.  
  664. function getItemRWInfo(uid)
  665.     local thing = getThing(uid)
  666.     if(thing.itemid < 100) then
  667.         return false
  668.     end
  669.  
  670.     local item, flags = getItemInfo(thing.itemid), 0
  671.     if(item.readable) then
  672.         flags = 1
  673.     end
  674.  
  675.     if(item.writable) then
  676.         flags = flags + 2
  677.     end
  678.  
  679.     return flags
  680. end
  681.  
  682. function getItemLevelDoor(itemid)
  683.     local item = getItemInfo(itemid)
  684.     return item and item.levelDoor or false
  685. end
  686.  
  687. function isItemStackable(itemid)
  688.     local item = getItemInfo(itemid)
  689.     return item and item.stackable or false
  690. end
  691.  
  692. function isItemRune(itemid)
  693.     local item = getItemInfo(itemid)
  694.     return item and item.type == ITEM_TYPE_RUNE or false
  695. end
  696.  
  697. function isItemDoor(itemid)
  698.     local item = getItemInfo(itemid)
  699.     return item and item.type == ITEM_TYPE_DOOR or false
  700. end
  701.  
  702. function isItemContainer(itemid)
  703.     local item = getItemInfo(itemid)
  704.     return item and item.group == ITEM_GROUP_CONTAINER or false
  705. end
  706.  
  707. function isItemFluidContainer(itemid)
  708.     local item = getItemInfo(itemid)
  709.     return item and item.group == ITEM_GROUP_FLUID or false
  710. end
  711.  
  712. function isItemMovable(itemid)
  713.     local item = getItemInfo(itemid)
  714.     return item and item.movable or false
  715. end
  716.  
  717. function isCorpse(uid)
  718.     local thing = getThing(uid)
  719.     if(thing.itemid < 100) then
  720.         return false
  721.     end
  722.  
  723.     local item = getItemInfo(thing.itemid)
  724.     return item and item.corpseType ~= 0 or false
  725. end
  726.  
  727. function getContainerCapById(itemid)
  728.     local item = getItemInfo(itemid)
  729.     if(not item or item.group ~= 2) then
  730.         return false
  731.     end
  732.  
  733.     return item.maxItems
  734. end
  735.  
  736. function getMonsterAttackSpells(name)
  737.     local monster = getMonsterInfo(name)
  738.     return monster and monster.attacks or false
  739. end
  740.  
  741. function getMonsterHealingSpells(name)
  742.     local monster = getMonsterInfo(name)
  743.     return monster and monster.defenses or false
  744. end
  745.  
  746. function getMonsterLootList(name)
  747.     local monster = getMonsterInfo(name)
  748.     return monster and monster.loot or false
  749. end
  750.  
  751. function getMonsterSummonList(name)
  752.     local monster = getMonsterInfo(name)
  753.     return monster and monster.summons or false
  754. end
  755.  
  756. function choose(...)
  757.     local arg = {...}
  758.     return arg[math.random(1, table.maxn(arg))]
  759. end
  760.  
  761. function isSummon(cid)
  762.     return getCreatureMaster(cid) ~= nil
  763. end
  764.  
  765. function getPlayerInArea(fromPos, toPos) -- by jhon992
  766. local online = getPlayersOnline()
  767. local players = {}
  768. for i=1, #online do
  769.     if isInArea(getPlayerPosition(online[i]), fromPos, toPos) then
  770.         players[#players+1] = online[i]
  771.     end
  772. end
  773. return players
  774. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement