Ir para conteúdo
  • Cadastre-se

(Resolvido)Alguem me ajuda com esse erro


Ir para solução Resolvido por Vodkart,

Posts Recomendados

O Erro

Spoiler

[8/1/2017 19:24:4] [Error - TalkAction Interface] 
[8/1/2017 19:24:4] data/talkactions/scripts/systempoints.lua:onSay
[8/1/2017 19:24:5] Description: 
[8/1/2017 19:24:5] data/talkactions/scripts/systempoints.lua:53: attempt to call global 'addPoints' (a nil value)
[8/1/2017 19:24:6] stack traceback:
[8/1/2017 19:24:6]     data/talkactions/scripts/systempoints.lua:53: in function <data/talkactions/scripts/systempoints.lua:1>

[8/1/2017 19:24:15] [Error - TalkAction Interface] 
[8/1/2017 19:24:16] data/talkactions/scripts/systempoints.lua:onSay
[8/1/2017 19:24:16] Description: 
[8/1/2017 19:24:16] data/talkactions/scripts/systempoints.lua:5: attempt to call global 'getPoints' (a nil value)
[8/1/2017 19:24:17] stack traceback:
[8/1/2017 19:24:17]     data/talkactions/scripts/systempoints.lua:5: in function <data/talkactions/scripts/systempoints.lua:1>

[8/1/2017 19:24:39] [Error - Action Interface] 
[8/1/2017 19:24:39] data/actions/scripts/vipitens.lua:onUse
[8/1/2017 19:24:39] Description: 
[8/1/2017 19:24:40] data/actions/scripts/vipitens.lua:47: attempt to call global 'getPoints' (a nil value)
[8/1/2017 19:24:40] stack traceback:
[8/1/2017 19:24:40]     data/actions/scripts/vipitens.lua:47: in function <data/actions/scripts/vipitens.lua:45>

Script da Talkaction que o ocorre o erro

Spoiler

function onSay(cid, words, param)

if(words == "!points") then

return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você tem "..getPoints(cid).." Points.")

elseif(words == "!rankpoints") then

local max_players,str = 20,""

str = "--[ RANK POINTS ]--\n\n"

query = db.getResult("SELECT `name`, `points` FROM `players` WHERE `points` > -1 AND `id` > 6 AND `group_id` < 2 ORDER BY `points` DESC, `name` ASC;")

if (query:getID() ~= -1) then k = 1 while true do

str = str .. "\n " .. k .. ". " .. query:getDataString("name") .. " - [" .. query:getDataInt("points") .. "]"

k = k + 1

if not(query:next()) or k > max_players then break end end query:free()end

if str ~= "" then doShowTextDialog(cid,6500, str) end

elseif(words == "/addpoints") then

if getPlayerAccess(cid) == 5 then

local t = string.explode(param, ",")

if not t[1] or not t[2] then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") return true end

local player,points = getPlayerByName(t[1]),t[2]

local pid = getPlayerByNameWildcard(t[1])

if not pid then

local guid  = getPlayerGUIDByName(t[1])

if guid == nil then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This player doesn't exists.") return true

end

db.executeQuery("UPDATE `players` SET `points` = `points` + " .. t[2] .. " WHERE `id` = "..guid) 

else

doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Foram adicionados "..points.." Points no seu character.")

addPoints(player,points)

end

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "você adicionou "..points.." Points do jogador "..t[1])

end

elseif(words == "/delpoints") then

if getPlayerAccess(cid) == 5 then

local t = string.explode(param, ",")

if not t[1] or not t[2] then return TRUE,doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") end

local player = getPlayerByName(t[1])

local points = t[2]

local pid = getPlayerByNameWildcard(t[1])

if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then

return TRUE,doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player with this name doesn\'t exist or is offline.") end

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "você removeu "..points.." Points do jogador "..t[1])

doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Foram removidos "..points.." Points do seu character.")

removePoints(player,points)

doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Você agora tem "..getPoints(player).." Points.")

end

elseif(words == "/setpoints") then

if getPlayerAccess(cid) == 5 then

local t = string.explode(param, ",")

if not t[1] or not t[2] then return TRUE,doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") end

local player = getPlayerByName(t[1])

local points = t[2]

local pid = getPlayerByNameWildcard(t[1])

if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then

return TRUE,doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player with this name doesn\'t exist or is offline.") end

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Agora o jogador "..t[1].." tem "..points.." Points no seu character.")

doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "agora você tem "..points.." Points do seu character.")

setPoints(player,points)

end

end

return true

end

Script da Action que ocorre o erro

Spoiler

local lever = {

[6001] = {20,2628},

[6002] = {20,2631},

[6003] = {20,2627},

[6004] = {20,2629},

[6005] = {20,2626},

[6006] = {10,2343},

[6007] = {10,12568},

[6008] = {10,11298},

[6009] = {10,12605},

[6010] = {10,9932},

[6011] = {10,10016},

[6012] = {10,8867},

[6013] = {10,7730},

[6014] = {10,2539},

[6015] = {10,9932},

[6016] = {30,10309},

[6017] = {15,10310},

[6018] = {25,8266}

}

local storage,exausted = 98762,10

local Stackable = {8303,8310} -- coloque o ID aqui dos que só vem 1

function onUse(cid,item,fromPosition,itemEx,toPosition)

if getPoints(cid) < lever[item.actionid][1] then

return doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Você precisa de "..lever[item.actionid][1].." points.")

elseif getPlayerStorageValue(cid, storage) >= os.time() then

return doPlayerSendCancel(cid, "wait " .. getPlayerStorageValue(cid, storage) - os.time() .. " seconds to use this item again.")

end

doPlayerAddItem(cid,lever[item.actionid][2], isItemStackable(lever[item.actionid][2]) and isInArray(Stackable, lever[item.actionid][2]) and 1 or 100)

removePoints(cid,lever[item.actionid][1])

setPlayerStorageValue(cid, storage, os.time()+exausted)

doPlayerSendTextMessage(cid,22,"Você comprou um " .. getItemNameById(lever[item.actionid][2]))

doSendMagicEffect(getCreaturePosition(cid), math.random(28,30))

return true

end 

Minha Functions Pode ser talves a causa do erro

