• 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 doPlayerAddMagLevel(cid, getPlayerMagLevel(cid) * (-1) + 70) is not working...

arbuzzo

New Member
Joined
Dec 11, 2012
Messages
22
Reaction score
0
Hi, I'm wondering why is my lua script not working, more precisely, this part:

Code:
doPlayerAddMagLevel(cid, getPlayerMagLevel(cid) * (-1) + 70)

I'm using very similar formula in order to change character's level and it works fine

Code:
doPlayerAddLevel(cid, getPlayerLevel(cid) * (-1) + 120, 1)

This maglevel line adds like 1 or 0,99 of mlvl but nothing else happens. I have to cast 'exura' manually to get next lvl.
I've checked lua documentation of my release (tfs 8.54) and both doPlayerAddMagLevel and getPlayerMagLevel are finished (not marked as // TODO)
 
The function does not work as it should if I recall correctly.
It is corrected in 0.3.7-preview and naturally in 0.4x

I'll take a quick poke around for you, because this same issue pissed me off a lot a year or so ago.

0.3.6 pl1
luascript.cpp
Code:
  //doPlayerAddSkillTry(cid, skillid, n[, useMultiplier])
        lua_register(m_luaState, "doPlayerAddSkillTry", LuaScriptInterface::luaDoPlayerAddSkillTry);
050-function.lua
Code:
function doPlayerAddSkill(cid, skill, amount, round)
        if(skill == SKILL__LEVEL) then
                return doPlayerAddLevel(cid, amount, round)
        elseif(skill == SKILL__MAGLEVEL) then
                return doPlayerAddMagLevel(cid, amount)
        end

        return doPlayerAddSkillTry(cid, skill, (getPlayerRequiredSkillTries(cid, skill, getPlayerSkillLevel(cid, skill) + 1) - getPlayerSkillTries(cid, skill)) / getConfigInfo('rateSkill'))
end

...

function doPlayerAddMagLevel(cid, amount)
        for i = 1, amount do
                doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid)) / getConfigInfo('rateMagic'))
        end
        return true
end

0.3.7-preview
luascript.cpp -- this part is the same as 0.3.6
Code:
 //doPlayerAddSkillTry(cid, skillid, n[, useMultiplier = true])
        lua_register(m_luaState, "doPlayerAddSkillTry", LuaInterface::luaDoPlayerAddSkillTry);

050-function.lua NOTE THAT THIS SECTION DIFFERS FROM 0.3.6
Code:
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 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

I hope this helped you somehow.
 
Back
Top