Hypnos Posted June 21, 2015 Share Posted June 21, 2015 My script have one error. I'am starting a script and this error in debugscript; Line 28: attemp to compare nil with number exprequired = {} addEventHandler("onResourceStart", resourceRoot, function () for i, thePlayer in ipairs(getElementsByType("player")) do theAccount = getPlayerAccount(thePlayer) if (theAccount) and not (isGuestAccount(theAccount)) then file = xmlLoadFile("exp_oranlari.xml") for i, node in ipairs (xmlNodeGetChildren(file)) do EXPRequired = tonumber(xmlNodeGetAttribute(node, "EXPRequired")) table.insert(exprequired, EXPRequired) end experience = tonumber(getAccountData(theAccount, "experience")) experience_t = tonumber(getAccountData(theAccount, "experience_t")) setElementData(thePlayer, "experience", experience or 0) setElementData(thePlayer, "experience_r", tonumber(exprequired[level or 1])) end end end) addEventHandler("onElementDataChange", getRootElement(), function (dataName) if (getElementType(source) == "player") and (dataName == "experience") then theAccount = getPlayerAccount(source) if (theAccount) and not (isGuestAccount(theAccount)) then experience = getElementData(source, "experience") experience_r = getElementData(source, "experience_r") if (experience >= tonumber(experience_r)) then .... Help me Link to comment
Walid Posted June 21, 2015 Share Posted June 21, 2015 Try this addEventHandler("onElementDataChange", getRootElement(), function (dataName) if (getElementType(source) == "player") and (dataName == "experience") then local theAccount = getPlayerAccount(source) if (theAccount) and not (isGuestAccount(theAccount)) then local experience = getElementData(source, "experience") or 0 local experience_r = getElementData(source, "experience_r") or 0 if (experience >= tonumber(experience_r)) then -- Your code here end end end end ) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now