Spoiler

function isInArray(array, value, caseSensitive)
    if(caseSensitive == nil or caseSensitive == false) and type(value) == "string" then
        local lowerValue = value:lower()
        for _, _value in ipairs(array) do
            if type(_value) == "string" and lowerValue == _value:lower() then
                return true
            end
        end
    else
        for _, _value in ipairs(array) do
            if (value == _value) then return true end
        end
    end

    return false
end

function setPlayerStorageValueDB(guid, key, value)
   db.executeQuery("UPDATE player_storage SET value = "..value.." WHERE key = "..key.." AND player_id = ".. guid ..";")
   return true
end

function getPlayerStorageValueDB(guid, key)
   local result = db.getResult("SELECT value FROM `player_storage` WHERE key = "..key.." AND player_id = ".. guid ..";")
   if result:getID() ~= -1 then
      return result:getDataInt("value")
   else
      return -1
   end
   result:free()
end

function doPlayerGiveItem(cid, itemid, amount, subType)
    local item = 0
    if(isItemStackable(itemid)) then
        item = doCreateItemEx(itemid, amount)
        if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
            return false
        end
    else
        for i = 1, amount do
            item = doCreateItemEx(itemid, subType)
            if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
                return false
            end
        end
    end

    return true
end

function doPlayerGiveItemContainer(cid, containerid, itemid, amount, subType)
    for i = 1, amount do
        local container = doCreateItemEx(containerid, 1)
        for x = 1, getContainerCapById(containerid) do
            doAddContainerItem(container, itemid, subType)
        end

        if(doPlayerAddItemEx(cid, container, true) ~= RETURNVALUE_NOERROR) then
            return false
        end
    end

    return true
end

function doPlayerTakeItem(cid, itemid, amount)
    return getPlayerItemCount(cid, itemid) >= amount and doPlayerRemoveItem(cid, itemid, amount)
end

function doPlayerSellItem(cid, itemid, count, cost)
    if(not doPlayerTakeItem(cid, itemid, count)) then
        return false
    end

    if(not doPlayerAddMoney(cid, cost)) then
        error('[doPlayerSellItem] Could not add money to: ' .. getPlayerName(cid) .. ' (' .. cost .. 'gp).')
    end

    return true
end

function doPlayerWithdrawMoney(cid, amount)
    if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
        return false
    end

    local balance = getPlayerBalance(cid)
    if(amount > balance or not doPlayerAddMoney(cid, amount)) then
        return false
    end

    doPlayerSetBalance(cid, balance - amount)
    return true
end

function doPlayerDepositMoney(cid, amount)
    if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
        return false
    end

    if(not doPlayerRemoveMoney(cid, amount)) then
        return false
    end

    doPlayerSetBalance(cid, getPlayerBalance(cid) + amount)
    return true
end

function doPlayerAddStamina(cid, minutes)
    return doPlayerSetStamina(cid, getPlayerStamina(cid) + minutes)
end

function isPremium(cid)
    return (isPlayer(cid) and (getPlayerPremiumDays(cid) > 0 or getBooleanFromString(getConfigValue('freePremium'))))
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"
    end

    return "th"
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 doNumberFormat(i)
    local str, found = string.gsub(i, "(%d)(%d%d%d)$", "%1,%2", 1), 0
    repeat
        str, found = string.gsub(str, "(%d)(%d%d%d),", "%1,%2,", 1)
    until found == 0
    return str
end

function doPlayerAddAddons(cid, addon)
    for i = 0, table.maxn(maleOutfits) do
        doPlayerAddOutfit(cid, maleOutfits, addon)
    end

    for i = 0, table.maxn(femaleOutfits) do
        doPlayerAddOutfit(cid, femaleOutfits, addon)
    end
end

function getTibiaTime(num)
    local minutes, hours = getWorldTime(), 0
    while (minutes > 60) do
        hours = hours + 1
        minutes = minutes - 60
    end

    if(num) then
        return {hours = hours, minutes = minutes}
    end

    return {hours =  hours < 10 and '0' .. hours or '' .. hours, minutes = minutes < 10 and '0' .. minutes or '' .. minutes}
end

function doWriteLogFile(file, text)
    local f = io.open(file, "a+")
    if(not f) then
        return false
    end

    f:write("[" .. os.date("%d/%m/%Y %H:%M:%S") .. "] " .. text .. "\n")
    f:close()
    return true
end

function getExperienceForLevel(lv)
    lv = lv - 1
    return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end

function doMutePlayer(cid, time)
    local condition = createConditionObject(CONDITION_MUTED, (time == -1 and time or time * 1000))
    return doAddCondition(cid, condition, false)

end

function doSummonCreature(name, pos)
    local cid = doCreateMonster(name, pos, false, false)
    if(not cid) then
        cid = doCreateNpc(name, pos)
    end

    return cid
end

function getPlayersOnlineEx()
    local players = {}
    for i, cid in ipairs(getPlayersOnline()) do
        table.insert(players, getCreatureName(cid))
    end

    return players
end

function getPlayerByName(name)
    local cid = getCreatureByName(name)
    return isPlayer(cid) and cid or nil
end

function isPlayer(cid)
    return isCreature(cid) and cid >= AUTOID_PLAYERS and cid < AUTOID_MONSTERS
end

function isPlayerGhost(cid)
    return isPlayer(cid) and (getCreatureCondition(cid, CONDITION_GAMEMASTER, GAMEMASTER_INVISIBLE, CONDITIONID_DEFAULT) or getPlayerFlagValue(cid, PLAYERFLAG_CANNOTBESEEN))
end

function isMonster(cid)
    return isCreature(cid) and cid >= AUTOID_MONSTERS and cid < AUTOID_NPCS
end

function isNpc(cid)
    -- Npc IDs are over int32_t range (which is default for lua_pushnumber),
    -- therefore number is always a negative value.
    return isCreature(cid) and (cid < 0 or cid >= AUTOID_NPCS)
end

function isUnderWater(cid)
    return isInArray(underWater, getTileInfo(getCreaturePosition(cid)).itemid)
end

