GTX Posted July 16, 2012 Posted July 16, 2012 Hi. I researched wiki and I can't find same function for ryden's mysql. Is there any function in ryden's mysql which is similar to or same as dbPoll? Thanks in advance.
Castillo Posted July 16, 2012 Posted July 16, 2012 I don't think dbPoll would be needed on Ryden's MySQL.
Kenix Posted July 17, 2012 Posted July 17, 2012 wiki.multitheftauto.com/wiki/Modules/MTA-MySQL/mysql_fetch_assoc
GTX Posted July 17, 2012 Author Posted July 17, 2012 Okay, nevermind for that. The code below returns this error: attempt to get length of a userdata value. Why? function updateRank() for i, v in ipairs(getElementsByType("player")) do if getElementData(v, "guest_") ~= 1 then local res = sqlC:query("SELECT * FROM accounts WHERE username='"..getElementData(v, "username_").."'") if res then local result = mysql_fetch_assoc(res) local rank = #sqlC:query("SELECT * FROM accounts WHERE points>='" .. result["points"].."'") if rank then setElementData(v, "Rank", rank) end end end end end
Anderl Posted July 17, 2012 Posted July 17, 2012 Okay, nevermind for that.The code below returns this error: attempt to get length of a userdata value. Why? function updateRank() for i, v in ipairs(getElementsByType("player")) do if getElementData(v, "guest_") ~= 1 then local res = sqlC:query("SELECT * FROM accounts WHERE username='"..getElementData(v, "username_").."'") if res then local result = mysql_fetch_assoc(res) local rank = #sqlC:query("SELECT * FROM accounts WHERE points>='" .. result["points"].."'") if rank then setElementData(v, "Rank", rank) end end end end end "sqlC:query" is returning userdata, you can't get length of it. Use "mysql_fetch_assoc" and get length of it.
GTX Posted July 17, 2012 Author Posted July 17, 2012 function updateRank() for i, v in ipairs(getElementsByType("player")) do if getElementData(v, "guest_") ~= 1 then local res = sqlC:query("SELECT * FROM accounts WHERE username='"..getElementData(v, "username_").."'") if res then local result = mysql_fetch_assoc(res) local rank = sqlC:query("SELECT * FROM accounts WHERE points>='" .. result["points"].."'") local r = #mysql_fetch_assoc(rank) if r then setElementData(v, "Rank", r) end end end end end That? It shows 0 for me.
Anderl Posted July 17, 2012 Posted July 17, 2012 function updateRank() for i, v in ipairs(getElementsByType("player")) do if getElementData(v, "guest_") ~= 1 then local res = sqlC:query("SELECT * FROM accounts WHERE username='"..getElementData(v, "username_").."'") if res then local result = mysql_fetch_assoc(res) local rank = sqlC:query("SELECT * FROM accounts WHERE points>='" .. result["points"].."'") local r = #mysql_fetch_assoc(rank) if r then setElementData(v, "Rank", r) end end end end end That? It shows 0 for me. I don't know right cuz I don't use MySQL from much time but should not: "result["points"]" be "result[1].points" or "result[1]['points']"?
Cadu12 Posted July 17, 2012 Posted July 17, 2012 function updateRank() for i, v in ipairs(getElementsByType("player")) do if getElementData(v, "guest_") ~= 1 then local res = sqlC:query("SELECT * FROM accounts WHERE username='"..getElementData(v, "username_").."'") if res then local result = mysql_fetch_assoc(res) local rank = sqlC:query("SELECT * FROM accounts WHERE points>='" .. result["points"].."'") local r = mysql_fetch_assoc(rank) if r then setElementData(v, "Rank", r["points"]) end end end end end
GTX Posted July 17, 2012 Author Posted July 17, 2012 function updateRank() for i, v in ipairs(getElementsByType("player")) do if getElementData(v, "guest_") ~= 1 then local res = sqlC:query("SELECT * FROM accounts WHERE username='"..getElementData(v, "username_").."'") if res then local result = mysql_fetch_assoc(res) local rank = sqlC:query("SELECT * FROM accounts WHERE points>='" .. result["points"].."'") local r = mysql_fetch_assoc(rank) if r then setElementData(v, "Rank", r["points"]) end end end end end This gets my points, and I want to make a "top list". Example: a = 100 points b = 101 points Element data: b = 1 a = 2
GTX Posted July 17, 2012 Author Posted July 17, 2012 Okay, I got it. EDIT: Nevermind, it works now. Thank you Cadu!
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