//_Dragon Posted August 16, 2019 Share Posted August 16, 2019 Hey there i want to count how many leaders are in clan but it counts only numbers of members local leaders = countPlayersInClan(clan) anybody can help me to make it works ? countLeaders in clan Link to comment
Dimos7 Posted August 16, 2019 Share Posted August 16, 2019 Well if you have rank like members and leader are store some where then use it to find how many are the leaders Link to comment
//_Dragon Posted August 16, 2019 Author Share Posted August 16, 2019 (edited) i add it only in sql clan_leaders but it doesnt has any relation with it i should find his local function countPlayersInClan(clan) local q = executeSQLQuery("SELECT * FROM clan_members WHERE clan=?",clan) local q = executeSQLQuery("SELECT * FROM clan_leaders WHERE clan=?",clan) return #q end function callMeMaybe() local tbl = {} local q = executeSQLQuery("SELECT * FROM clans") for i,v in ipairs(q) do local query = executeSQLQuery("SELECT username FROM accountUsername WHERE account=?",v.owner) local clan = v.name local tag = v.tag local r = v.r local g = v.g local b = v.b local members = countPlayersInClan(clan) local leaders = countPlayersInClan(clan) table.insert(tbl,#tbl+1,{owner=query[1].username:gsub("%[.*%]", ""),name=clan,tag=tag,r=r,g=g,b=b,members=members,leaders=leaders}) Edited August 16, 2019 by //_Dragon Link to comment
HassoN Posted August 16, 2019 Share Posted August 16, 2019 local members = countPlayersInClan(clan) local leaders = countPlayersInClan(clan) How are you using the same code twice for two different purposes? Does your database have any information about member's ranks? local q = executeSQLQuery("SELECT * FROM clan_leaders WHERE clan=?",clan) this should work ONLY IF you had a table called "clan_leaders" that actually has a list of all the leaders of a certain clan. Link to comment
//_Dragon Posted August 16, 2019 Author Share Posted August 16, 2019 my database has clan_leaders the only issue is countPlayerInClan i need to replace it to get fixed Link to comment
HassoN Posted August 16, 2019 Share Posted August 16, 2019 Then use 2 different functions function countPlayersInClan(clan) local q = executeSQLQuery("SELECT * FROM clan_members WHERE clan=?",clan) return #q end function countLeadersInClan(clan) local q = executeSQLQuery("SELECT * FROM clan_leaders WHERE clan=?",clan) return #q end function callMeMaybe() local tbl = {} local q = executeSQLQuery("SELECT * FROM clans") for i,v in ipairs(q) do local query = executeSQLQuery("SELECT username FROM accountUsername WHERE account=?",v.owner) local clan = v.name local tag = v.tag local r = v.r local g = v.g local b = v.b local members = countPlayersInClan(clan) local leaders = countLeadersInClan(clan) table.insert(tbl,#tbl+1,{owner=query[1].username:gsub("%[.*%]", ""),name=clan,tag=tag,r=r,g=g,b=b,members=members,leaders=leaders}) 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