function doPlayerAddLevel(cid, amount, round)
    local experience, level, amount = 0, getPlayerLevel(cid), amount or 1
    if(amount > 0) then
        experience = getExperienceForLevel(level + amount) - (round and getPlayerExperience(cid) or getExperienceForLevel(level))
    else
        experience = -((round and getPlayerExperience(cid) or getExperienceForLevel(level)) - getExperienceForLevel(level + amount))
    end

    return doPlayerAddExperience(cid, experience)
end

function doPlayerAddMagLevel(cid, amount)
    local amount = amount or 1
    for i = 1, amount do
        doPlayerAddSpentMana(cid, getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid), false)
    end

    return true
end

function doPlayerAddSkill(cid, skill, amount, round)
    local amount = amount or 1
    if(skill == SKILL__LEVEL) then
        return doPlayerAddLevel(cid, amount, round)
    elseif(skill == SKILL__MAGLEVEL) then
        return doPlayerAddMagLevel(cid, amount)
    end

    for i = 1, amount do
        doPlayerAddSkillTry(cid, skill, getPlayerRequiredSkillTries(cid, skill, getPlayerSkillLevel(cid, skill) + 1) - getPlayerSkillTries(cid, skill), false)
    end

    return true
end

function isPrivateChannel(channelId)
    return channelId >= CHANNEL_PRIVATE
end

function doBroadcastMessage(text, class)
    local class = class or MESSAGE_STATUS_WARNING
    if(type(class) == 'string') then
        local className = MESSAGE_TYPES[class]
        if(className == nil) then
            return false
        end

        class = className
    elseif(class < MESSAGE_FIRST or class > MESSAGE_LAST) then
        return false
    end

    for _, pid in ipairs(getPlayersOnline()) do
        doPlayerSendTextMessage(pid, class, text)
    end

    print("> Broadcasted message: \"" .. text .. "\".")
    return true
end

function doPlayerBroadcastMessage(cid, text, class, checkFlag, ghost)
    local checkFlag, ghost, class = checkFlag or true, ghost or false, class or TALKTYPE_BROADCAST
    if(checkFlag and not getPlayerFlagValue(cid, PLAYERFLAG_CANBROADCAST)) then
        return false
    end

    if(type(class) == 'string') then
        local className = TALKTYPE_TYPES[class]
        if(className == nil) then
            return false
        end

        class = className
    elseif(class < TALKTYPE_FIRST or class > TALKTYPE_LAST) then
        return false
    end

    for _, pid in ipairs(getPlayersOnline()) do
        doCreatureSay(cid, text, class, ghost, pid)
    end

    print("> " .. getCreatureName(cid) .. " broadcasted message: \"" .. text .. "\".")
    return true
end

function doCopyItem(item, attributes)
    local attributes = ((type(attributes) == 'table') and attributes or { "aid" })

    local ret = doCreateItemEx(item.itemid, item.type)
    for _, key in ipairs(attributes) do
        local value = getItemAttribute(item.uid, key)
        if(value ~= nil) then
            doItemSetAttribute(ret, key, value)
        end
    end

    if(isContainer(item.uid)) then
        for i = (getContainerSize(item.uid) - 1), 0, -1 do
            local tmp = getContainerItem(item.uid, i)
            if(tmp.itemid > 0) then
                doAddContainerItemEx(ret, doCopyItem(tmp, true).uid)
            end
        end
    end

    return getThing(ret)
end

function doSetItemText(uid, text, writer, date)
    local thing = getThing(uid)
    if(thing.itemid < 100) then
        return false
    end

    doItemSetAttribute(uid, "text", text)
    if(writer ~= nil) then
        doItemSetAttribute(uid, "writer", tostring(writer))
        if(date ~= nil) then
            doItemSetAttribute(uid, "date", tonumber(date))
        end
    end

    return true
end

function getItemWeightById(itemid, count, precision)
    local item, count, precision = getItemInfo(itemid), count or 1, precision or false
    if(not item) then
        return false
    end

    if(count > 100) then
        -- print a warning, as its impossible to have more than 100 stackable items without "cheating" the count
        print('[Warning] getItemWeightById', 'Calculating weight for more than 100 items!')
    end

    local weight = item.weight * count
    return precission and weight or math.round(weight, 2)
end

