Fuentes Posted January 5, 2016 Share Posted January 5, 2016 function safeLoadCallback(qh) local result, num = dbPoll(qh, 0) for k, row in ipairs(result) do local safe = createObject(2332, row["x"],row["y"],row["z"],row["interior"],row["dimension"],row["rotation"]) setElementData(safe, "dbId", row["id"]) setElementData(safe, "x", row["x"]) setElementData(safe, "y", row["y"]) setElementData(safe, "z", row["z"]) setElementData(safe, "interior", row["interior"]) setElementData(safe, "rot", row["rotation"]) setElementData(safe, "group", row["group"]) setElementData(safe, "money", row["money"]) setElementData(safe, "kokain", row["kokain"]) setElementData(safe, "heroin", row["heroin"]) setElementData(safe, "matreial", row["material"]) end end function test(player) local money = getElementData(safe, "money") outputChatBox("money: "..money,player, 255, 0, 0) end addCommandHandler("test", test, false, false) Bad argument @ 'getElementData' [Expected element at argument 1, got nil Link to comment
Dazee Posted January 5, 2016 Share Posted January 5, 2016 I believe the error you are getting is because the local money = getElementData(safe, "money") is in a seperate function than the object safe try this function safeLoadCallback(qh) local result, num = dbPoll(qh, 0) for k, row in ipairs(result) do local safe = createObject(2332, row["x"],row["y"],row["z"],row["interior"],row["dimension"],row["rotation"]) setElementData(safe, "dbId", row["id"]) setElementData(safe, "x", row["x"]) setElementData(safe, "y", row["y"]) setElementData(safe, "z", row["z"]) setElementData(safe, "interior", row["interior"]) setElementData(safe, "rot", row["rotation"]) setElementData(safe, "group", row["group"]) setElementData(safe, "money", row["money"]) setElementData(safe, "kokain", row["kokain"]) setElementData(safe, "heroin", row["heroin"]) setElementData(safe, "matreial", row["material"]) function test(player) local money = getElementData(safe, "money") outputChatBox("money: "..money,player, 255, 0, 0) end end end addCommandHandler("test", test, false, false) Tho I'm not sure about this I only had a quick look. Link to comment
Walid Posted January 5, 2016 Share Posted January 5, 2016 function safeLoadCallback(qh) local result, num = dbPoll(qh, 0) for k, row in ipairs(result) do safe = createObject(2332, row["x"],row["y"],row["z"],row["interior"],row["dimension"],row["rotation"]) setElementData(safe, "dbId", row["id"]) setElementData(safe, "x", row["x"]) setElementData(safe, "y", row["y"]) setElementData(safe, "z", row["z"]) setElementData(safe, "interior", row["interior"]) setElementData(safe, "rot", row["rotation"]) setElementData(safe, "group", row["group"]) setElementData(safe, "money", row["money"]) setElementData(safe, "kokain", row["kokain"]) setElementData(safe, "heroin", row["heroin"]) setElementData(safe, "matreial", row["material"]) end end function test(player) local money = getElementData(safe, "money") if money then outputChatBox("money: "..money,player, 255, 0, 0) end end addCommandHandler("test", test) Link to comment
Fuentes Posted January 5, 2016 Author Share Posted January 5, 2016 Bad argument @ 'getEleme ntData' [Expected element at argument 1, got nil] Link to comment
Fuentes Posted January 5, 2016 Author Share Posted January 5, 2016 next getelementdata problem: local groupsafe = tonumber(getElementData(safe, "group")) and mysql datatable 2 safe id 1 safeid:faction1 2 safeid:faction2 script now i faction 1 chatbox test faction 1 safe money please help thank you function safecheck() local teamID = tonumber(getElementData(source, "group")) local groupsafe = tonumber(getElementData(safe, "group")) if teamID >0 then if groupsafe == teamID then outputChatBox ("test ") else outputChatBox ("Not are factionsafe") end else outputChatBox ("Not are faction") end end addEvent("safecheck", true ) addEventHandler("safecheck", getRootElement(),safecheck) Link to comment
Addlibs Posted January 5, 2016 Share Posted January 5, 2016 'safe' is not defined anywhere within 'safecheck' function Link to comment
Fuentes Posted January 6, 2016 Author Share Posted January 6, 2016 'safe' is not defined anywhere within 'safecheck' function please help Link to comment
Addlibs Posted January 6, 2016 Share Posted January 6, 2016 You're attempting to getElementData of a nil value (that is, a variable that is set to nil, or even more simply, the variable is set to nothing or not set at all) 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