• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Scripts Outdated

_Aion_

Nothing Else
Joined
Jan 19, 2010
Messages
401
Solutions
4
Reaction score
10
Location
Jequie,Bahia,Brazil
Please can someone help fix some scripts?
always the same errors in various scripts, and scripts are essential to my OT.
Erro N°1 = attempt to compare number with string
Erro N°2 = attempt to perform arithmetic on a nil value

and the database is not getting the values​​, the script is corrupting and is getting some strange symbols (see the image below)
Capturar.JPG

I do not know what to do if someone has a "light" and wants to help me.

NOTE: Most of the scripts that are giving this error, scripts are the TFS 0.3.4

Thanks to all and sorry my bad english, because i'm brazilian.
 
Here is scripts
LUA:
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)
    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

NOTE: this script is essential for my OT...
I do not know what to do if you can help me: D
 
Last edited:
Your file can be saved in several kinds of encodings, the text of it. I'd use UTF-8.
9xypC.png

(without byte order mark (BOM) is preferred)
 
but I believe that there is error in notepad or another editor ...
but the script that are corrupting the database, I am a layman on the subject.

explaining better: scripts works for awhile and then corrupt the database in some storage
 
Code:
local addattribute = tonumber(getPlayerStorageValue(cid, 47061)) + (newlevel - oldlevel) * 2 --- this is the line that corrupts the database and this is error that show in console "attempt to perform arithmetic on a nil value"


addattribute = numeric value of storage 47061 + (newlevel-oldlevel) x 2

so.. if newlevel = 59 and oldlevel = 58 you get 1

numeric value of storage 47061+1x2 = x+1*2 = x+2

why is there a tonumber? isnt it stored in numbers to begin with?
setPlayerStorageValue(cid, 47061, addattribute)
setPlayerStorageValue(cid, 47061, x+2)
lets pretend its 0
tonumber (nil)+(59-58)*2 = nil2
nil2 + 1 * 2 = nil6
nil6 + 1 * 2 = nil14
nil14 + 1 * 2 = nil30
nil30 + 1 * 2 = nil62
nil62 + 1 * 2 = nil126
nil126 + 1 * 2 = nil154
nil154 + 1 * 2 = nil310
setPlayerStorageValue(cid, 47061, nil310)
etc etc..
Can you tell me what x is? What is the default of storage 47061?
 
Last edited:
Back
Top