Jump to content

problem countRankInClan


//_Dragon

Recommended Posts

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 by //_Dragon
Link to comment
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

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

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