• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Use 100x item if have 100 item

itzbrhue3

New Member
Joined
Feb 21, 2017
Messages
41
Solutions
1
Reaction score
1
Lua:
local config = {
    [12782] = {exp = 97001, lvl = 79001, typ3="Hitpoints"},
    [12783] = {exp = 97002, lvl = 79002, typ3="Manapoints"},
    [12784] = {exp = 97003, lvl = 79003, typ3="Magic Level"},
    [12785] = {exp = 97004, lvl = 79004, typ3="Melee"},
    --[?] = {exp = 97005, lvl = 79005, type="SHIELD"},
    [12786] = {exp = 97006, lvl = 79006, typ3="Distance"},
    --[?] = {exp = 97007, lvl = 79007, typ3="Hp Recovery"},
    --[?] = {exp = 97008, lvl = 79008, typ3="Mp Recovery"},
}


function onUse(cid, item, fromPosition, itemEx, toPosition)
    for key, value in pairs(config) do
        if item.itemid == key then
            local experience = getPlayerStorageValue(cid, value.exp)
            local level = getPlayerStorageValue(cid, value.lvl)
            doPlayerSetStorageValue(cid, value.exp, experience + 1)
            if experience >= math.ceil((level ^ 3) / 2) then
                doPlayerSetStorageValue(cid, value.lvl, level + 1)
                doSendMagicEffect(getPlayerPosition(cid), 27)
                doPlayerSendTextMessage(cid, 19, "[SKILL BONUS] ".. value.typ3 .." has increase to level ".. level + 1 ..".")
            end
            local exp_need = math.ceil((level ^ 3) / 2) - math.ceil(((level - 1) ^ 3) / 2)
            local exp = experience - math.ceil((level ^ 3) / 2) + exp_need
            doPlayerSendTextMessage(cid, 26, "[".. exp .."/".. exp_need .."]")
        end
    end
    doRemoveItem(item.uid, 1)
    return true
end
i maked this script, but it would be possible player use 100x item if have this item?
 
Lua:
local config = {
    [12782] = {exp = 97001, lvl = 79001, typ3="Hitpoints"},
    [12783] = {exp = 97002, lvl = 79002, typ3="Manapoints"},
    [12784] = {exp = 97003, lvl = 79003, typ3="Magic Level"},
    [12785] = {exp = 97004, lvl = 79004, typ3="Melee"},
    --[?] = {exp = 97005, lvl = 79005, type="SHIELD"},
    [12786] = {exp = 97006, lvl = 79006, typ3="Distance"},
    --[?] = {exp = 97007, lvl = 79007, typ3="Hp Recovery"},
    --[?] = {exp = 97008, lvl = 79008, typ3="Mp Recovery"},
}


function onUse(cid, item, fromPosition, itemEx, toPosition)
    for key, value in pairs(config) do
        if item.itemid == key then
            local experience = getPlayerStorageValue(cid, value.exp)
            local level = getPlayerStorageValue(cid, value.lvl)
            doPlayerSetStorageValue(cid, value.exp, experience + 1)
            if experience >= math.ceil((level ^ 3) / 2) then
                doPlayerSetStorageValue(cid, value.lvl, level + 1)
                doSendMagicEffect(getPlayerPosition(cid), 27)
                doPlayerSendTextMessage(cid, 19, "[SKILL BONUS] ".. value.typ3 .." has increase to level ".. level + 1 ..".")
            end
            local exp_need = math.ceil((level ^ 3) / 2) - math.ceil(((level - 1) ^ 3) / 2)
            local exp = experience - math.ceil((level ^ 3) / 2) + exp_need
            doPlayerSendTextMessage(cid, 26, "[".. exp .."/".. exp_need .."]")
        end
    end
    doRemoveItem(item.uid, 1)
    return true
end
i maked this script, but it would be possible player use 100x item if have this item?

You could detect how many stacks of the item the player has with
local totalStacks = getPlayerItemCount(cid, item.id) and increase values based on a multiplier of that count.

Just make sure to then also remove that amount of stacks with doRemoveItem(item.uid, totalStacks).

You could limit the count to 100 max by using math.min(100, totalStacks).
 