function choose(...)
    local arg, ret = {...}

    if type(arg[1]) == 'table' then
        ret = arg[1][math.random(#arg[1])]
    else
        ret = arg[math.random(#arg)]
    end

    return ret
end

function doPlayerAddExpEx(cid, amount)
    if(not doPlayerAddExp(cid, amount)) then
        return false
    end

    local position = getThingPosition(cid)
    doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE, "You gained " .. amount .. " experience.", amount, COLOR_WHITE, position)

    local spectators, name = getSpectators(position, 7, 7), getCreatureName(cid)
    for _, pid in ipairs(spectators) do
        if(isPlayer(pid) and cid ~= pid) then
            doPlayerSendTextMessage(pid, MESSAGE_EXPERIENCE_OTHERS, name .. " gained " .. amount .. " experience.", amount, COLOR_WHITE, position)
        end
    end

    return true
end

function getItemTopParent(uid)
    local parent = getItemParent(uid)
    if(not parent or parent.uid == 0) then
        return nil
    end

    while(true) do
        local tmp = getItemParent(parent.uid)
        if(tmp and tmp.uid ~= 0) then
            parent = tmp
        else
            break
        end
    end

    return parent
end

function getItemHolder(uid)
    local parent = getItemParent(uid)
    if(not parent or parent.uid == 0) then
        return nil
    end

    local holder = nil
    while(true) do
        local tmp = getItemParent(parent.uid)
        if(tmp and tmp.uid ~= 0) then
            if(tmp.itemid == 1) then -- a creature
                holder = tmp
                break
            end

            parent = tmp
        else
            break
        end
    end

    return holder
end

function valid(f)
    return function(p, ...)
        if(isCreature(p)) then
            return f(p, ...)
        end
    end
end

function addContainerItems(container,items)
    local items_mod = {}
    for _, it in ipairs(items) do
        if( isItemStackable(it.id) and it.count > 100) then
            local c = it.count
            while( c > 100 ) do
                table.insert(items_mod,{id = it.id,count = 100})
                c = c - 100
            end
            if(c > 0) then
                table.insert(items_mod,{id = it.id,count = c})
            end
        else
            table.insert(items_mod,{id = it.id,count = 1})
        end
    end

function getPoints(cid)
    local check = db.getResult("SELECT `points` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
        return check:getDataInt("points") <= 0 and 0 or check:getDataInt("points") end
function addPoints(cid,amount)
db.Query("UPDATE `players` SET `points` = "..getPoints(cid).."+"..amount.." WHERE `id` = "..getPlayerGUID(cid)) end
function removePoints(cid,amount)
db.Query("UPDATE `players` SET `points` = "..getPoints(cid).."-"..amount.." WHERE `id` = "..getPlayerGUID(cid)) end
function setPoints(cid,value)
db.Query("UPDATE `players` SET `points` = "..value.." WHERE `id` = "..getPlayerGUID(cid)) end    

    local free = getContainerCap(container.uid) - (getContainerSize(container.uid) )
    local count = math.ceil(#items_mod/ free)
    local main_bp = container.uid
    local insert_bp = main_bp
    local counter = 1
    for c,it in ipairs(items_mod) do
        local _c = isItemStackable(it.id) and (it.count > 100 and 100 or it.count) or 1
        if count > 1 then
            if (counter < free) then
                doAddContainerItem(insert_bp, it.id, _c)
            else
                insert_bp = doAddContainerItem(insert_bp, container.itemid, 1)
                count = (#items_mod)-(free-1)
                free = getContainerCap(insert_bp) 
                count = math.ceil(count/ free)
                doAddContainerItem(insert_bp, it.id, _c)
                counter = 1
            end
            counter = counter + 1
        else
            doAddContainerItem(insert_bp, it.id, _c)
        end
    end

    return main_bp
end

 

Editado por Ocruxzika (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
  • Solução

é na lib functions mesmo

vc colocou as funções dentro de outra.

 

 

function isInArray(array, value, caseSensitive)
    if(caseSensitive == nil or caseSensitive == false) and type(value) == "string" then
        local lowerValue = value:lower()
        for _, _value in ipairs(array) do
            if type(_value) == "string" and lowerValue == _value:lower() then
                return true
            end
        end
    else
        for _, _value in ipairs(array) do
            if (value == _value) then return true end
        end
    end
    return false
end
function setPlayerStorageValueDB(guid, key, value)
   db.executeQuery("UPDATE player_storage SET value = "..value.." WHERE key = "..key.." AND player_id = ".. guid ..";")
   return true
end
function getPlayerStorageValueDB(guid, key)
   local result = db.getResult("SELECT value FROM `player_storage` WHERE key = "..key.." AND player_id = ".. guid ..";")
   if result:getID() ~= -1 then
      return result:getDataInt("value")
   else
      return -1
   end
   result:free()
end
function doPlayerGiveItem(cid, itemid, amount, subType)
    local item = 0
    if(isItemStackable(itemid)) then
        item = doCreateItemEx(itemid, amount)
        if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
            return false
        end
    else
        for i = 1, amount do
            item = doCreateItemEx(itemid, subType)
            if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
                return false
            end
        end
    end
    return true
end
function doPlayerGiveItemContainer(cid, containerid, itemid, amount, subType)
    for i = 1, amount do
        local container = doCreateItemEx(containerid, 1)
        for x = 1, getContainerCapById(containerid) do
            doAddContainerItem(container, itemid, subType)
        end
        if(doPlayerAddItemEx(cid, container, true) ~= RETURNVALUE_NOERROR) then
            return false
        end
    end
    return true
end
function doPlayerTakeItem(cid, itemid, amount)
    return getPlayerItemCount(cid, itemid) >= amount and doPlayerRemoveItem(cid, itemid, amount)
end
function doPlayerSellItem(cid, itemid, count, cost)
    if(not doPlayerTakeItem(cid, itemid, count)) then
        return false
    end
    if(not doPlayerAddMoney(cid, cost)) then
        error('[doPlayerSellItem] Could not add money to: ' .. getPlayerName(cid) .. ' (' .. cost .. 'gp).')
    end
    return true
end
function doPlayerWithdrawMoney(cid, amount)
    if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
        return false
    end
    local balance = getPlayerBalance(cid)
    if(amount > balance or not doPlayerAddMoney(cid, amount)) then
        return false
    end
    doPlayerSetBalance(cid, balance - amount)
    return true
end
function doPlayerDepositMoney(cid, amount)
    if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
        return false
    end
    if(not doPlayerRemoveMoney(cid, amount)) then
        return false
    end
    doPlayerSetBalance(cid, getPlayerBalance(cid) + amount)
    return true
end
function doPlayerAddStamina(cid, minutes)
    return doPlayerSetStamina(cid, getPlayerStamina(cid) + minutes)
end
function isPremium(cid)
    return (isPlayer(cid) and (getPlayerPremiumDays(cid) > 0 or getBooleanFromString(getConfigValue('freePremium'))))
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"
    end
    return "th"
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 doNumberFormat(i)
    local str, found = string.gsub(i, "(%d)(%d%d%d)$", "%1,%2", 1), 0
    repeat
        str, found = string.gsub(str, "(%d)(%d%d%d),", "%1,%2,", 1)
    until found == 0
    return str
end
function doPlayerAddAddons(cid, addon)
    for i = 0, table.maxn(maleOutfits) do
        doPlayerAddOutfit(cid, maleOutfits, addon)
    end
    for i = 0, table.maxn(femaleOutfits) do
        doPlayerAddOutfit(cid, femaleOutfits, addon)
    end
end
function getTibiaTime(num)
    local minutes, hours = getWorldTime(), 0
    while (minutes > 60) do
        hours = hours + 1
        minutes = minutes - 60
    end
    if(num) then
        return {hours = hours, minutes = minutes}
    end
    return {hours =  hours < 10 and '0' .. hours or '' .. hours, minutes = minutes < 10 and '0' .. minutes or '' .. minutes}
end
function doWriteLogFile(file, text)
    local f = io.open(file, "a+")
    if(not f) then
        return false
    end
    f:write("[" .. os.date("%d/%m/%Y %H:%M:%S") .. "] " .. text .. "\n")
    f:close()
    return true
end
function getExperienceForLevel(lv)
    lv = lv - 1
    return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end
function doMutePlayer(cid, time)
    local condition = createConditionObject(CONDITION_MUTED, (time == -1 and time or time * 1000))
    return doAddCondition(cid, condition, false)
end
function doSummonCreature(name, pos)
    local cid = doCreateMonster(name, pos, false, false)
    if(not cid) then
        cid = doCreateNpc(name, pos)
    end
    return cid
end
function getPlayersOnlineEx()
    local players = {}
    for i, cid in ipairs(getPlayersOnline()) do
        table.insert(players, getCreatureName(cid))
    end
    return players
end
function getPlayerByName(name)
    local cid = getCreatureByName(name)
    return isPlayer(cid) and cid or nil
end
function isPlayer(cid)
    return isCreature(cid) and cid >= AUTOID_PLAYERS and cid < AUTOID_MONSTERS
end
function isPlayerGhost(cid)
    return isPlayer(cid) and (getCreatureCondition(cid, CONDITION_GAMEMASTER, GAMEMASTER_INVISIBLE, CONDITIONID_DEFAULT) or getPlayerFlagValue(cid, PLAYERFLAG_CANNOTBESEEN))
end
function isMonster(cid)
    return isCreature(cid) and cid >= AUTOID_MONSTERS and cid < AUTOID_NPCS
end
function isNpc(cid)
    -- Npc IDs are over int32_t range (which is default for lua_pushnumber),
    -- therefore number is always a negative value.
    return isCreature(cid) and (cid < 0 or cid >= AUTOID_NPCS)
end
function isUnderWater(cid)
    return isInArray(underWater, getTileInfo(getCreaturePosition(cid)).itemid)
end
function doPlayerAddLevel(cid, amount, round)
    local experience, level, amount = 0, getPlayerLevel(cid), amount or 1
    if(amount > 0) then
        experience = getExperienceForLevel(level + amount) - (round and getPlayerExperience(cid) or getExperienceForLevel(level))
    else
        experience = -((round and getPlayerExperience(cid) or getExperienceForLevel(level)) - getExperienceForLevel(level + amount))
    end
    return doPlayerAddExperience(cid, experience)
end
function doPlayerAddMagLevel(cid, amount)
    local amount = amount or 1
    for i = 1, amount do
        doPlayerAddSpentMana(cid, getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid), false)
    end
    return true
end
function doPlayerAddSkill(cid, skill, amount, round)
    local amount = amount or 1
    if(skill == SKILL__LEVEL) then
        return doPlayerAddLevel(cid, amount, round)
    elseif(skill == SKILL__MAGLEVEL) then
        return doPlayerAddMagLevel(cid, amount)
    end
    for i = 1, amount do
        doPlayerAddSkillTry(cid, skill, getPlayerRequiredSkillTries(cid, skill, getPlayerSkillLevel(cid, skill) + 1) - getPlayerSkillTries(cid, skill), false)
    end
    return true
end
function isPrivateChannel(channelId)
    return channelId >= CHANNEL_PRIVATE
end
function doBroadcastMessage(text, class)
    local class = class or MESSAGE_STATUS_WARNING
    if(type(class) == 'string') then
        local className = MESSAGE_TYPES[class]
        if(className == nil) then
            return false
        end
        class = className
    elseif(class < MESSAGE_FIRST or class > MESSAGE_LAST) then
        return false
    end
    for _, pid in ipairs(getPlayersOnline()) do
        doPlayerSendTextMessage(pid, class, text)
    end
    print("> Broadcasted message: \"" .. text .. "\".")
    return true
end
function doPlayerBroadcastMessage(cid, text, class, checkFlag, ghost)
    local checkFlag, ghost, class = checkFlag or true, ghost or false, class or TALKTYPE_BROADCAST
    if(checkFlag and not getPlayerFlagValue(cid, PLAYERFLAG_CANBROADCAST)) then
        return false
    end
    if(type(class) == 'string') then
        local className = TALKTYPE_TYPES[class]
        if(className == nil) then
            return false
        end
        class = className
    elseif(class < TALKTYPE_FIRST or class > TALKTYPE_LAST) then
        return false
    end
    for _, pid in ipairs(getPlayersOnline()) do
        doCreatureSay(cid, text, class, ghost, pid)
    end
    print("> " .. getCreatureName(cid) .. " broadcasted message: \"" .. text .. "\".")
    return true
end
function doCopyItem(item, attributes)
    local attributes = ((type(attributes) == 'table') and attributes or { "aid" })
    local ret = doCreateItemEx(item.itemid, item.type)
    for _, key in ipairs(attributes) do
        local value = getItemAttribute(item.uid, key)
        if(value ~= nil) then
            doItemSetAttribute(ret, key, value)
        end
    end
    if(isContainer(item.uid)) then
        for i = (getContainerSize(item.uid) - 1), 0, -1 do
            local tmp = getContainerItem(item.uid, i)
            if(tmp.itemid > 0) then
                doAddContainerItemEx(ret, doCopyItem(tmp, true).uid)
            end
        end
    end
    return getThing(ret)
end
function doSetItemText(uid, text, writer, date)
    local thing = getThing(uid)
    if(thing.itemid < 100) then
        return false
    end
    doItemSetAttribute(uid, "text", text)
    if(writer ~= nil) then
        doItemSetAttribute(uid, "writer", tostring(writer))
        if(date ~= nil) then
            doItemSetAttribute(uid, "date", tonumber(date))
        end
    end
    return true
end
function getItemWeightById(itemid, count, precision)
    local item, count, precision = getItemInfo(itemid), count or 1, precision or false
    if(not item) then
        return false
    end
    if(count > 100) then
        -- print a warning, as its impossible to have more than 100 stackable items without "cheating" the count
        print('[Warning] getItemWeightById', 'Calculating weight for more than 100 items!')
    end
    local weight = item.weight * count
    return precission and weight or math.round(weight, 2)
end
function choose(...)
    local arg, ret = {...}
    if type(arg[1]) == 'table' then
        ret = arg[1][math.random(#arg[1])]
    else
        ret = arg[math.random(#arg)]
    end
    return ret
end
function doPlayerAddExpEx(cid, amount)
    if(not doPlayerAddExp(cid, amount)) then
        return false
    end
    local position = getThingPosition(cid)
    doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE, "You gained " .. amount .. " experience.", amount, COLOR_WHITE, position)
    local spectators, name = getSpectators(position, 7, 7), getCreatureName(cid)
    for _, pid in ipairs(spectators) do
        if(isPlayer(pid) and cid ~= pid) then
            doPlayerSendTextMessage(pid, MESSAGE_EXPERIENCE_OTHERS, name .. " gained " .. amount .. " experience.", amount, COLOR_WHITE, position)
        end
    end
    return true
end
function getItemTopParent(uid)
    local parent = getItemParent(uid)
    if(not parent or parent.uid == 0) then
        return nil
    end
    while(true) do
        local tmp = getItemParent(parent.uid)
        if(tmp and tmp.uid ~= 0) then
            parent = tmp
        else
            break
        end
    end
    return parent
end
function getItemHolder(uid)
    local parent = getItemParent(uid)
    if(not parent or parent.uid == 0) then
        return nil
    end
    local holder = nil
    while(true) do
        local tmp = getItemParent(parent.uid)
        if(tmp and tmp.uid ~= 0) then
            if(tmp.itemid == 1) then -- a creature
                holder = tmp
                break
            end
            parent = tmp
        else
            break
        end
    end
    return holder
end
function valid(f)
    return function(p, ...)
        if(isCreature(p)) then
            return f(p, ...)
        end
    end
end
function addContainerItems(container,items)
    local items_mod = {}
    for _, it in ipairs(items) do
        if( isItemStackable(it.id) and it.count > 100) then
            local c = it.count
            while( c > 100 ) do
                table.insert(items_mod,{id = it.id,count = 100})
                c = c - 100
            end
            if(c > 0) then
                table.insert(items_mod,{id = it.id,count = c})
            end
        else
            table.insert(items_mod,{id = it.id,count = 1})
        end
    end
    local free = getContainerCap(container.uid) - (getContainerSize(container.uid) )
    local count = math.ceil(#items_mod/ free)
    local main_bp = container.uid
    local insert_bp = main_bp
    local counter = 1
    for c,it in ipairs(items_mod) do
        local _c = isItemStackable(it.id) and (it.count > 100 and 100 or it.count) or 1
        if count > 1 then
            if (counter < free) then
                doAddContainerItem(insert_bp, it.id, _c)
            else
                insert_bp = doAddContainerItem(insert_bp, container.itemid, 1)
                count = (#items_mod)-(free-1)
                free = getContainerCap(insert_bp) 
                count = math.ceil(count/ free)
                doAddContainerItem(insert_bp, it.id, _c)
                counter = 1
            end
            counter = counter + 1
        else
            doAddContainerItem(insert_bp, it.id, _c)
        end
    end
    return main_bp
end
function getPoints(cid)
local check = db.getResult("SELECT `points` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
return check:getDataInt("points") <= 0 and 0 or check:getDataInt("points") end
function addPoints(cid,amount)
db.Query("UPDATE `players` SET `points` = "..getPoints(cid).."+"..amount.." WHERE `id` = "..getPlayerGUID(cid)) end
function removePoints(cid,amount)
db.Query("UPDATE `players` SET `points` = "..getPoints(cid).."-"..amount.." WHERE `id` = "..getPlayerGUID(cid)) end
function setPoints(cid,value)
db.Query("UPDATE `players` SET `points` = "..value.." WHERE `id` = "..getPlayerGUID(cid)) end  

 

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
22 minutos atrás, Vodkart disse:

é na lib functions mesmo

vc colocou as funções dentro de outra.

 

 


function isInArray(array, value, caseSensitive)
    if(caseSensitive == nil or caseSensitive == false) and type(value) == "string" then
        local lowerValue = value:lower()
        for _, _value in ipairs(array) do
            if type(_value) == "string" and lowerValue == _value:lower() then
                return true
            end
        end
    else
        for _, _value in ipairs(array) do
            if (value == _value) then return true end
        end
    end
    return false
end
function setPlayerStorageValueDB(guid, key, value)
   db.executeQuery("UPDATE player_storage SET value = "..value.." WHERE key = "..key.." AND player_id = ".. guid ..";")
   return true
end
function getPlayerStorageValueDB(guid, key)
   local result = db.getResult("SELECT value FROM `player_storage` WHERE key = "..key.." AND player_id = ".. guid ..";")
   if result:getID() ~= -1 then
      return result:getDataInt("value")
   else
      return -1
   end
   result:free()
end
function doPlayerGiveItem(cid, itemid, amount, subType)
    local item = 0
    if(isItemStackable(itemid)) then
        item = doCreateItemEx(itemid, amount)
        if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
            return false
        end
    else
        for i = 1, amount do
            item = doCreateItemEx(itemid, subType)
            if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
                return false
            end
        end
    end
    return true
end
function doPlayerGiveItemContainer(cid, containerid, itemid, amount, subType)
    for i = 1, amount do
        local container = doCreateItemEx(containerid, 1)
        for x = 1, getContainerCapById(containerid) do
            doAddContainerItem(container, itemid, subType)
        end
        if(doPlayerAddItemEx(cid, container, true) ~= RETURNVALUE_NOERROR) then
            return false
        end
    end
    return true
end
function doPlayerTakeItem(cid, itemid, amount)
    return getPlayerItemCount(cid, itemid) >= amount and doPlayerRemoveItem(cid, itemid, amount)
end
function doPlayerSellItem(cid, itemid, count, cost)
    if(not doPlayerTakeItem(cid, itemid, count)) then
        return false
    end
    if(not doPlayerAddMoney(cid, cost)) then
        error('[doPlayerSellItem] Could not add money to: ' .. getPlayerName(cid) .. ' (' .. cost .. 'gp).')
    end
    return true
end
function doPlayerWithdrawMoney(cid, amount)
    if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
        return false
    end
    local balance = getPlayerBalance(cid)
    if(amount > balance or not doPlayerAddMoney(cid, amount)) then
        return false
    end
    doPlayerSetBalance(cid, balance - amount)
    return true
end
function doPlayerDepositMoney(cid, amount)
    if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
        return false
    end
    if(not doPlayerRemoveMoney(cid, amount)) then
        return false
    end
    doPlayerSetBalance(cid, getPlayerBalance(cid) + amount)
    return true
end
function doPlayerAddStamina(cid, minutes)
    return doPlayerSetStamina(cid, getPlayerStamina(cid) + minutes)
end
function isPremium(cid)
    return (isPlayer(cid) and (getPlayerPremiumDays(cid) > 0 or getBooleanFromString(getConfigValue('freePremium'))))
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"
    end
    return "th"
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 doNumberFormat(i)
    local str, found = string.gsub(i, "(%d)(%d%d%d)$", "%1,%2", 1), 0
    repeat
        str, found = string.gsub(str, "(%d)(%d%d%d),", "%1,%2,", 1)
    until found == 0
    return str
end
function doPlayerAddAddons(cid, addon)
    for i = 0, table.maxn(maleOutfits) do
        doPlayerAddOutfit(cid, maleOutfits, addon)
    end
    for i = 0, table.maxn(femaleOutfits) do
        doPlayerAddOutfit(cid, femaleOutfits, addon)
    end
end
function getTibiaTime(num)
    local minutes, hours = getWorldTime(), 0
    while (minutes > 60) do
        hours = hours + 1
        minutes = minutes - 60
    end
    if(num) then
        return {hours = hours, minutes = minutes}
    end
    return {hours =  hours < 10 and '0' .. hours or '' .. hours, minutes = minutes < 10 and '0' .. minutes or '' .. minutes}
end
function doWriteLogFile(file, text)
    local f = io.open(file, "a+")
    if(not f) then
        return false
    end
    f:write("[" .. os.date("%d/%m/%Y %H:%M:%S") .. "] " .. text .. "\n")
    f:close()
    return true
end
function getExperienceForLevel(lv)
    lv = lv - 1
    return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end
function doMutePlayer(cid, time)
    local condition = createConditionObject(CONDITION_MUTED, (time == -1 and time or time * 1000))
    return doAddCondition(cid, condition, false)
end
function doSummonCreature(name, pos)
    local cid = doCreateMonster(name, pos, false, false)
    if(not cid) then
        cid = doCreateNpc(name, pos)
    end
    return cid
end
function getPlayersOnlineEx()
    local players = {}
    for i, cid in ipairs(getPlayersOnline()) do
        table.insert(players, getCreatureName(cid))
    end
    return players
end
function getPlayerByName(name)
    local cid = getCreatureByName(name)
    return isPlayer(cid) and cid or nil
end
function isPlayer(cid)
    return isCreature(cid) and cid >= AUTOID_PLAYERS and cid < AUTOID_MONSTERS
end
function isPlayerGhost(cid)
    return isPlayer(cid) and (getCreatureCondition(cid, CONDITION_GAMEMASTER, GAMEMASTER_INVISIBLE, CONDITIONID_DEFAULT) or getPlayerFlagValue(cid, PLAYERFLAG_CANNOTBESEEN))
end
function isMonster(cid)
    return isCreature(cid) and cid >= AUTOID_MONSTERS and cid < AUTOID_NPCS
end
function isNpc(cid)
    -- Npc IDs are over int32_t range (which is default for lua_pushnumber),
    -- therefore number is always a negative value.
    return isCreature(cid) and (cid < 0 or cid >= AUTOID_NPCS)
end
function isUnderWater(cid)
    return isInArray(underWater, getTileInfo(getCreaturePosition(cid)).itemid)
end
function doPlayerAddLevel(cid, amount, round)
    local experience, level, amount = 0, getPlayerLevel(cid), amount or 1
    if(amount > 0) then
        experience = getExperienceForLevel(level + amount) - (round and getPlayerExperience(cid) or getExperienceForLevel(level))
    else
        experience = -((round and getPlayerExperience(cid) or getExperienceForLevel(level)) - getExperienceForLevel(level + amount))
    end
    return doPlayerAddExperience(cid, experience)
end
function doPlayerAddMagLevel(cid, amount)
    local amount = amount or 1
    for i = 1, amount do
        doPlayerAddSpentMana(cid, getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid), false)
    end
    return true
end
function doPlayerAddSkill(cid, skill, amount, round)
    local amount = amount or 1
    if(skill == SKILL__LEVEL) then
        return doPlayerAddLevel(cid, amount, round)
    elseif(skill == SKILL__MAGLEVEL) then
        return doPlayerAddMagLevel(cid, amount)
    end
    for i = 1, amount do
        doPlayerAddSkillTry(cid, skill, getPlayerRequiredSkillTries(cid, skill, getPlayerSkillLevel(cid, skill) + 1) - getPlayerSkillTries(cid, skill), false)
    end
    return true
end
function isPrivateChannel(channelId)
    return channelId >= CHANNEL_PRIVATE
end
function doBroadcastMessage(text, class)
    local class = class or MESSAGE_STATUS_WARNING
    if(type(class) == 'string') then
        local className = MESSAGE_TYPES[class]
        if(className == nil) then
            return false
        end
        class = className
    elseif(class < MESSAGE_FIRST or class > MESSAGE_LAST) then
        return false
    end
    for _, pid in ipairs(getPlayersOnline()) do
        doPlayerSendTextMessage(pid, class, text)
    end
    print("> Broadcasted message: \"" .. text .. "\".")
    return true
end
function doPlayerBroadcastMessage(cid, text, class, checkFlag, ghost)
    local checkFlag, ghost, class = checkFlag or true, ghost or false, class or TALKTYPE_BROADCAST
    if(checkFlag and not getPlayerFlagValue(cid, PLAYERFLAG_CANBROADCAST)) then
        return false
    end
    if(type(class) == 'string') then
        local className = TALKTYPE_TYPES[class]
        if(className == nil) then
            return false
        end
        class = className
    elseif(class < TALKTYPE_FIRST or class > TALKTYPE_LAST) then
        return false
    end
    for _, pid in ipairs(getPlayersOnline()) do
        doCreatureSay(cid, text, class, ghost, pid)
    end
    print("> " .. getCreatureName(cid) .. " broadcasted message: \"" .. text .. "\".")
    return true
end
function doCopyItem(item, attributes)
    local attributes = ((type(attributes) == 'table') and attributes or { "aid" })
    local ret = doCreateItemEx(item.itemid, item.type)
    for _, key in ipairs(attributes) do
        local value = getItemAttribute(item.uid, key)
        if(value ~= nil) then
            doItemSetAttribute(ret, key, value)
        end
    end
    if(isContainer(item.uid)) then
        for i = (getContainerSize(item.uid) - 1), 0, -1 do
            local tmp = getContainerItem(item.uid, i)
            if(tmp.itemid > 0) then
                doAddContainerItemEx(ret, doCopyItem(tmp, true).uid)
            end
        end
    end
    return getThing(ret)
end
function doSetItemText(uid, text, writer, date)
    local thing = getThing(uid)
    if(thing.itemid < 100) then
        return false
    end
    doItemSetAttribute(uid, "text", text)
    if(writer ~= nil) then
        doItemSetAttribute(uid, "writer", tostring(writer))
        if(date ~= nil) then
            doItemSetAttribute(uid, "date", tonumber(date))
        end
    end
    return true
end
function getItemWeightById(itemid, count, precision)
    local item, count, precision = getItemInfo(itemid), count or 1, precision or false
    if(not item) then
        return false
    end
    if(count > 100) then
        -- print a warning, as its impossible to have more than 100 stackable items without "cheating" the count
        print('[Warning] getItemWeightById', 'Calculating weight for more than 100 items!')
    end
    local weight = item.weight * count
    return precission and weight or math.round(weight, 2)
end
function choose(...)
    local arg, ret = {...}
    if type(arg[1]) == 'table' then
        ret = arg[1][math.random(#arg[1])]
    else
        ret = arg[math.random(#arg)]
    end
    return ret
end
function doPlayerAddExpEx(cid, amount)
    if(not doPlayerAddExp(cid, amount)) then
        return false
    end
    local position = getThingPosition(cid)
    doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE, "You gained " .. amount .. " experience.", amount, COLOR_WHITE, position)
    local spectators, name = getSpectators(position, 7, 7), getCreatureName(cid)
    for _, pid in ipairs(spectators) do
        if(isPlayer(pid) and cid ~= pid) then
            doPlayerSendTextMessage(pid, MESSAGE_EXPERIENCE_OTHERS, name .. " gained " .. amount .. " experience.", amount, COLOR_WHITE, position)
        end
    end
    return true
end
function getItemTopParent(uid)
    local parent = getItemParent(uid)
    if(not parent or parent.uid == 0) then
        return nil
    end
    while(true) do
        local tmp = getItemParent(parent.uid)
        if(tmp and tmp.uid ~= 0) then
            parent = tmp
        else
            break
        end
    end
    return parent
end
function getItemHolder(uid)
    local parent = getItemParent(uid)
    if(not parent or parent.uid == 0) then
        return nil
    end
    local holder = nil
    while(true) do
        local tmp = getItemParent(parent.uid)
        if(tmp and tmp.uid ~= 0) then
            if(tmp.itemid == 1) then -- a creature
                holder = tmp
                break
            end
            parent = tmp
        else
            break
        end
    end
    return holder
end
function valid(f)
    return function(p, ...)
        if(isCreature(p)) then
            return f(p, ...)
        end
    end
end
function addContainerItems(container,items)
    local items_mod = {}
    for _, it in ipairs(items) do
        if( isItemStackable(it.id) and it.count > 100) then
            local c = it.count
            while( c > 100 ) do
                table.insert(items_mod,{id = it.id,count = 100})
                c = c - 100
            end
            if(c > 0) then
                table.insert(items_mod,{id = it.id,count = c})
            end
        else
            table.insert(items_mod,{id = it.id,count = 1})
        end
    end
    local free = getContainerCap(container.uid) - (getContainerSize(container.uid) )
    local count = math.ceil(#items_mod/ free)
    local main_bp = container.uid
    local insert_bp = main_bp
    local counter = 1
    for c,it in ipairs(items_mod) do
        local _c = isItemStackable(it.id) and (it.count > 100 and 100 or it.count) or 1
        if count > 1 then
            if (counter < free) then
                doAddContainerItem(insert_bp, it.id, _c)
            else
                insert_bp = doAddContainerItem(insert_bp, container.itemid, 1)
                count = (#items_mod)-(free-1)
                free = getContainerCap(insert_bp) 
                count = math.ceil(count/ free)
                doAddContainerItem(insert_bp, it.id, _c)
                counter = 1
            end
            counter = counter + 1
        else
            doAddContainerItem(insert_bp, it.id, _c)
        end
    end
    return main_bp
end
function getPoints(cid)
local check = db.getResult("SELECT `points` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
return check:getDataInt("points") <= 0 and 0 or check:getDataInt("points") end
function addPoints(cid,amount)
db.Query("UPDATE `players` SET `points` = "..getPoints(cid).."+"..amount.." WHERE `id` = "..getPlayerGUID(cid)) end
function removePoints(cid,amount)
db.Query("UPDATE `players` SET `points` = "..getPoints(cid).."-"..amount.." WHERE `id` = "..getPlayerGUID(cid)) end
function setPoints(cid,value)
db.Query("UPDATE `players` SET `points` = "..value.." WHERE `id` = "..getPlayerGUID(cid)) end  

deu isso


[8/1/2017 22:39:3] [Error - TalkAction Interface] 
[8/1/2017 22:39:4] data/talkactions/scripts/systempoints.lua:onSay
[8/1/2017 22:39:5] Description: 
[8/1/2017 22:39:5] data/lib/050-function.lua:414: attempt to call field 'Query' (a nil value)
[8/1/2017 22:39:6] stack traceback:
[8/1/2017 22:39:6]     data/lib/050-function.lua:414: in function 'addPoints'
[8/1/2017 22:39:7]     data/talkactions/scripts/systempoints.lua:53: in function <data/talkactions/scripts/systempoints.lua:1>

 

Link para o post
Compartilhar em outros sites

onde tiver 'db.Query' troca por 'db.query' ou se não der, use 'db.executeQuery'

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites
15 minutos atrás, Vodkart disse:

onde tiver 'db.Query' troca por 'db.query' ou se não der, use 'db.executeQuery'

Tu é o cara! Reputado.

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo