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

Solved Bonus Hp/Mana Item set problem

The issue isn't with the armor. It's your transformation system.
If you don't post the transformation system we can't tell you what can be changed to fix the issue.
 
as i said, you use
setCreatureMaxHealth together with getCreatureMaxHealth (which returns the max hp you have, WITH bonuses from items
an easy solution is forcing the player to unEquip all items, you can also check each item and see the hp bonus on them and calculate backwards
 
Code:
local function changeStats(cid, outfit, currVoc)
    local newVoc     = currVoc + 1
    local vocInfo = getVocationInfo(newVoc)
    doPlayerSetVocation(cid, newVoc)
    setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + vocInfo.healthGain)
    setCreatureMaxMana(cid, getCreatureMaxMana(cid) + vocInfo.manaGain)
    doCreatureChangeOutfit(cid, outfit)
end

local function checkEq(cid, pos)
    for i = 1, 10 do
        if getPlayerSlotItem(cid, i) then
            doPlayerSendCancel(cid, 'You must take off all equipment before transforming.')
            doSendMagicEffect(pos, CONST_ME_POFF)
            return false
            break
        end
    end
    return true
end

local voc = {
    --// Goku
    [228] = {level = 30, outfit = 149},
    [2]   = {level = 50, outfit = 150},
    [3]   = {level = 100, outfit = 151},
    [4]   = {level = 150, outfit = 152},
    [5]   = {level = 200, outfit = 153},
    [7]   = {level = 50, outfit = 155},
    [8]   = {level = 100, outfit = 156},
    [9]   = {level = 150, outfit = 157}
}

function onSay(cid, words, param)
    local pos = getCreaturePosition(cid)
    local currVoc = getPlayerVocation(cid)
    local tmp = voc[currVoc]
    if not exhaustion.get(cid, 103) then
        if checkEq(cid, pos) then
            if tmp then
                if getPlayerLevel(cid) >= tmp.level then
                    changeStats(cid, tmp.outfit, currVoc)
                else
                    doPlayerSendCancel(cid, 'You need level '.. tmp.level ..' to transform.')
                    doSendMagicEffect(pos, CONST_ME_POFF)
                end
            else
                doPlayerSendCancel(cid, 'Sorry.')
                doSendMagicEffect(pos, CONST_ME_POFF)
            end
        end
    else
        doPlayerSendCancel(cid, 'Slow down.')
    end
    exhaustion.set(cid, 103, 0)
    return true
end
you have to add the rest of the vocations to the table yourself, i did goku for you, follow this:
[vocation id] = {level = x, outfit = y}
no more 2.6k lines of code :|
 
Last edited:
[Error - LuaScriptInterface::loadFile] data/talkactions/scripts/transformation.lua:331: 'end' expected (to close 'if' at line 326) near 'break'
[Warning - Event::loadScript] Cannot load script (data/talkactions/scripts/transformation.lua)
data/talkactions/scripts/transformation.lua:331: 'end' expected (to close 'if' at line 326) near 'break'

Help please? @Xeraphus
Code:
local function checkEq(cid, pos)
    for i = 1, 10 do
        if getPlayerSlotItem(cid, i) then
            doPlayerSendCancel(cid, 'You must take off all equipment before transforming.')
            doSendMagicEffect(pos, CONST_ME_POFF)
            return false
        end
    end
    return true
end
dunno if you can ret false before breaking loop
 
No error in console but, I cant transform now It says " You must take off all equipment before transforming"
Sorry Im new to coding.
that's the point.
since you can't get the health/mana percent values on the eq unless you parse items.xml, you have to remove your eq first before transforming
 
Code:
function onSay(cid, words, param)
    local pos = getCreaturePosition(cid)
    local currVoc = getPlayerVocation(cid)
    local tmp = voc[currVoc]
    if not exhaustion.get(cid, 103) then
        if checkEq(cid, pos) then
            print(1)
            if tmp then
                print(2)
                if getPlayerLevel(cid) >= tmp.level then
                    print('2-1')
                    changeStats(cid, tmp.outfit, currVoc)
                else
                    print('2-2')
                    doPlayerSendCancel(cid, 'You need level '.. tmp.level ..' to transform.')
                    doSendMagicEffect(pos, CONST_ME_POFF)
                end
            else
                print(3)
                doPlayerSendCancel(cid, 'Sorry.')
                doSendMagicEffect(pos, CONST_ME_POFF)
            end
        end
    else
        print(4)
        doPlayerSendCancel(cid, 'Slow down.')
    end
    exhaustion.set(cid, 103, 0)
    return true
end
tell me what it prints
 
I guess I did something wrong or thats the result you wanted ?

[Error - TalkAction Interface]
data/talkactions/scripts/transformation.lua; onSay
Description: data/talkactions/scripts/transformation.lua:92: attempt to index global 'voc' (a nil value)
stack traceback:
data/talkactions/scripts/transformation.lua:92: in function <data/talkactions/scripts/transformation.lua:89>
upload the script to pastebin or something
shouldn't be getting that error unless you are an incorrect voc or you set up the table incorrectly
 
Back
Top