WASSIm. Posted January 30, 2014 Posted January 30, 2014 hi guys i have problem its show me on memberCount "N/A" Server addEvent("onPlayerOpenGroupsList", true) addEventHandler("onPlayerOpenGroupsList", root, function ( ) local getGroups = exports["server"]:dbQueryZA("SELECT * FROM groups") local getMembers = exports["server"]:dbQueryZA("SELECT * FROM groupMembers") triggerClientEvent(source, "onClientPlayerOpenGroupsList", source, getGroups, getMembers) end) Client addEvent("onClientPlayerOpenGroupsList", true) addEventHandler("onClientPlayerOpenGroupsList", root, function (groups, members) guiSetVisible(GUIGroup.window[1], true) guiBringToFront(GUIGroup.window[1]) guiGridListClear(GUIGroup.gridlist[1]) for i, group in ipairs(groups) do local groupName = group["groupName"] or "N/A" local memberCount = members[groupName] or "N/A" local row = guiGridListAddRow(GUIGroup.gridlist[1]) guiGridListSetItemText(GUIGroup.gridlist[1], row, 1, tostring(groupName), false, false) guiGridListSetItemText(GUIGroup.gridlist[1], row, 2, tostring(memberCount), false, false) end end)
Castillo Posted January 30, 2014 Posted January 30, 2014 Because that's not how it has to be done, "members" contains a table with all the members of all groups. The format of "members" table would be: row: [ column ]: valuerow: [ column ]: value
Castillo Posted February 1, 2014 Posted February 1, 2014 Post the column names from "groupMembers" table.
WASSIm. Posted February 1, 2014 Author Posted February 1, 2014 ID INTEGER PRIMARY KEY, groupName TEXT, memberName TEXT, memberAccount TEXT, memberLevel INT, memberWL INT, memberLastOn TEXT, memberJoinedOn TEXT
Castillo Posted February 1, 2014 Posted February 1, 2014 addEvent ( "onClientPlayerOpenGroupsList", true ) addEventHandler ( "onClientPlayerOpenGroupsList", root, function ( groups, members ) guiSetVisible ( GUIGroup.window[1], true ) guiBringToFront ( GUIGroup.window[1] ) guiGridListClear ( GUIGroup.gridlist[1] ) local memberCount = { } for _, member in ipairs ( members ) do if ( not memberCount [ member.groupName ] ) then memberCount [ member.groupName ] = 0 end memberCount [ member.groupName ] = ( memberCount [ member.groupName ] + 1 ) end for _, group in ipairs ( groups ) do local groupName = ( group [ "groupName" ] or "N/A" ) local count = ( memberCount [ groupName ] or "N/A" ) local row = guiGridListAddRow ( GUIGroup.gridlist[1] ) guiGridListSetItemText ( GUIGroup.gridlist[1], row, 1, tostring ( groupName ), false, false ) guiGridListSetItemText ( GUIGroup.gridlist[1], row, 2, tostring ( count ), false, false ) end end )
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