Piorun Posted June 19, 2011 Share Posted June 19, 2011 Hi, today i've got a problem again -.-. But now with mysql functions included into MTA. My codes: SERWER function getPlayerChars() userid = getElementData(source, "userid") local result = mysql_query(handler, "SELECT * FROM tc_postacie WHERE playerid='"..userid.."'") numRows = mysql_num_rows ( result ) if numRows == 1 then if (result) then while true do local data = mysql_fetch_assoc(result) if (not data) then break end name1 = tostring(data["name"]) name2 = tostring(data["surname"]) triggerClientEvent(source, "onCreateCharsMenu", getRootElement(), name1, name2) end mysql_free_result(result) else end end end addEvent("onClientShowChars", true) addEventHandler("onClientShowChars", getRootElement(), getPlayerChars) CLIENT function crChrMenu(name1, name2) guiCreateLabel(7,20,207,22,name1.." "..name2,false) charname = name1.." "..name2 lenght = string.len(charname) addEventHandler("onClientRender",root, function() dxDrawRectangle(7.0,20.0,60.0,74.0,tocolor(0,0,0,191),false) end ) end addEvent("onCreateCharsMenu", true) addEventHandler("onCreateCharsMenu", getRootElement(), crChrMenu) [lua] It's working good, but for only one record. When mysql returns more than one record it's not working. I added too [lua] outputChatBox(name1) into serwer side, but it's not working too. WTF? Link to comment
Castillo Posted June 19, 2011 Share Posted June 19, 2011 Do you mean that it just returns one record? if so, I think you should use a 'for' to loop. Link to comment
Piorun Posted June 19, 2011 Author Share Posted June 19, 2011 s***, i found the wrong code. I paste it from another script, and there i've got for one record. I must delete numRows = mysql_num_rows ( result ) if numRows == 1 then and it will be good . Sorry for problems. Link to comment
Piorun Posted June 19, 2011 Author Share Posted June 19, 2011 okey, i delete it, it's working, it's showing me a labels, and rectangle, but the how to do a list of labels? I show what i mean: i've got this one, but i want a list of it. How to? Only labels. I'll try to do something with rectangle, don't worry Link to comment
Castillo Posted June 19, 2011 Share Posted June 19, 2011 labels = 0 function crChrMenu(name1, name2) labels = labels +20 guiCreateLabel(7,labels,207,22,name1.." "..name2,false) charname = name1.." "..name2 lenght = string.len(charname) addEventHandler("onClientRender",root, function() dxDrawRectangle(7.0,20.0,60.0,74.0,tocolor(0,0,0,191),false) end ) end addEvent("onCreateCharsMenu", true) addEventHandler("onCreateCharsMenu", getRootElement(), crChrMenu) Try that (not tested). Link to comment
Piorun Posted June 19, 2011 Author Share Posted June 19, 2011 I was thinking about it, but... Hell yeah, it's working - thanks to you !!! 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