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. Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
Castillo Posted July 16, 2012 Posted July 16, 2012 I don't think dbPoll would be needed on Ryden's MySQL. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Kenix Posted July 17, 2012 Posted July 17, 2012 wiki.multitheftauto.com/wiki/Modules/MTA-MySQL/mysql_fetch_assoc http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
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 Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
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. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
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. Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
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']"? "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
GTX Posted July 17, 2012 Author Posted July 17, 2012 Then: attempt to index field '?' (a nil value) Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
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 Ingame nick: Cadu12
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 Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
Cadu12 Posted July 17, 2012 Posted July 17, 2012 http://www.w3schools.com/sql/sql_orderby.asp Ingame nick: Cadu12
GTX Posted July 17, 2012 Author Posted July 17, 2012 Okay, I got it. EDIT: Nevermind, it works now. Thank you Cadu! Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS. Developer and owner of https://projectbea.st - Project Beast
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