• 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 attempt to perform arithmetic on a string value - Help

_Aion_

Nothing Else
Joined
Jan 19, 2010
Messages
400
Solutions
4
Reaction score
10
Location
Jequie,Bahia,Brazil
Hello I would like to know how can I fix this problem>> attempt to perform arithmetic on a string value <<
've changed my distro several times, looked at the lib and I think it's all normal.
the database was to be a numbers example: 31231321454 and is getting '* Y (some strange symbols)
appears in this distro.


Code:
[25.12.2011 16:00:15] [Error - CreatureScript Interface]
[12/25/2011 16:00:15] data / creaturescripts / scripts / attribute_points.lua: onAdvance
[12/25/2011 16:00:15] Description:
[12/25/2011 16:00:15] data / creaturescripts / scripts / attribute_points.lua: 6: attempt to perform arithmetic on a string value
[12/25/2011 16:00:15] stack traceback:
[12/25/2011 16:00:15] data / creaturescripts / scripts / attribute_points.lua: 6: in function <data/creaturescripts/scripts/attribute_points.lua:1>

Here is the script
Code:
function onAdvance(cid, skill, oldlevel, newlevel)
	if skill == 8 then
		if oldlevel < newlevel then
    local addmana = getPlayerMaxMana(cid)
    local addhp = getCreatureMaxHealth(cid)
	local addattribute = (getPlayerStorageValue(cid, 47061)+(newlevel-oldlevel)*2) -- this is the line that corrupts the database and displays this error "attempt to perform arithmetic on a string value"
    doSendAnimatedText(getPlayerPosition(cid), "Level UP", 129)
    doSendMagicEffect(getPlayerPosition(cid),math.random(28, 30))
    doCreatureAddHealth(cid, addhp)
    doPlayerAddMana(cid, addmana)
	setPlayerStorageValue(cid, 47061, addattribute)
		end
	end
	return true
end

this is not just the script that this error, even in the MOD cybershot an error like this, I would like to know how to solve this problem because I'm having a lot of headaches.

Thank you.

sorry for my bad English
 
Last edited:
is there another script that sets a value to key '47061' other than this script?? I assume there is since, you never check is 47061 is a nill, so there must be another script setting up a value that is not an integer.
 
there was for normal functioning, but is giving this error and even putting it in another storage the same error.
being that has no string = "test" in the script, and in several script is giving this error even in the MOD (REP) of the cybershot.
I do not know what I can do and can not disable these scripts because they are very essential for my OTServ.
 
Did you registred this even on login.lua? If not register it and it may work!
jh2.jpg

22.jpg

6.jpg
 
the error is not this script, it is one of.
all recorded this normal, he works for a time deposed the database "corrupt" instead of getting numbers is getting a few symbols.
 
Like Doggynub said before, this error happens when you try to perform a mathematical operation in a string

Lua:
function onAdvance (cid, oldlevel, newlevel)
    local config = {
        addmana = getPlayerMaxMana(cid)
        addhp = getCreatureMaxHealth(cid)
        add = (getPlayerStorageValue (cid, 47061) + (newlevel-oldlevel) * 2)
    }
    if oldlevel < newlevel then
        doSendAnimatedText (getPlayerPosition (cid), "Level Up", 129) - will show the hovering text of "Level Up"
        doSendMagicEffect (getPlayerPosition (cid), math.random (28, 30)) - will show the range of fireworks
        doCreatureAddHealth (cid, config.addhp) - will give max hp level up after
        doPlayerAddMana (cid, config.addmana) - Will give Max mana after level up
        setPlayerStorageValue (cid, 47061, config.add) - Will add attribute points after level 2
    end
    return true
end
Your script should now work

If you have more scripts with this problem, you can add me on MSN(check my profile) and I'll help you there, it's faster and easier :p
 
Back
Top