You could detect how many stacks of the item the player has with
local totalStacks = getPlayerItemCount(cid, item.id) and increase values based on a multiplier of that count.

Just make sure to then also remove that amount of stacks with doRemoveItem(item.uid, totalStacks).

You could limit the count to 100 max by using math.min(100, totalStacks).
Lua:
local config = {
    [12782] = {exp = 97001, lvl = 79001, typ3="Hitpoints"},
    [12783] = {exp = 97002, lvl = 79002, typ3="Manapoints"},
    [12784] = {exp = 97003, lvl = 79003, typ3="Magic Level"},
    [12785] = {exp = 97004, lvl = 79004, typ3="Melee"},
    --[?] = {exp = 97005, lvl = 79005, type="SHIELD"},
    [12786] = {exp = 97006, lvl = 79006, typ3="Distance"},
    --[?] = {exp = 97007, lvl = 79007, typ3="Hp Recovery"},
    --[?] = {exp = 97008, lvl = 79008, typ3="Mp Recovery"},
}


function onUse(cid, item, fromPosition, itemEx, toPosition)
    local totalStacks = math.min(100, getPlayerItemCount(cid, item.id))
    for key, value in pairs(config) do
        if item.itemid == key then
            local experience = getPlayerStorageValue(cid, value.exp)
            local level = getPlayerStorageValue(cid, value.lvl)
            if totalStacks == 100 then
                doPlayerSetStorageValue(cid, value.exp, experience + totalStacks)
            else
                doPlayerSetStorageValue(cid, value.exp, experience + totalStacks)
            end
            if experience >= math.ceil((level ^ 3) / 2) then
                doPlayerSetStorageValue(cid, value.lvl, level + 1)
                doSendMagicEffect(getPlayerPosition(cid), 27)
                doPlayerSendTextMessage(cid, 19, "[SKILL BONUS] ".. value.typ3 .." has increase to level ".. level + 1 ..".")
            end
            local exp_need = math.ceil((level ^ 3) / 2) - math.ceil(((level - 1) ^ 3) / 2)
            local exp = experience - math.ceil((level ^ 3) / 2) + exp_need
            doPlayerSendTextMessage(cid, 26, "[".. exp .."/".. exp_need .."]")
        end
    end
    print(totalStacks)
    if totalStacks == 100 then
        doRemoveItem(item.uid, totalStacks)
    else
        doRemoveItem(item.uid, 1)
    end
    return true
end
so i maked this but if player use 1 + 99 increase 100 storage and no remove items
 
Lua:
local config = {
    [12782] = {exp = 97001, lvl = 79001, typ3="Hitpoints"},
    [12783] = {exp = 97002, lvl = 79002, typ3="Manapoints"},
    [12784] = {exp = 97003, lvl = 79003, typ3="Magic Level"},
    [12785] = {exp = 97004, lvl = 79004, typ3="Melee"},
    --[?] = {exp = 97005, lvl = 79005, type="SHIELD"},
    [12786] = {exp = 97006, lvl = 79006, typ3="Distance"},
    --[?] = {exp = 97007, lvl = 79007, typ3="Hp Recovery"},
    --[?] = {exp = 97008, lvl = 79008, typ3="Mp Recovery"},
}


function onUse(cid, item, fromPosition, itemEx, toPosition) 
    local isInTable = config[item.itemid]
    if isInTable then
        local count = getPlayerItemCount(cid, item.itemid)
        if count and count > 0 then
            local experience = getPlayerStorageValue(cid, isInTable.exp)
            local level = getPlayerStorageValue(cid, isInTable.lvl)
            doPlayerSetStorageValue(cid, isInTable.exp, experience + count)
            if experience >= math.ceil((level ^ 3) / 2) then
                doPlayerSetStorageValue(cid, isInTable.lvl, level + count)
                doSendMagicEffect(getPlayerPosition(cid), 27)
                doPlayerSendTextMessage(cid, 19, "[SKILL BONUS] ".. isInTable.typ3 .." has increase to level ".. level + 1 ..".")
            end
            local exp_need = math.ceil((level ^ 3) / 2) - math.ceil(((level - 1) ^ 3) / 2)
            local exp = experience - math.ceil((level ^ 3) / 2) + exp_need
            doPlayerSendTextMessage(cid, 26, "[".. exp .."/".. exp_need .."]")
            doPlayerRemoveItem(cid, item.uid, count)
        end
    end     
  
  
    return true
