Advertisement
Guest User

global.lua

a guest
Feb 4th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 9.14 KB | None | 0 0
  1. dofile('data/lib/libs.lua')
  2.  
  3. ropeSpots = {384, 418, 8278, 8592, 13189, 14435, 14436, 15635, 19518, 26019}
  4.  
  5. doors = {
  6.     [1209] = 1211, [1210] = 1211, [1212] = 1214, [1213] = 1214, [1219] = 1220, [1221] = 1222, [1231] = 1233, [1232] = 1233, [1234] = 1236,
  7.     [1235] = 1236, [1237] = 1238, [1239] = 1240, [1249] = 1251, [1250] = 1251, [1252] = 1254, [1253] = 1254, [1539] = 1540, [1541] = 1542,
  8.     [3535] = 3537, [3536] = 3537, [3538] = 3539, [3544] = 3546, [3545] = 3546, [3547] = 3548, [4913] = 4915, [4914] = 4915, [4916] = 4918,
  9.     [4917] = 4918, [5082] = 5083, [5084] = 5085, [5098] = 5100, [5099] = 5100, [5101] = 5102, [5107] = 5109, [5108] = 5109, [5110] = 5111,
  10.     [5116] = 5118, [5117] = 5118, [5119] = 5120, [5125] = 5127, [5126] = 5127, [5128] = 5129, [5134] = 5136, [5135] = 5136, [5137] = 5139,
  11.     [5138] = 5139, [5140] = 5142, [5141] = 5142, [5143] = 5145, [5144] = 5145, [5278] = 5280, [5279] = 5280, [5281] = 5283, [5282] = 5283,
  12.     [5284] = 5285, [5286] = 5287, [5515] = 5516, [5517] = 5518, [5732] = 5734, [5733] = 5734, [5735] = 5737, [5736] = 5737, [6192] = 6194,
  13.     [6193] = 6194, [6195] = 6197, [6196] = 6197, [6198] = 6199, [6200] = 6201, [6249] = 6251, [6250] = 6251, [6252] = 6254, [6253] = 6254,
  14.     [6255] = 6256, [6257] = 6258, [6795] = 6796, [6797] = 6798, [6799] = 6800, [6801] = 6802, [6891] = 6893, [6892] = 6893, [6894] = 6895,
  15.     [6900] = 6902, [6901] = 6902, [6903] = 6904, [7033] = 7035, [7034] = 7035, [7036] = 7037, [7042] = 7044, [7043] = 7044, [7045] = 7046,
  16.     [7054] = 7055, [7056] = 7057, [8541] = 8543, [8542] = 8543, [8544] = 8546, [8545] = 8546, [8547] = 8548, [8549] = 8550, [9165] = 9167,
  17.     [9166] = 9167, [9168] = 9170, [9169] = 9170, [9171] = 9172, [9173] = 9174, [9267] = 9269, [9268] = 9269, [9270] = 9272, [9271] = 9272,
  18.     [9273] = 9274, [9275] = 9276, [10276] = 10277, [10274] = 10275, [10268] = 10270, [10269] = 10270, [10271] = 10273, [10272] = 10273, [10471] = 10472,
  19.     [10480] = 10481, [10477] = 10479, [10478] = 10479, [10468] = 10470, [10469] = 10470, [10775] = 10777, [10776] = 10777, [12092] = 12094, [12093] = 12094,
  20.     [12188] = 12190, [12189] = 12190, [19840] = 19842, [19841] = 19842, [19843] = 19844, [19980] = 19982, [19981] = 19982, [19983] = 19984, [20273] = 20275,
  21.     [20274] = 20275, [20276] = 20277, [17235] = 17236, [18208] = 18209, [13022] = 13023, [10784] = 10786, [10785] = 10786, [12099] = 12101, [12100] = 12101,
  22.     [12197] = 12199, [12198] = 12199, [19849] = 19851, [19850] = 19851, [19852] = 19853, [19989] = 19991, [19990] = 19991, [19992] = 19993, [20282] = 20284,
  23.     [20283] = 20284, [20285] = 20286, [17237] = 17238, [13020] = 13021, [10780] = 10781, [12095] = 12096, [12195] = 12196, [19845] = 19846, [19985] = 19986,
  24.     [20278] = 20279, [10789] = 10790, [12102] = 12103, [12204] = 12205, [19854] = 19855, [19994] = 19995, [20287] = 20288, [10782] = 10783, [12097] = 12098,
  25.     [12193] = 12194, [19847] = 19848, [19987] = 19988, [20280] = 20281, [10791] = 10792, [12104] = 12105, [12202] = 12203, [19856] = 19857, [19996] = 19997,
  26.     [20289] = 20290, [22814] = 22815, [22815] = 22816, [22817] = 22818, [22819] = 22820, [22823] = 22825, [22824] = 22825, [22826] = 22827, [22828] = 22829
  27. }
  28.  
  29. verticalOpenDoors = {
  30.     1211, 1220, 1224, 1228, 1233, 1238, 1242, 1246, 1251, 1256, 1260, 1540, 3546, 3548, 3550, 3552, 4915, 5083, 5109, 5111, 5113, 5115, 5127, 5129, 5131,
  31.     5133, 5142, 5145, 5283, 5285, 5289, 5293, 5516, 5737, 5749, 6194, 6199, 6203, 6207, 6251, 6256, 6260, 6264, 6798, 6802, 6902, 6904, 6906, 6908, 7044,
  32.     7046, 7048, 7050, 7055, 8543, 8548, 8552, 8556, 9167, 9172, 9269, 9274, 9274, 9269, 9278, 9282, 10270, 10275, 10279, 10283, 10479, 10481, 10485, 10483,
  33.     10786, 12101, 12199, 19851, 19853, 19991, 19993, 20284, 20286, 17238, 13021, 10790, 12103, 12205, 19855, 19995, 20288, 10792, 12105, 12203, 19857, 19997,
  34.     20290, 22825, 22827, 22829, 22831
  35. }
  36.  
  37. horizontalOpenDoors = {
  38.     1214, 1222, 1226, 1230, 1236, 1240, 1244, 1248, 1254, 1258, 1262, 1542, 3537, 3539, 3541, 3543, 4918, 5085, 5100, 5102, 5104, 5106, 5118,
  39.     5120, 5122, 5124, 5136, 5139, 5280, 5287, 5291, 5295, 5518, 5734, 5746, 6197, 6201, 6205, 6209, 6254, 6258, 6262, 6266, 6796, 6800, 6893,
  40.     6895, 6897, 6899, 7035, 7037, 7039, 7041, 7057, 8546, 8550, 8554, 8558, 9170, 9174, 9272, 9276, 9280, 9284, 10273, 10277, 10281, 10285,
  41.     10470, 10472, 10476, 10474, 10777, 12094, 12190, 19842, 19844, 19982, 19984, 20275, 20277, 17236, 18209, 13023, 10781, 12096, 12196,
  42.     19846, 19986, 20279, 10783, 12098, 12194, 19848, 19988, 20281, 22816, 22818, 22820, 22822
  43. }
  44.  
  45. openSpecialDoors = {
  46.     1224, 1226, 1228, 1230, 1242, 1244, 1246, 1248, 1256, 1258, 1260, 1262, 3541, 3543, 3550, 3552, 5104, 5106, 5113, 5115, 5122, 5124, 5131, 5133,
  47.     5289, 5291, 5293, 5295, 6203, 6205, 6207, 6209, 6260, 6262, 6264, 6266, 6897, 6899, 6906, 6908, 7039, 7041, 7048, 7050, 8552, 8554, 8556, 8558,
  48.     9176, 9178, 9180, 9182, 9278, 9280, 9282, 9284, 10279, 10281, 10283, 10285, 10474, 10476, 10483, 10485, 10781, 12096, 12196, 19846, 19986, 20279,
  49.     10783, 12098, 12194, 19848, 19988, 20281, 10790, 12103, 12205, 19855, 19995, 20288, 10792, 12105, 12203, 19857, 19997, 20290
  50. }
  51.  
  52. questDoors = {
  53.     1223, 1225, 1241, 1243, 1255, 1257, 3542, 3551, 5105, 5114, 5123, 5132, 5288, 5290, 5745, 5748, 6202, 6204, 6259, 6261, 6898, 6907, 7040, 7049,
  54.     8551, 8553, 9175,9177, 9277, 9279, 10278, 10280, 10475, 10484, 10782, 12097, 19847, 19987, 20280, 10791, 12104, 12204, 12195, 19856, 19996, 20289,
  55.     22821, 22830
  56. }
  57.  
  58. levelDoors = {
  59.     1227, 1229, 1245, 1247, 1259, 1261, 3540, 3549, 5103, 5112, 5121, 5130, 5292, 5294, 6206, 6208, 6263, 6265, 6896, 6905, 7038, 7047, 8555, 8557,9179, 9181,
  60.     9281, 9283, 10282, 10284, 10473, 10482, 10780, 10789, 10780, 12095, 12195, 19845, 19985, 20278, 10789, 12102, 12193, 12202, 19854, 19994, 20287
  61. }
  62.  
  63. keys = {2086, 2087, 2088, 2089, 2090, 2091, 2092, 10032}
  64.  
  65. function doCreatureSayWithRadius(cid, text, type, radiusx, radiusy, position)
  66.     if not position then
  67.         position = Creature(cid):getPosition()
  68.     end
  69.  
  70.     local spectators, spectator = Game.getSpectators(position, false, true, radiusx, radiusx, radiusy, radiusy)
  71.     for i = 1, #spectators do
  72.         spectator = spectators[i]
  73.         spectator:say(text, type, false, spectator, position)
  74.     end
  75. end
  76.  
  77. function getBlessingsCost(level)
  78.     if level <= 30 then
  79.         return 2000
  80.     elseif level >= 120 then
  81.         return 20000
  82.     else
  83.         return (level - 20) * 200
  84.     end
  85. end
  86.  
  87. function logCommand(player, words, param)
  88.     local file = io.open("data/logs/"..player:getName()".log", "a+")
  89.     file:write(("[ %s ] %s%s\n"):format(os.date(), words, (param ~= "" and " " or "") .. param))
  90.     file:flush()
  91.     file:close()
  92.     return true
  93. end
  94.  
  95. function getPvpBlessingCost(level)
  96.     if level <= 30 then
  97.         return 2000
  98.     elseif level >= 270 then
  99.         return 50000
  100.     else
  101.         return (level - 20) * 200
  102.     end
  103. end
  104.  
  105. function isInRange(pos, fromPos, toPos)
  106.     return pos.x >= fromPos.x and pos.y >= fromPos.y and pos.z >= fromPos.z and pos.x <= toPos.x and pos.y <= toPos.y and pos.z <= toPos.z
  107. end
  108.  
  109. function isNumber(str)
  110.     return tonumber(str) ~= nil
  111. end
  112.  
  113. function getTibianTime()
  114.     local worldTime = getWorldTime()
  115.     local hours = math.floor(worldTime / 60)
  116.  
  117.     local minutes = worldTime % 60
  118.     if minutes < 10 then
  119.         minutes = '0' .. minutes
  120.     end
  121.     return hours .. ':' .. minutes
  122. end
  123.  
  124. -- Stamina
  125. if nextUseStaminaTime == nil then
  126.     nextUseStaminaTime = {}
  127. end
  128.  
  129.  
  130. -- CASAMENTO MARRY
  131.  
  132. PROPOSED_STATUS = 1
  133. MARRIED_STATUS = 2
  134. PROPACCEPT_STATUS = 3
  135. LOOK_MARRIAGE_DESCR = TRUE
  136. ITEM_WEDDING_RING = 2121
  137. ITEM_ENGRAVED_WEDDING_RING = 10502
  138.  
  139. function getPlayerSpouse(id)
  140.    local resultQuery = db.storeQuery("SELECT `marriage_spouse` FROM `players` WHERE `id` = " .. db.escapeString(id))
  141.    if resultQuery ~= false then
  142.        local ret = result.getDataInt(resultQuery, "marriage_spouse")
  143.        result.free(resultQuery)
  144.        return ret
  145.    end
  146.    return -1
  147. end
  148.  
  149. function setPlayerSpouse(id, val)
  150.    db.query("UPDATE `players` SET `marriage_spouse` = " .. val .. " WHERE `id` = " .. id)
  151. end
  152.  
  153. function getPlayerMarriageStatus(id)
  154.    local resultQuery = db.storeQuery("SELECT `marriage_status` FROM `players` WHERE `id` = " .. db.escapeString(id))
  155.    if resultQuery ~= false then
  156.        local ret = result.getDataInt(resultQuery, "marriage_status")
  157.        result.free(resultQuery)
  158.        return ret
  159.    end
  160.    return -1
  161. end
  162.  
  163. function setPlayerMarriageStatus(id, val)
  164.    db.query("UPDATE `players` SET `marriage_status` = " .. val .. " WHERE `id` = " .. id)
  165. end
  166.  
  167. function Player:getMarriageDescription(thing)
  168.    local descr = ""
  169.    if getPlayerMarriageStatus(thing:getGuid()) == MARRIED_STATUS then
  170.        playerSpouse = getPlayerSpouse(thing:getGuid())
  171.        if self == thing then
  172.            descr = descr .. " You are "
  173.        elseif thing:getSex() == PLAYERSEX_FEMALE then
  174.            descr = descr .. " She is "
  175.        else
  176.            descr = descr .. " He is "
  177.        end
  178.        descr = descr .. "married to " .. getPlayerNameById(playerSpouse) .. '.'
  179.    end
  180.    return descr
  181. end
  182.  
  183. -- The following 2 functions can be used for delayed shouted text
  184.  
  185. function say(param)
  186. selfSay(text)
  187. doCreatureSay(param.cid, param.text, 1)
  188. end
  189.  
  190. function delayedSay(text, delay)
  191. local delay = delay or 0
  192. local cid = getNpcCid()
  193. addEvent(say, delay, {cid = cid, text = text})
  194. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement