• 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!

Lua item upgrade - how change %?

giddy92

New Member
Joined
Aug 8, 2014
Messages
69
Reaction score
0
I want to change it, to give from 1% to 10% (first script)
And second give always 5%. (second script)
How to do it?


Code:
local conf = {
maxSlotCount=3,
ignoredIds={}
}

function choose(...)
    local arg = {...}
    return arg[math.random(1,#arg)]
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.uid == 0 or item.itemid == 0 then return false end
    toPosition.stackpos = 255
    if isInArray(conf.ignoredIds, itemEx.itemid)
        or (not getItemWeaponType(itemEx.uid) or getItemWeaponType(itemEx.uid) > 5)
        or (getItemWeaponType(itemEx.uid) == 0 and not isArmor(itemEx.uid))
        or itemEx.itemid == 0 or itemEx.type > 1 or isItemStackable(itemEx.uid) then
        return false
    end
    if isCreature(itemEx.uid) then
        return false
    end
    local nam = Item(itemEx.uid):getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
    function getper()
        local n = 1
        for i=1,10 do
            n = n+math.random(0,10)
            if n < 8*i then
                break
            end
        end
        return n
    end
    function getSlotCount(nam)
        local c = 0
        for _ in nam:gmatch('%[(.-)%]') do
            c = c+1
        end
        return c
    end
    if getSlotCount(nam) < conf.maxSlotCount then
        local l = choose('dist')
        local p = getper()
        doSendMagicEffect(toPosition,30)
        nam = nam..' ['..l..'.+'..p..'%]'
        doPlayerSendTextMessage(cid, 20,l..'.+'..p..'%')
        doSetItemSpecialDescription(itemEx.uid, nam)
        doRemoveItem(item.uid,1)
    else
        doPlayerSendTextMessage(cid, 20,"Slot limit reached.")
    end
    return true
end
 
People don't want to help unless you tell them which distribution you are using... Usually best to have that in the title I think...
I am sure its tfs 1.0, but where is your second script? And I am not entirely sure but if you are saying it always adds 1-10 percent then I would have to say here is what you need to change...

Code:
n = n+math.random(0,10)
to
Code:
 n = n+5
to make it always add 5%
 
Yea, its tfs 1.0 sorry.
My English is so bad :|

I meant the second solution
First, the script always gives 5%
Second, that the same script will give you randomly from 1 to 10%
 
Back
Top