function doPlayerGiveItem(cid, itemid, count, charges) local hasCharges = (isItemRune(itemid) == TRUE or isItemFluidContainer(itemid) == TRUE) if(hasCharges and charges == nil) then charges = 1 end while count > 0 do local tempcount = 1 if(hasCharges) then tempcount = charges end if(isItemStackable(itemid) == TRUE) then tempcount = math.min(100, count) end local ret = doPlayerAddItem(cid, itemid, tempcount) if(ret == LUA_ERROR) then ret = doCreateItem(itemid, tempcount, getPlayerPosition(cid)) end if(ret ~= LUA_ERROR) then if(hasCharges) then count = count - 1 else count = count - tempcount end else return LUA_ERROR end end return LUA_NO_ERROR end function doPlayerTakeItem(cid, itemid, count) if(getPlayerItemCount(cid,itemid) >= count) then while count > 0 do local tempcount = 0 if(isItemStackable(itemid) == TRUE) then tempcount = math.min(100, count) else tempcount = 1 end local ret = doPlayerRemoveItem(cid, itemid, tempcount) if(ret ~= LUA_ERROR) then count = count - tempcount else return LUA_ERROR end end if(count == 0) then return LUA_NO_ERROR end else return LUA_ERROR end end function doPlayerBuyItem(cid, itemid, count, cost, charges) if(doPlayerRemoveMoney(cid, cost) == TRUE) then return doPlayerGiveItem(cid, itemid, count, charges) end return LUA_ERROR end function doPlayerBuyItemContainer(cid, container, itemid, count, cost, charges) if doPlayerRemoveMoney(cid, cost) == TRUE then for i = 1, count do local containerItem = doCreateItemEx(container, 1) for x = 1, getContainerCap(containerItem) do doAddContainerItem(containerItem, itemid, charges) end doPlayerAddItemEx(cid, containerItem, 1) end return LUA_NO_ERROR end return LUA_ERROR end function doPlayerbuyContainer(cid, container, itemid, charges, cost, count) return doPlayerBuyItemContainer(cid, container, itemid, count, cost, charges) end function do22222PlayerbuyContainer(cid, container, itemid, charges, cost, count) if doPlayerRemoveMoney(cid, cost) == TRUE then if container == 2595 then local backpack = doPlayerAddItem(cid, container, 1) doAddContainerItem(backpack, 2599, 1) else for i = 1, count do local backpack = doPlayerAddItem(cid, container, 1) for x = 1, 20 do doAddContainerItem(backpack, itemid, charges) end end end return LUA_NO_ERROR end return LUA_ERROR end function doPlayerSellItem(cid, itemid, count, cost) if(doPlayerTakeItem(cid, itemid, count) == LUA_NO_ERROR) then if(doPlayerAddMoney(cid, cost) ~= TRUE) then error('Could not add money to ' .. getPlayerName(cid) .. ' (' .. cost .. 'gp)') end return LUA_NO_ERROR end return LUA_ERROR end function isInRange(pos, fromPos, toPos) 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) and TRUE or FALSE end function isPremium(cid) return (isPlayer(cid) == TRUE and (getPlayerPremiumDays(cid) > 0 or getConfigInfo('freePremium') == "yes")) and TRUE or FALSE end function getMonthDayEnding(day) if day == "01" or day == "21" or day == "31" then return "st" elseif day == "02" or day == "22" then return "nd" elseif day == "03" or day == "23" then return "rd" else return "th" end end function getMonthString(m) return os.date("%B", os.time{year = 1970, month = m, day = 1}) end function getArticle(str) return str:find("[AaEeIiOoUuYy]") == 1 and "an" or "a" end function isNumber(str) return tonumber(str) ~= nil and TRUE or FALSE end function getDistanceBetween(firstPosition, secondPosition) local xDif = math.abs(firstPosition.x - secondPosition.x) local yDif = math.abs(firstPosition.y - secondPosition.y) local posDif = math.max(xDif, yDif) if(firstPosition.z ~= secondPosition.z) then posDif = posDif + 9 + 6 end return posDif end function doPlayerAddAddons(cid, addon) for i = 0, table.maxn(maleOutfits) do doPlayerAddOutfit(cid, maleOutfits[i], addon) end for i = 0, table.maxn(femaleOutfits) do doPlayerAddOutfit(cid, femaleOutfits[i], addon) end end function isSorcerer(cid) if(isPlayer(cid) == FALSE) then debugPrint("isSorcerer: Player not found.") return false end return (isInArray({1,5,9}, getPlayerVocation(cid)) == TRUE) end function isDruid(cid) if(isPlayer(cid) == FALSE) then debugPrint("isDruid: Player not found.") return false end return (isInArray({2,6,12}, getPlayerVocation(cid)) == TRUE) end function isPaladin(cid) if(isPlayer(cid) == FALSE) then debugPrint("isPaladin: Player not found.") return false end return (isInArray({3,7,13}, getPlayerVocation(cid)) == TRUE) end function isKnight(cid) if(isPlayer(cid) == FALSE) then debugPrint("isKnight: Player not found.") return false end return (isInArray({4,8,15,16}, getPlayerVocation(cid)) == TRUE) end function isRookie(cid) if(isPlayer(cid) == FALSE) then debugPrint("isRookie: Player not found.") return false end return (isInArray({0}, getPlayerVocation(cid)) == TRUE) end function getConfigInfo(info) if (type(info) ~= 'string') then return nil end dofile(getConfigFile()) return _G[info] end function getDirectionTo(pos1, pos2) local dir = NORTH if(pos1.x > pos2.x) then dir = WEST if(pos1.y > pos2.y) then dir = NORTHWEST elseif(pos1.y < pos2.y) then dir = SOUTHWEST end elseif(pos1.x < pos2.x) then dir = EAST if(pos1.y > pos2.y) then dir = NORTHEAST elseif(pos1.y < pos2.y) then dir = SOUTHEAST end else if(pos1.y > pos2.y) then dir = NORTH elseif(pos1.y < pos2.y) then dir = SOUTH end end return dir end function getPlayerLookPos(cid) return getPosByDir(getThingPos(cid), getPlayerLookDir(cid)) end function getPosByDir(fromPosition, direction, size) local n = size or 1 local pos = fromPosition if(direction == NORTH) then pos.y = pos.y - n elseif(direction == SOUTH) then pos.y = pos.y + n elseif(direction == WEST) then pos.x = pos.x - n elseif(direction == EAST) then pos.x = pos.x + n elseif(direction == NORTHWEST) then pos.y = pos.y - n pos.x = pos.x - n elseif(direction == NORTHEAST) then pos.y = pos.y - n pos.x = pos.x + n elseif(direction == SOUTHWEST) then pos.y = pos.y + n pos.x = pos.x - n elseif(direction == SOUTHEAST) then pos.y = pos.y + n pos.x = pos.x + n end return pos end function getPlayerMoney(cid) return ((getPlayerItemCount(cid, ITEM_CRYSTAL_COIN) * 10000) + (getPlayerItemCount(cid, ITEM_PLATINUM_COIN) * 100) + getPlayerItemCount(cid, ITEM_GOLD_COIN)) end function doPlayerWithdrawAllMoney(cid) return doPlayerWithdrawMoney(cid, getPlayerBalance(cid)) end function doPlayerDepositAllMoney(cid) return doPlayerDepositMoney(cid, getPlayerMoney(cid)) end function doPlayerTransferAllMoneyTo(cid, target) return doPlayerTransferMoneyTo(cid, target, getPlayerBalance(cid)) end function playerExists(name) return (getPlayerGUIDByName(name) ~= 0) end function getTibiaTime() local worldTime = getWorldTime() local hours = 0 while (worldTime > 60) do hours = hours + 1 worldTime = worldTime - 60 end return {hours = hours, minutes = worldTime} end function doWriteLogFile(file, text) local file = io.open(file, "a+") file:write("[" .. os.date("%d/%m/%Y %H:%M:%S") .. "] " .. text .. "\n") file:close() end function isInArea(pos, fromPos, toPos) if pos.x >= fromPos.x and pos.x <= toPos.x then if pos.y >= fromPos.y and pos.y <= toPos.y then if pos.z >= fromPos.z and pos.z <= toPos.z then return TRUE end end end return FALSE end function getExperienceForLevel(level) return (50 * level * level * level) / 3 - 100 * level * level + (850 * level) / 3 - 200 end exhaustion = { check = function (cid, storage) local exhaust = getPlayerStorageValue(cid, storage) if (os.time(t) >= exhaust) then return FALSE else return TRUE end end, get = function (cid, storage) local exhaust = getPlayerStorageValue(cid, storage) local left = exhaust - os.time(t) if (left >= 0) then return left else return FALSE end end, set = function (cid, storage, time) setPlayerStorageValue(cid, storage, os.time(t) + time) end, make = function (cid, storage, time) local exhaust = exhaustion.get(cid, storage) if (exhaust > 0) then return FALSE else exhaustion.set(cid, storage, time) return TRUE end end } table.find = function (table, value) for i, v in pairs(table) do if(v == value) then return i end end return nil end table.getPos = table.find table.isStrIn = function (txt, str) local result = false for i, v in pairs(str) do result = (string.find(txt, v) and not string.find(txt, '(%w+)' .. v) and not string.find(txt, v .. '(%w+)')) if(result) then break end end return result end table.countElements = function (table, item) local count = 0 for i, n in pairs(table) do if(item == n) then count = count + 1 end end return count end table.getCombinations = function (table, num) local a, number, select, newlist = {}, #table, num, {} for i = 1, select do a[#a + 1] = i end local newthing = {} while(TRUE) do local newrow = {} for i = 1, select do newrow[#newrow + 1] = table[a[i]] end newlist[#newlist + 1] = newrow i = select while(a[i] == (number - select + i)) do i = i - 1 end if(i < 1) then break end a[i] = a[i] + 1 for j = i, select do a[j] = a[i] + j - i end end return newlist end string.split = function (str) local t = {} local function helper(word) table.insert(t, word) return "" end if(not str:gsub("%w+", helper):find"%S") then return t end end string.trim = function (str) return (string.gsub(str, "^%s*(.-)%s*$", "%1")) end string.explode = function (str, sep) local pos, t = 1, {} if #sep == 0 or #str == 0 then return end for s, e in function() return string.find(str, sep, pos) end do table.insert(t, string.trim(string.sub(str, pos, s - 1))) pos = e + 1 end table.insert(t, string.trim(string.sub(str, pos))) return t end -- shop system dofile("./config.lua") function getOfferOfPlayer(name) local offer = {} local result_items = db.getResult("SELECT `id`, `name`, `item_name`, `itemid`, `subType`, `count`, `price` FROM `ots_playersshopsystem` WHERE `name` = " .. db.escapeString(name) .. " AND `count` > '0' AND `itemid` != '66'") if(result_items:getID() ~= -1) then while(true) do table.insert(offer, {id = result_items:getDataInt("id"), name = result_items:getDataString("name"), item_name = result_items:getDataString("item_name"), itemid = result_items:getDataInt("itemid"), subType = result_items:getDataInt("subType"), count = result_items:getDataInt("count"), price = result_items:getDataInt("price")}) if not(result_items:next()) then break end end result_items:free() end return offer end function getOfferOfItem(item_name) local offer = {} result_items = db.getResult("SELECT `id`, `name`, `item_name`, `itemid`, `subType`, `count`, `price` FROM `ots_playersshopsystem` WHERE `item_name` = " .. db.escapeString(item_name) .. " AND `count` > '0' AND `itemid` != '66' ORDER BY `price` ASC LIMIT 5") if(result_items:getID() ~= -1) then while(true) do table.insert(offer, {id = result_items:getDataInt("id"), name = result_items:getDataString("name"), item_name = result_items:getDataString("item_name"), itemid = result_items:getDataInt("itemid"), subType = result_items:getDataInt("subType"), count = result_items:getDataInt("count"), price = result_items:getDataInt("price")}) if not(result_items:next()) then break end end result_items:free() end return offer end function addItemToOffer(name, itemid, subType, count) local inDB_id = 0 local result_offers = db.getResult("SELECT `id`, `count` FROM `ots_playersshopsystem` WHERE `name` = " .. db.escapeString(name) .. " AND `itemid` = '" .. itemid .. "' AND `subType` = '" .. subType .. "' AND `itemid` != '66'") if(result_offers:getID() ~= -1) then inDB_id = result_offers:getDataInt("id") result_offers:free() end if inDB_id ~= 0 then db.executeQuery("UPDATE `ots_playersshopsystem` SET `count` = `ots_playersshopsystem`.`count` + " .. count .." WHERE `id` = '" .. inDB_id .. "' AND `subType` = '" .. subType .. "' AND `itemid` != '66'") else db.executeQuery("INSERT INTO `ots_playersshopsystem` (`id`, `name`, `item_name`, `itemid`, `subType`, `count`, `price`) VALUES (NULL, " .. db.escapeString(name) .. ", " .. db.escapeString(getItemNameById(itemid)) .. ", '" .. itemid .. "', '" .. subType .. "', '" .. count .. "', 1000000)") end return true end function removeItemsFromOffer(name, itemid, subType, count) db.executeQuery("UPDATE `ots_playersshopsystem` SET `count` = `ots_playersshopsystem`.`count` - " .. count .." WHERE `name` = " .. db.escapeString(name) .. " AND `itemid` = '" .. itemid .. "' AND `subType` = '" .. subType .. "' AND `itemid` != '66'") return true end function changePriceOfItem(name, itemid, subType, price) db.executeQuery("UPDATE `ots_playersshopsystem` SET `price` = " .. price .." WHERE `name` = " .. db.escapeString(name) .. " AND `itemid` = '" .. itemid .. "' AND `subType` = '" .. subType .. "' AND `itemid` != '66'") return true end function getItemWithId(id) local item = {id=0} local result_items = db.getResult("SELECT `id`, `name`, `item_name`, `itemid`, `subType`, `count`, `price` FROM `ots_playersshopsystem` WHERE `id` = '" .. id .. "' AND `count` > 0 AND `itemid` != '66'") if (result_items:getID() ~= -1) then item = {id = result_items:getDataInt("id"), name = result_items:getDataString("name"), item_name = result_items:getDataString("item_name"), itemid = result_items:getDataInt("itemid"), subType = result_items:getDataInt("subType"), count = result_items:getDataInt("count"), price = result_items:getDataInt("price")} result_items:free() end return item end function getItemWithItemId(name, itemid, subType) local item = {id=0} local result_items = db.getResult("SELECT `id`, `name`, `item_name`, `itemid`, `subType`, `count`, `price` FROM `ots_playersshopsystem` WHERE `name` = " .. db.escapeString(name) .. " AND `itemid` = '" .. itemid .. "' AND `subType` = '" .. subType .. "' AND `count` > 0 AND `itemid` != '66'") if(result_items:getID() ~= -1) then item = {id = result_items:getDataInt("id"), name = result_items:getDataString("name"), item_name = result_items:getDataString("item_name"), itemid = result_items:getDataInt("itemid"), subType = result_items:getDataInt("subType"), count = result_items:getDataInt("count"), price = result_items:getDataInt("price")} result_items:free() end return item end function getCash(name) local cash = 0 local result_items = db.getResult("SELECT `id`, `count` FROM `ots_playersshopsystem` WHERE `name` = " .. db.escapeString(name) .. " AND `itemid` = '66'") if(result_items:getID() ~= -1) then cash = result_items:getDataInt("count") result_items:free() else db.executeQuery("INSERT INTO `tfs`.`ots_playersshopsystem` (`id`, `name`, `item_name`, `itemid`, `count`, `price`) VALUES ('', " .. db.escapeString(name) .. ", 'Player Cash', '66', '0', '0')") end return cash end function setCash(name, count) db.executeQuery("UPDATE `ots_playersshopsystem` SET `count` = " .. count ..", `price` = " .. count .." WHERE `name` = " .. db.escapeString(name) .. " AND `itemid` = '66'") return true end function addPlayerItemFromShop(cid, itemid, amount, subType) local amount = amount or 1 local subType = subType or 0 if(isItemStackable(itemid) == TRUE) then local item = doCreateItemEx(itemid, amount) local ret = doPlayerAddItemEx(cid, item) if(ret ~= RETURNVALUE_NOERROR) then return {}, 0 end return {item}, amount end local items = {} local ret = 0 local a = 0 for i = 1, amount do items[i] = doCreateItemEx(itemid, subType) ret = doPlayerAddItemEx(cid, items[i]) if(ret ~= RETURNVALUE_NOERROR) then break end a = a + 1 end return items, a end -- gesior scripts dontAttack = {'motyl', 'kot', 'pies'} function isInTableString(tablee, stringg) stringg = string.lower(tostring(stringg)) for i = 1, table.maxn(tablee) do if string.lower(tostring(tablee[i])) == stringg then return 1 end end return 0 end function jebGo(param) if (isPlayer(param.cid) == TRUE or isCreature(param.cid) == TRUE) and (isPlayer(variantToNumber(param.var)) == TRUE or isCreature(variantToNumber(param.var)) == TRUE) then local cidpos = getCreaturePosition(param.cid) local varpos = getCreaturePosition(variantToNumber(param.var)) if getDistanceBetween(cidpos, varpos) < param.dist and varpos.z == cidpos.z then doCombat(param.cid, param.combat, param.var) end end end function getMonstersInArea3(cidpos, notCidArray) local playernumber = 0 local playersInRange = {} local pPos = cidpos local positionsToCheck = { {x=pPos.x-3,y=pPos.y+3,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x-2,y=pPos.y+3,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x-1,y=pPos.y+3,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x,y=pPos.y+3,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+1,y=pPos.y+3,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+2,y=pPos.y+3,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+3,y=pPos.y+3,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE}, {x=pPos.x-3,y=pPos.y+2,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x-2,y=pPos.y+2,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x-1,y=pPos.y+2,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x,y=pPos.y+2,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+1,y=pPos.y+2,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+2,y=pPos.y+2,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+3,y=pPos.y+2,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE}, {x=pPos.x-3,y=pPos.y+1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x-2,y=pPos.y+1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x-1,y=pPos.y+1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x,y=pPos.y+1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+1,y=pPos.y+1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+2,y=pPos.y+1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+3,y=pPos.y+1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE}, {x=pPos.x-3,y=pPos.y,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x-2,y=pPos.y,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x-1,y=pPos.y,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x,y=pPos.y,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+1,y=pPos.y,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+2,y=pPos.y,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+3,y=pPos.y,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE}, {x=pPos.x-3,y=pPos.y-1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x-2,y=pPos.y-1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x-1,y=pPos.y-1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x,y=pPos.y-1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+1,y=pPos.y-1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+2,y=pPos.y-1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+3,y=pPos.y-1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE}, {x=pPos.x-3,y=pPos.y-2,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x-2,y=pPos.y-2,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x-1,y=pPos.y-2,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x,y=pPos.y-2,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+1,y=pPos.y-2,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+2,y=pPos.y-2,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+3,y=pPos.y-2,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE}, {x=pPos.x-3,y=pPos.y-3,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x-2,y=pPos.y-3,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x-1,y=pPos.y-3,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x,y=pPos.y-3,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+1,y=pPos.y-3,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+2,y=pPos.y-3,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+3,y=pPos.y-3,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE} } for i = 1, table.maxn(positionsToCheck) do local creatureToHit = getThingfromPos(positionsToCheck[i]) if creatureToHit ~= 0 then if getTilePzInfo(positionsToCheck[i]) == 0 then if (isCreature(creatureToHit.uid) == TRUE and creatureToHit.uid ~= cid and isInArray(notCidArray, creatureToHit.uid) ~= TRUE) then if isPlayer(creatureToHit.uid) == TRUE then if getPlayerStorageValue(creatureToHit.uid, 39005) ~= 1 then table.insert(playersInRange, creatureToHit.uid) playernumber = playernumber + 1 end else table.insert(playersInRange, creatureToHit.uid) playernumber = playernumber + 1 end end end end end return {list = playersInRange, number = playernumber} end function getMonstersInArea1(cidpos, notCidArray) local playernumber = 0 local playersInRange = {} local pPos = cidpos local positionsToCheck = { {x=pPos.x-1,y=pPos.y+1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x,y=pPos.y+1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+1,y=pPos.y+1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE}, {x=pPos.x-1,y=pPos.y,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x,y=pPos.y,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+1,y=pPos.y,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE}, {x=pPos.x-1,y=pPos.y-1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x,y=pPos.y-1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE},{x=pPos.x+1,y=pPos.y-1,z=pPos.z,stackpos=STACKPOS_TOP_CREATURE}, } for i = 1, table.maxn(positionsToCheck) do local creatureToHit = getThingfromPos(positionsToCheck[i]) if creatureToHit ~= 0 then if getTilePzInfo(positionsToCheck[i]) == 0 then if (isCreature(creatureToHit.uid) == TRUE and creatureToHit.uid ~= cid and isInArray(notCidArray, creatureToHit.uid) ~= TRUE) then if isPlayer(creatureToHit.uid) == TRUE then if getPlayerStorageValue(creatureToHit.uid, 39005) ~= 1 then table.insert(playersInRange, creatureToHit.uid) playernumber = playernumber + 1 end else table.insert(playersInRange, creatureToHit.uid) playernumber = playernumber + 1 end end end end end return {list = playersInRange, number = playernumber} end function doDamageCreature(cid, damage, color, effect) damage = math.abs(damage) if getCreatureCondition(cid, CONDITION_MANASHIELD) == 1 then doSendMagicEffect(getThingPos(cid),CONST_ME_LOSEENERGY) doPlayerAddMana(cid, -math.min(damage, getPlayerMana(cid))) damage = damage - getPlayerMana(cid) end if damage > 0 then doCreatureAddHealth(cid, -damage) doSendAnimatedText(getThingPos(cid), damage, color or TEXTCOLOR_RED) end if effect then doSendMagicEffect(getThingPos(cid),effect) end return 1 end function addPremiumPoints(cid, value) local player_account_id = db.getResult("SELECT `account_id` FROM `players` WHERE `name` = " .. db.escapeString(getCreatureName(cid)) .. ";") if(player_account_id:getID() ~= -1) then local account_id = player_account_id:getDataInt("account_id") player_account_id:free() local player_account = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. account_id .. ";") if(player_account:getID() ~= -1) then local setpoints = player_account:getDataInt("premium_points") + value db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. setpoints .. " WHERE `id` = " .. account_id .. ";") player_account:free() return TRUE end end return FALSE end function actualizeItemName(uid, returnname) if uid > 0 then local itemEx = getThing(doCreateItemEx(getThing(uid).itemid, getThing(uid).itemid)) local itemTXT = '' local spearator = '' if getItemArmor(uid) - getItemArmor(itemEx.uid) ~= 0 then itemTXT = itemTXT .. spearator .. 'Arm: +'.. getItemArmor(uid) - getItemArmor(itemEx.uid) spearator = ', ' end if getItemAttack(uid) - getItemAttack(itemEx.uid) ~= 0 then itemTXT = itemTXT .. spearator .. 'Atk: +'.. getItemAttack(uid) - getItemAttack(itemEx.uid) spearator = ', ' end if getItemExtraAttack(uid) - getItemExtraAttack(itemEx.uid) ~= 0 then itemTXT = itemTXT .. spearator .. 'eAtk: +'.. getItemExtraAttack(uid) - getItemExtraAttack(itemEx.uid) spearator = ', ' end if getItemDefense(uid) - getItemDefense(itemEx.uid) ~= 0 then itemTXT = itemTXT .. spearator .. 'Def: +'.. getItemDefense(uid) - getItemDefense(itemEx.uid) spearator = ', ' end if getItemExtraDefense(uid) - getItemExtraDefense(itemEx.uid) ~= 0 then itemTXT = itemTXT .. spearator .. 'eDef: +'.. getItemExtraDefense(uid) - getItemExtraDefense(itemEx.uid) spearator = ', ' end if getItemAttackSpeed(uid) > 0 then itemTXT = itemTXT .. spearator .. 'AtkT: -'.. (1000 - getItemAttackSpeed(uid)) / 10 .. '%' spearator = ', ' end if getItemHealthMaxPercent(uid) - getItemHealthMaxPercent(itemEx.uid) > 0 then itemTXT = itemTXT .. spearator .. 'HP: +'.. getItemHealthMaxPercent(uid) .. '%' spearator = ', ' end if getItemManaMaxPercent(uid) - getItemManaMaxPercent(itemEx.uid) > 0 then itemTXT = itemTXT .. spearator .. 'MP: +'.. getItemManaMaxPercent(uid) .. '%' spearator = ', ' end if itemTXT ~= '' then setItemName(uid, getItemNameById(itemEx.itemid) .. " [" .. itemTXT .. "] ") return getItemNameById(itemEx.itemid) .. " [" .. itemTXT .. "] " else setItemName(uid, getItemNameById(itemEx.itemid)) return getItemNameById(itemEx.itemid) end end return TRUE end