• 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:
recorded yes.
here as this
Code:
registerCreatureEvent (cid, "AttributePoints")
getPlayerStorageValue if (cid, 47061) <0 then
setPlayerStorageValue (cid, 47061.0)
end

and
Code:
<event type="advance" name="AttributePoints" event="script" value="attribute_points.lua"/>

NOTE: not only is this script, as in other mod cybershot of such an error also, I'm using TFS 0.3.6 (8.60)
 
Lua:
function onAdvance(cid, oldlevel, newlevel)
local cfg = {
	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, cfg.addhp) -- will give max hp level up after
     doPlayerAddMana(cid, cfg.addmana) -- Will give Max mana after level up
	setPlayerStorageValue(cid, 47061, cfg.add) -- Will add attribute points after level 2
end
return true
end
 
Lua:
function onAdvance(cid, oldlevel, newlevel)
local cfg = {
	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, cfg.addhp) -- will give max hp level up after
     doPlayerAddMana(cid, cfg.addmana) -- Will give Max mana after level up
	setPlayerStorageValue(cid, 47061, cfg.add) -- Will add attribute points after level 2
end
return true
end

did not work
 
it would be easier help you if you say what the heck do you want in your script

Lua:
function onAdvance (cid, oldlevel, newlevel)
	local config = {
		addmana = getPlayerMaxMana (cid),
		addhp =  getCreatureMaxHealth (cid),
		add = (getPlayerStorageValue (cid, 47061) + (newlevel - oldlevel)) * 2
	}
	local pos = getPlayerPosition (cid)

	if (oldlevel < newlevel) then
		doSendAnimatedText (pos, "Level Up", 129) -- will show the hovering text of "Level Up"
		doSendMagicEffect (pos, 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
 
Did you registred this even on login.lua? If not register it and it may work!
jh2.jpg

22.jpg

6.jpg
 
already registered, and before taking all normal.
but I was changing some scripts version and give this error
Code:
attempt to perform arithmetic on a string value
for a while everything is normal, then the database (this storage script) gets a few symbols (in some players)
 
mean my storage and 47061 others bugged that is causing this?
if I change 47061 to 00101 (even not coming only getting 00 101) will work normal?

EDIT:I tried changing the values ​​of storage and yet still gives this error
I do not know what to do, I've only distro I changed storage '-'
if it was only with this script I disabled it, but they are with various
 
Last edited:
Lua:
config = 
{
	mana = {type = "percent", value = 100},
	health = {type = "number", value = 500},
	storage = {key = 47061, value = 1, per = 2}
}

function onAdvance(cid, skill, oldlevel, newlevel)
	if (skill == SKILL__LEVEL and newLevel > oldLevel) then
		local pos = getThingPosition(cid)
		doSendAnimatedText(pos, "Level Up", COLOR_GREY)
		doSendMagicEffect(pos, math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
		if (config.health.type == "percent") then
			doCreatureAddHealth(cid, math.ceil(config.health.value * getCreatureHealth(cid) / 100))
		elseif (config.health.type == "number") then
			doCreatureAddHealth(cid, config.health.value)
		end
		if (config.mana.type == "percent") then
			doCreatureAddMana(cid, math.ceil(config.mana.value * getCreatureMana(cid) / 100))
		elseif (config.mana.type == "number") then
			doCreatureAddMana(cid, config.mana.value)
		end
		if (getCreatureStorage(cid, storage.key) == -1) then
			doCreatureSetStorage(cid, storage.key, 0)
		end
		if (newLevel % config.stoage.per == 0) then
			doCreatureSetStorage(cid, config.storage.key, getCreatureStorage(cid, config.storage.key) + config.storage.value)
		end
	end
endconfig = 
{
	mana = {type = "percent", value = 100},
	health = {type = "number", value = 500},
	storage = {key = 47061, value = 1, per = 2}
}

function onAdvance(cid, skill, oldlevel, newlevel)
	if (skill == SKILL__LEVEL and newLevel > oldLevel) then
		local pos = getThingPosition(cid)
		doSendAnimatedText(pos, "Level Up", COLOR_GREY)
		doSendMagicEffect(pos, math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
		if (config.health.type == "percent") then
			doCreatureAddHealth(cid, math.ceil(config.health.value * getCreatureHealth(cid) / 100))
		elseif (config.health.type == "number") then
			doCreatureAddHealth(cid, config.health.value)
		end
		if (config.mana.type == "percent") then
			doCreatureAddMana(cid, math.ceil(config.mana.value * getCreatureMana(cid) / 100))
		elseif (config.mana.type == "number") then
			doCreatureAddMana(cid, config.mana.value)
		end
		if (getCreatureStorage(cid, storage.key) == -1) then
			doCreatureSetStorage(cid, storage.key, 0)
		end
		if (newLevel % config.stoage.per == 0) then
			doCreatureSetStorage(cid, config.storage.key, getCreatureStorage(cid, config.storage.key) + config.storage.value)
		end
	end
end
 
this is not what I want; x
want to know how to fix this problem
Code:
attempt to perform arithmetic on a string value
because I have several scripts of this error, and from what I saw in the script above will not do the same thing the previous

if you can explain how to solve: D

Thank you!
 
Well this problem should occur if you do like that for example:
Lua:
local f = "a"/2

Well, when performing a mathematical operation on a string!!( I guess)
 
this is the line that the error
I think it's all right, but if not a scripter and want / can help thank you.
Lua:
add = (getPlayerStorageValue (cid, 47061) + (-newlevel oldlevel) * 2)
 
Back
Top