Controlled Posted January 4, 2014 Share Posted January 4, 2014 local gameAccountID = getElementData(thePlayer, "account:id") local dbid = getElementData(thePlayer, "dbid") mResult2 = exports.mysql:query_fetch_assoc("SELECT `vp` FROM `accounts` WHERE `id`='".. tostring(gameAccountID) .."'") Stats = tonumber(mResult2["vp"]) elseif (Stats>0) then setPlayerNametagColor(thePlayer, 167, 133, 63) Error is Number with Nil on elseif line. How can 0 be Nil? lol I tried writing it like Stats > 0 Stats>0 (Stats > 0) (Stats>0) All the same lol Link to comment
xXMADEXx Posted January 4, 2014 Share Posted January 4, 2014 0 isn't nil, "Stats" is returning nil. Link to comment
Controlled Posted January 4, 2014 Author Share Posted January 4, 2014 Wouldn't that be Nil with Number? Not Number with Nil? Link to comment
WASSIm. Posted January 4, 2014 Share Posted January 4, 2014 local gameAccountID = getElementData(thePlayer, "account:id") local dbid = getElementData(thePlayer, "dbid") mResult2 = exports.mysql:query_fetch_assoc("SELECT `vp` FROM `accounts` WHERE `id`='".. tostring(gameAccountID) .."'") if (mResult2) then Stats = tonumber(mResult2[1]["vp"]) if (Stats>0) then setPlayerNametagColor(thePlayer, 167, 133, 63) end end Link to comment
Controlled Posted January 4, 2014 Author Share Posted January 4, 2014 And I thought that at first too, so I made this. function old( thePlayer ) if thePlayer then local logged = getElementData(thePlayer, "loggedin") if (logged==1) then local gameAccountID = getElementData(thePlayer, "account:id") local dbid = getElementData(thePlayer, "dbid") mResult2 = exports.mysql:query_fetch_assoc("SELECT `vp` FROM `accounts` WHERE `id`='".. tostring(gameAccountID) .."'") Stats = tonumber(mResult2["vp"]) if (Stats>0) then outputChatBox("You have", thePlayer) else outputChatBox("You don't", thePlayer) end end end end addCommandHandler("checkVP", old) It worked fine without errors. Link to comment
Controlled Posted January 4, 2014 Author Share Posted January 4, 2014 local gameAccountID = getElementData(thePlayer, "account:id") local dbid = getElementData(thePlayer, "dbid") mResult2 = exports.mysql:query_fetch_assoc("SELECT `vp` FROM `accounts` WHERE `id`='".. tostring(gameAccountID) .."'") if (mResult2) then Stats = tonumber(mResult2[1]["vp"]) if (Stats>0) then setPlayerNametagColor(thePlayer, 167, 133, 63) end end Returns the Error, Attempt to Index Field "?" (A Nil Value) on Stats = tonumber(mResult2[1]["vp"] Link to comment
WASSIm. Posted January 4, 2014 Share Posted January 4, 2014 function old( thePlayer ) if thePlayer then local logged = getElementData(thePlayer, "loggedin") if (logged==1) then local gameAccountID = getElementData(thePlayer, "account:id") local dbid = getElementData(thePlayer, "dbid") mResult2 = exports.mysql:query_fetch_assoc("SELECT `vp` FROM `accounts` WHERE `id`='".. tostring(gameAccountID) .."'") if (mResult2 and mResult2[1]["vp"]) then Stats = tonumber(mResult2[1]["vp"]) if (Stats>0) then outputChatBox("You have", thePlayer) else outputChatBox("You don't", thePlayer) end end end end end addCommandHandler("checkVP", old) Link to comment
Controlled Posted January 4, 2014 Author Share Posted January 4, 2014 That script is not the issue. The one I posted before is the issue. 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