Jump to content

mysql list


Piorun

Recommended Posts

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

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:

fasuy.png

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...