end
 
Last edited:
Lua:
local config = {
    [12782] = {exp = 97001, lvl = 79001, typ3="Hitpoints"},
    [12783] = {exp = 97002, lvl = 79002, typ3="Manapoints"},
    [12784] = {exp = 97003, lvl = 79003, typ3="Magic Level"},
    [12785] = {exp = 97004, lvl = 79004, typ3="Melee"},
    --[?] = {exp = 97005, lvl = 79005, type="SHIELD"},
    [12786] = {exp = 97006, lvl = 79006, typ3="Distance"},
    --[?] = {exp = 97007, lvl = 79007, typ3="Hp Recovery"},
    --[?] = {exp = 97008, lvl = 79008, typ3="Mp Recovery"},
}


function onUse(cid, item, fromPosition, itemEx, toPosition) 
    local isInTable = config[item.itemid]
    if isInTable then
        local count = getPlayerItemCount(cid, item.itemid)
        if count and count > 0 then
            local experience = getPlayerStorageValue(cid, isInTable.exp)
            local level = getPlayerStorageValue(cid, isInTable.lvl)
            doPlayerSetStorageValue(cid, isInTable.exp, experience + count)
            if experience >= math.ceil((level ^ 3) / 2) then
                doPlayerSetStorageValue(cid, isInTable.lvl, level + count)
                doSendMagicEffect(getPlayerPosition(cid), 27)
                doPlayerSendTextMessage(cid, 19, "[SKILL BONUS] ".. isInTable.typ3 .." has increase to level ".. level + 1 ..".")
            end
            local exp_need = math.ceil((level ^ 3) / 2) - math.ceil(((level - 1) ^ 3) / 2)
            local exp = experience - math.ceil((level ^ 3) / 2) + exp_need
            doPlayerSendTextMessage(cid, 26, "[".. exp .."/".. exp_need .."]")
            doRemoveItem(item.uid, count)
        end
    end     
  
  
    return true
end
same bug, player use 1 + 99 in bag and increase 100 storage but no remove items
 
same bug, if player split 100 and use item increase stor and no remove items
Lua:
local config = {
    [12782] = {exp = 97001, lvl = 79001, typ3="Hitpoints"},
    [12783] = {exp = 97002, lvl = 79002, typ3="Manapoints"},
    [12784] = {exp = 97003, lvl = 79003, typ3="Magic Level"},
    [12785] = {exp = 97004, lvl = 79004, typ3="Melee"},
    --[?] = {exp = 97005, lvl = 79005, type="SHIELD"},
    [12786] = {exp = 97006, lvl = 79006, typ3="Distance"},
    --[?] = {exp = 97007, lvl = 79007, typ3="Hp Recovery"},
    --[?] = {exp = 97008, lvl = 79008, typ3="Mp Recovery"},
}


function onUse(cid, item, fromPosition, itemEx, toPosition)
    local isInTable = config[item.itemid]
    if isInTable then
        local count = getPlayerItemCount(cid, item.itemid)
        if count >= 1 then
            doRemoveItem(item.uid, count)
            local experience = getPlayerStorageValue(cid, isInTable.exp)
            local level = getPlayerStorageValue(cid, isInTable.lvl)
            doPlayerSetStorageValue(cid, isInTable.exp, experience + count)
            if experience >= math.ceil((level ^ 3) / 2) then
                doPlayerSetStorageValue(cid, isInTable.lvl, level + count)
                doSendMagicEffect(getPlayerPosition(cid), 27)
                doPlayerSendTextMessage(cid, 19, "[SKILL BONUS] ".. isInTable.typ3 .." has increase to level ".. level + 1 ..".")
            end
            local exp_need = math.ceil((level ^ 3) / 2) - math.ceil(((level - 1) ^ 3) / 2)
            local exp = experience - math.ceil((level ^ 3) / 2) + exp_need
            doPlayerSendTextMessage(cid, 26, "[".. exp .."/".. exp_need .."]")
        end
    end     
 
 
    return true
end
 
Back
Top