Zafire Posted July 24, 2011 Share Posted July 24, 2011 Hi, i need to create multi-dimensional arrays for load data of a player from a mysql table i have this ----------------------------------------- Cargar Stats ---------------------------------------- function cargarStats(usuario) local resultado = mysql_query(coneccion_mysql, "SELECT * FROM usuarios WHERE usuario='"..usuario.."'") dato[player] = mysql_fetch_assoc(resultado) end ----------------------------------------------------------------------------------------------- but it doesnt works, i think you understand me i want to load data of a player so i need something like data[player]["money"].. i have to use that player because if something login and his name is Maria i use data["Maria"]["money"].. if i dont use that array for everyonee single user, will be buggy because will be the same var for all.. Help me pls, thx god bless u Link to comment
DarkLink Posted July 24, 2011 Share Posted July 24, 2011 What do you need to do is make a table as dictionaires. You can read about it here: http://lua-users.org/wiki/TablesTutorial Then would be something like: t = { maria="hermoneyhere", darklink="hismoneyhere", john="hismoneyhere" } Then guess you want to print the money of all players? Something like: for k,v in pairs(t) do outputChatBox(k .. " has this money: " .. v) end Then would appear on console something like: maria has this money: 233 --int depending on his money, can be a data node of the player. darklink has this money: 712 john has this money: 100 ofc I am the richest :b I hope I could help you. PS: I think you are portuguese? maybe brasil? Link to comment
Zafire Posted July 25, 2011 Author Share Posted July 25, 2011 thxx for help!! but i try and try before you help me and i create i function for take a single data for the player i want i use this.. function stat(usuario, dato) local resultado = mysql_query(coneccion_mysql, "SELECT * FROM usuarios WHERE usuario='"..usuario.."'") local datos = mysql_fetch_assoc(resultado) return datos[dato] end jeje, i am from Venezuela 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