Sign in to follow this  
Pedro001

Exporting to the scoreboard.

Recommended Posts

Hi guys, I'm trying to export the info of this function here

clanRankNames =
{
    [1] = "Aprendiz",
    [2] = "Membro",
    [3] = "Treinador",
    [4] = "Sub-Comandante",
    [5] = "Comandante",
    [6] = "Líder"
}

into the scoreboard using this

GangRank = clanRankNames[rank]

exports.scoreboard:addScoreboardColumn("GangRank")

 

but instead of getting the text in the quotes, i'm getting the number in brackets.

How can I get the text in the scoreboard? 

 

Share this post


Link to post
10 hours ago, Pedro001 said:

Hi guys, I'm trying to export the info of this function here

clanRankNames =
{
    [1] = "Aprendiz",
    [2] = "Membro",
    [3] = "Treinador",
    [4] = "Sub-Comandante",
    [5] = "Comandante",
    [6] = "Líder"
}

into the scoreboard using this

GangRank = clanRankNames[rank]

exports.scoreboard:addScoreboardColumn("GangRank")

 

but instead of getting the text in the quotes, i'm getting the number in brackets.

How can I get the text in the scoreboard? 

 

Please! Someone help me with this! :crybaby:

Share this post


Link to post
12 hours ago, aka Blue said:

If you dont post your code lines we cant help you.

Server

local clanDB = nil
local clanTable = {}

zp = 300000


function initDatabase()
	clanDB = dbConnect( "sqlite", "clans.db" )
	dbExec(clanDB, "CREATE TABLE IF NOT EXISTS Clans (Name PRIMARY KEY, Color, Members, X, Y, Z, Cash)")
end
initDatabase()

function fillClanTable()
	local result = dbPoll(dbQuery(clanDB, "SELECT * FROM Clans"),-1)
	if result and type(result) == "table" then
		clanTable = {}
		for k,v in pairs(result) do
			v["Color"] = fromJSON(v["Color"])
			v["Members"] = fromJSON(v["Members"])
			for key,val in pairs(v["Members"]) do
				if val[2] == 6 then
					v["Leader"] = val[1]
				end
			end
			table.insert(clanTable,v)
			createTeam( v["Name"], unpack(v["Color"]) )
		end
	end
end
fillClanTable()

function createClan(name,r,g,b)
	local result = dbPoll(dbQuery(clanDB, "SELECT * FROM Clans WHERE Name = ?", name),-1)
	local resultt = dbPoll(dbQuery(clanDB, "SELECT * FROM Clans WHERE Members = ?", getAccountName(getPlayerAccount(source))),-1)
	if resultt and #resultt <= 0 then
		if result and #result <= 0 then
			if name and #name <= 15 then
				local accName = getAccountName(getPlayerAccount(source))
				if r and g and b then
					if tonumber(getPlayerMoney(source, localPlayer)) >= 20000000 then
						setPlayerMoney(source, tonumber(getPlayerMoney(source, localPlayer)) - 20000000)
						local color = {tonumber(r),tonumber(g),tonumber(b)}
						dbExec(clanDB, "INSERT INTO Clans VALUES(?,?,?,?,?,?,?)",name,toJSON(color),toJSON({{accName,6}}),0,0,0,0)
						local team = createTeam(name,unpack(color))
						setPlayerTeam(source,team)
						local oldName = getPlayerName(source)
						fillClanTable()
						setElementData(source,"faction", name)
						outputChatBox("#FF0000[GANG]: #FFFFFFVoce criou a facção #FF0000"..name.." #FFFFFFcom sucesso",source,255, 0, 0, true)
						else
						outputChatBox("#FF0000[GANG]: #FFFFFFParece que voce nao tem dinheiro o suficiente", source, 255, 0, 0, true)
						outputChatBox("#FF0000[GANG]: #FFFFFFPara poder criar uma você precisa de #00800030,000,000$", source, 255, 0, 0, true)						
						return
					end
				end
			else
				outputChatBox("#ff0000[GANG] #ffffffO nome é muito longo!",source)
			end
		else
			outputChatBox("#ff0000[GANG]: #ffffffO facção já existe !",source)
		end
	end
end
addEvent( "createNewClan", true )
addEventHandler("createNewClan", root, createClan)

function getFreeID()
	local result = dbPoll(dbQuery(clanDB, "SELECT ID FROM Clans ORDER BY ID ASC"), -1)
	newID = false
	for i, id in pairs (result) do
		if id["ID"] ~= i then
			newID = i
			break
		end
	end
	if newID then return newID else return #result + 1 end
end



function was ()
	local faction, rank = getPlayerFaction(source)
	local data = getFactionData(faction)
	if faction and rank then
		if data["X"] ~= 0 or 0 and data["Y"] ~= 0 or 0 and data["Z"] ~= 0 or 20 then
		    spawnPlayer(source,data["X"],data["Y"],data["Z"]+0.2)
			setTimer (spawnPlayer, 1000, 1, source, data["X"],data["Y"],data["Z"]+0.2, 0, getPedSkin (source), 0, 0, getPlayerTeam(source))
		end
	end
end
addEventHandler("onPlayerWasted", getRootElement(), was)

function initClanCreationWindow(ply)
	local accName = getAccountName ( getPlayerAccount ( ply ) )
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Console" ) ) then
    	triggerClientEvent( ply, "initClanCreationWindow", ply, clanTable )
    end
end
addCommandHandler("gangs",initClanCreationWindow)

function getPlayerFaction(ply)
	local accName = getAccountName ( getPlayerAccount ( ply ) ) 
	for k,v in pairs(clanTable) do
		for key,val in pairs(v["Members"]) do
			if val[1] == accName then
				return v["Name"], val[2]
			end
		end
	end
end

function getFactionData(name)
	for k,v in pairs(clanTable) do
		if v["Name"] == name then
			return v
		end
	end
end

function setFactionOnLogin()
	local faction, rank = getPlayerFaction(source)
	local data = getFactionData(faction)
	if faction and rank then
		setElementData(source,"faction",faction)
		setElementData(source,"GangRank",rank)
		if getTeamFromName (faction) then
			setPlayerTeam(source,getTeamFromName (faction))
		else
			local team = createTeam(faction,unpack(data["Color"]))
			setPlayerTeam(source,team)
		end
		local oldName = getPlayerName(source)
		local newName = "["..faction.."]"..oldName
		setPlayerName(source, newName )
		if data["X"] ~= 0 and data["Y"] ~= 0 and data["Z"] ~= 0 then
			setElementPosition(source,data["X"],data["Y"],data["Z"]+0.2)
		end
	end
end
addEventHandler("onPlayerLogin",root,setFactionOnLogin)

function setFactionOnStart()

GangRank = clanRankNames[rank]

	exports.scoreboard:addScoreboardColumn("GangRank")






for i, v in ipairs (getElementsByType ("player")) do
	local acc = getPlayerAccount (v)
	if not isGuestAccount (acc) then
		local faction, rank = getPlayerFaction(v)
		local data = getFactionData(faction)
		if faction and rank then
			setElementData(v,"faction",faction)
			setElementData(v,"GangRank",rank)
			if getTeamFromName (faction) then
				setPlayerTeam(v,getTeamFromName (faction))
			else
				local team = createTeam(faction,unpack(data["Color"]))
				setPlayerTeam(v,team)
			end
			local oldName = getPlayerName(v)
			local newName = "["..faction.."]"..oldName
			setPlayerName(v, newName )
			if data["X"] ~= 0 and data["Y"] ~= 0 and data["Z"] ~= 0 then
				setElementPosition(v,data["X"],data["Y"],data["Z"]+0.2)
			end
		end
	end
end
end
addEventHandler("onResourceStart",resourceRoot,setFactionOnStart)

function deleteClan(name)
	local clan = getFactionData(name)
	for k,v in pairs(clan["Members"]) do
		local acc = getAccount(v[1])
		local ply = getAccountPlayer( acc )
		if ply then
			removeElementData(ply,"faction")
			removeElementData(ply,"GangRank")
			setPlayerTeam(ply,nil)
		    outputChatBox("#FF0000[GANG]: #FFFFFFSua gang #FF0000"..name.." #FFFFFFfoi excluida por um de nossos #FF0000ADMINISTRADORES", ply, 255, 0, 0, true)
		end
	end
	dbExec(clanDB, "DELETE FROM Clans WHERE Name = ?",name)
	fillClanTable()
end
addEvent( "deleteClan", true )
addEventHandler("deleteClan", root, deleteClan)

function inviteToClan(ply)
	if not getElementData(ply,"faction") then
		if not isGuestAccount (getPlayerAccount (ply)) then
			local clan = getFactionData(getElementData(source,"faction"))
			triggerClientEvent(ply,"clanInvitation",source,clan)
		else
			outputChatBox("#ff0000[GANG]: #ffffffO jogador ainda não esta logado no servidor.",source, 255, 255, 255,true)
		end
	else
		outputChatBox("#32CD32[GANG]: #ffffffO jogador já está na facção.",source, 255, 0, 0)
	end
end
addEvent( "inviteToClan", true )
addEventHandler("inviteToClan", root, inviteToClan)

function acceptInvite(clan)
	setElementData(source,"faction", clan["Name"])
	setElementData(source,"GangRank", 1)
	setPlayerTeam(source,getTeamFromName (clan["Name"]))
	local newMembers = clan["Members"]
	local accName = getAccountName ( getPlayerAccount ( source ) ) 
	table.insert(newMembers,{accName,1})
	dbExec(clanDB, "UPDATE Clans SET Members = ? WHERE Name = ? ",toJSON(newMembers), clan["Name"])
	fillClanTable()
end
addEvent( "acceptInvite", true )
addEventHandler("acceptInvite", root, acceptInvite)

function kickFromClan(login)
	if getElementData(source,"GangRank") == 6 or getElementData(source,"GangRank") == 5 then
		local acc = getAccount( login )
		local clan = getFactionData(getElementData(source,"faction"))
		local newMembers = clan["Members"]
		for k,v in pairs(clan["Members"]) do
			if v[1] == login and v[2] < 6 then
				table.remove(newMembers,k)
			else
			end
		end
		dbExec(clanDB, "UPDATE Clans SET Members = ? WHERE Name = ? ",toJSON(newMembers), clan["Name"])
		local ply =  getAccountPlayer( acc )
		if ply then
			removeElementData(ply,"faction")
			removeElementData(ply,"GangRank")
			outputChatBox("#ff0000[GANG]: #ffffffVocê foi excluído da facção.",ply)
		end
		fillClanTable()
	end
end
addEvent( "kickFromClan", true )
addEventHandler("kickFromClan", root, kickFromClan)

function leaveClan()
	local clan = getFactionData(getElementData(source,"faction"))
	local newMembers = clan["Members"]
	local login = getAccountName(getPlayerAccount(source))
	for k,v in pairs(clan["Members"]) do
		if v[1] == login and v[2] < 10 then
			table.remove(newMembers,k)
		end
	end
	dbExec(clanDB, "UPDATE Clans SET Members = ? WHERE Name = ? ",toJSON(newMembers), clan["Name"])
	removeElementData(source,"faction")
	removeElementData(source,"GangRank")
	setPlayerTeam(source,nil)
	fillClanTable()
end
addEvent( "leaveClan", true )
addEventHandler("leaveClan", root, leaveClan)

function changeClanCash(state,count)
	local clan = getFactionData(getElementData(source,"faction"))
	if clan then
		if state == "take" then
			if clan["Cash"] >= count then
				outputChatBox("#ff0000[GANG]: #ffffffVocê retirou com sucesso "..count.." #32CD32reais #ffffffda conta da facção!",source,255,255,255,true)
				givePlayerMoney(source,count)
				dbExec(clanDB, "UPDATE Clans SET Cash = ? WHERE Name = ? ",clan["Cash"]-count, clan["Name"])
				fillClanTable()
			end
		elseif state == "give" then
			if getPlayerMoney(source) >= count then
				outputChatBox("#32CD32[GANG]: #ffffffVocê adicionou "..count.." #32CD32reias #ffffffpara sua facção!",source,255,255,255,true)
				takePlayerMoney(source,count)
				dbExec(clanDB, "UPDATE Clans SET Cash = ? WHERE Name = ? ",clan["Cash"]+count, clan["Name"])
				fillClanTable()
			end
		end
	end
end
addEvent( "changeClanCash", true )
addEventHandler("changeClanCash", root, changeClanCash)

function changeClanSpawnPoint(state)
	local x,y,z = getElementPosition(source)
	local clan = getElementData(source,"faction")
	if state then
		dbExec(clanDB, "UPDATE Clans SET X = ?, Y = ?, Z = ? WHERE Name = ? ",x,y,z, clan)
		fillClanTable()
	else
		dbExec(clanDB, "UPDATE Clans SET X = ?, Y = ?, Z = ? WHERE Name = ? ",0,0,0, clan)
		fillClanTable()
	end
end
addEvent( "changeClanSpawnPoint", true )
addEventHandler("changeClanSpawnPoint", root, changeClanSpawnPoint)

function setNewClanRank(login,rank)
	if getElementData(source,"GangRank") == 6 or getElementData(source,"GangRank") == 5 then
		local acc = getAccount( login )
		local clan = getFactionData(getElementData(source,"faction"))
		local newMembers = clan["Members"]
		for k,v in pairs(clan["Members"]) do
			if v[1] == login then
				if v[2] < 6 then
					v[2] = rank
				else return
				end
			end
		end
		dbExec(clanDB, "UPDATE Clans SET Members = ? WHERE Name = ? ",toJSON(newMembers), clan["Name"])
		local ply =  getAccountPlayer( acc )
		if ply then
			removeElementData(ply,"faction")
			removeElementData(ply,"GangRank")
			setPlayerTeam(ply,nil)
			outputChatBox("#32CD32[GANG]: #ffffffSua nova classificação: #32CD32"..rank,ply,255,255,255,true)
		end
		fillClanTable()
	end
end
addEvent( "setNewClanRank", true )
addEventHandler("setNewClanRank", root, setNewClanRank)

function playerQuit()
	local team = getPlayerTeam(source)
	setPlayerTeam(source,nil)
	if team then
		local teamCount = getPlayersInTeam(team)
		outputServerLog( "CONTAGEM DE EQUIPE: "..#teamCount )
		if #teamCount <= 1 then
			destroyElement(team)
		end
	end
end
addEventHandler("onPlayerQuit",root,playerQuit)

setTimer(function()
for _,v in pairs(getElementsByType ("pickup")) do
data = getElementData(v,"teamZone")
if data then
local result = dbPoll(dbQuery(clanDB, "SELECT * FROM Clans WHERE Name = ?",data),-1)
if result and #result ~= 0 then
cash1 = result[1].Cash
cash2 = tonumber(cash1 + zp)
dbExec(clanDB, "UPDATE Clans SET Cash = ? WHERE Name = ? ",cash2,data)
fillClanTable()
end
end
end
end,3600000,0)

Client

local scx,scy = guiGetScreenSize()
local px = scx/1920
local sizeX, sizeY = 400*px,600*px
local posX,posY = 10*px,scy-sizeY-100*px
local screen = dxCreateScreenSource( scx,scy )

local selectionsi_player_list_clan = 0
local presi_player_list_clan = false
local scrollsi_player_list_clan = 0
local scrollMaxsi_player_list_clan = 0
local rtsi_player_list_clan = dxCreateRenderTarget( 280,160, true )
local clksi_player_list_clan = false

local selectionsi_piglos = 0
local presi_piglos = false
local scrollsi_piglos = 0
local scrollMaxsi_piglos = 0
local rtsi_piglos = dxCreateRenderTarget( 190,170, true )
local clksi_piglos = false

local clanTable = nil
local myClanTable = nil

local creationWindow = nil
local newClanWindow = nil
local clanWindow = nil
local font = guiCreateFont( "font.ttf", 32 )

local blipos = createBlip(2318.49194, 75.57992, 26.48438,60)
setBlipVisibleDistance(blipos, 300)

local marketbuy = createMarker(2318.49194, 75.57992, 25.48438, "cylinder", 1.5, 0, 255, 106, 50 )	
function openNewClanWindows (element)
	if element == localPlayer then
		if stat_create_clan_mark == false then
		stat_create_clan_mark = true
		showCursor(true)
		addEventHandler("onClientRender", root, wnd_create_clan_mark)
		guiSetVisible(edit, true)
		guiSetInputMode("no_binds_when_editing", true)
		end
	end
end
addEventHandler( "onClientMarkerHit", marketbuy, openNewClanWindows )

function initClanCreationWindow(clans)
	if isElement(creationWindow) then
		showCursor(false)
		destroyElement(creationWindow)
	else
		clanTable = clans
		showCursor(true)
		creationWindow = guiCreateWindow(0.3,0.25,0.3,0.5,"Lista de Gangs - Servidor", true)
		local clanlist = guiCreateGridList(0.1,0.1,0.8,0.7,true,creationWindow)
		guiGridListAddColumn( clanlist, "Nome",0.5 )
		guiGridListAddColumn( clanlist, "Lider",0.45 )
		for k,v in pairs(clans) do
			local row = guiGridListAddRow(clanlist)
			guiGridListSetItemText(clanlist,row,1,v["Name"],false,false)
			guiGridListSetItemText(clanlist,row,2,v["Leader"],false,false)
		end

		local btnCreate = guiCreateButton(0.7,0.85,0.2,0.1,"Criar",true,creationWindow)
		local btnDelete = guiCreateButton(0.4,0.85,0.2,0.1,"Excluir",true,creationWindow)
		local btnClose = guiCreateButton(0.1,0.85,0.2,0.1,"Fechar",true,creationWindow)

		addEventHandler("onClientGUIClick",creationWindow,function()
			if source == btnCreate then
				initClanCreationWindow()
				if stat_create_clan_mark == false then
					stat_create_clan_mark = true
					showCursor(true)
					addEventHandler("onClientRender", root, wnd_create_clan_mark)
					guiSetVisible(edit, true)
					guiSetInputMode("no_binds_when_editing", true)
				else
					stat_create_clan_mark = false
					showCursor(false)
					removeEventHandler("onClientRender", root, wnd_create_clan_mark)
					guiSetVisible(edit, false)
					guiSetInputMode("no_binds_when_editing", false)
				end
			elseif source == btnDelete then
				local clanName = guiGridListGetItemText( clanlist, guiGridListGetSelectedItem( clanlist ) )
				triggerServerEvent( "deleteClan", localPlayer,clanName )
				outputChatBox("#FF0000[GANG]: #FFFFFFVocê excluiu #FF0000"..clanName.." #FFFFFFcom sucesso", 255, 0, 0, true)
				initClanCreationWindow()
			elseif source == btnClose then
				initClanCreationWindow()
			end
		end)
	end
end
addEvent( "initClanCreationWindow", true )
addEventHandler("initClanCreationWindow", root, initClanCreationWindow)

function isClanExists(name)
	for k,v in pairs(clanTable) do
		if v["Name"] == name then
			return true
		end
	end
end

function isRGB(str)
	local s = tonumber(str)
	if s and s >= 0 and s <= 255 then
		return true
	else
		return false
	end
end

stat_create_clan_mark = false

name_clan = "Digite o nome da gang"

scrolR_1 = scx / 2 + 127.5
ProcentR_1 = 1
visualPocentClan_1 = 0

scrolG_2 = scx / 2 + 127.5
ProcentG_2 = 1
visualPocentClan_2 = 0

scrolB_3 = scx / 2 + 127.5
ProcentB_3 = 1
visualPocentClan_3 = 0

edit = guiCreateEdit(scx / 2 - 145, scy / 2 - 15, 290, 20,name_clan,false)
guiSetVisible(edit, false)

function wnd_create_clan_mark ()

	dxDrawWindow( scx / 2 - 150 , scy / 2 - 150, 300, 235, "Painel - Criar Gang")
	
	dxDrawScrollBarR(scx / 2 - 127.5, scy / 2 - 90, 255, 10, scrolR_1, "Vermelho "..math.floor(visualPocentClan_1 / 2.55).." %", ProcentR_1)
	dxDrawScrollBarG(scx / 2 - 127.5, scy / 2 - 65, 255, 10, scrolG_2, "Verde "..math.floor(visualPocentClan_2 / 2.55).." %", ProcentG_2)
	dxDrawScrollBarB(scx / 2 - 127.5, scy / 2 - 40, 255, 10, scrolB_3, "Azul "..math.floor(visualPocentClan_3 / 2.55).." %", ProcentB_3)
	
	dxDrawButtonText_pas(scx / 2 - 150, scy / 2 - 120, 300, 20, "Nome: "..name_clan, 1, 1)
	
	dxDrawButtonText(scx / 2 - 145, scy / 2 + 10, 290, 20, "Valor: 30 000 000$", 1, 1)
	 
	dxDrawButton( scx / 2 - 145, scy / 2 + 35, 290, 20, "Criar")
	dxDrawButton( scx / 2 - 145, scy / 2 + 60, 290, 20, "Fechar")
	
	name_clan = guiGetText(edit)

end

addEventHandler( "onClientClick", root, function(button, state)
	if stat_create_clan_mark == true then
		if button == "left" and state == "down" then
			local x, y, w, h = scx / 2 - 127.5, scy / 2 - 90, 255, 10
			if cursorPosition( scrolR_1, y-5, 10, h+10 ) then
				scrollMovingR_1 = true
			else
				if scrolR_1 <= x then
					if cursorPosition( x, y-5, 10, h+10 ) then
						scrollMovingR_1 = true
					end
				else
					if cursorPosition( (x+w)-10, y-5, 10, h+10 ) then
						scrollMovingR_1 = true
					end
				end
			end
		elseif button == "left" and state == "up" then
			if scrollMovingR_1 then
				scrollMovingR_1 = false
			end
		end
		if button == "left" and state == "down" then
			local x, y, w, h = scx / 2 - 127.5, scy / 2 - 65, 255, 10
			if cursorPosition( scrolG_2, y-5, 10, h+10 ) then
				scrollMovingG_2 = true
			else
				if scrolG_2 <= x then
					if cursorPosition( x, y-5, 10, h+10 ) then
						scrollMovingG_2 = true
					end
				else
					if cursorPosition( (x+w)-10, y-5, 10, h+10 ) then
						scrollMovingG_2 = true
					end
				end
			end
		elseif button == "left" and state == "up" then
			if scrollMovingG_2 then
				scrollMovingG_2 = false
			end
		end
		
		if button == "left" and state == "down" then
			local x, y, w, h = scx / 2 - 127.5, scy / 2 - 40, 255, 10
			if cursorPosition( scrolB_3, y-5, 10, h+10 ) then
				scrollMovingB_3 = true
			else
				if scrolB_3 <= x then
					if cursorPosition( x, y-5, 10, h+10 ) then
						scrollMovingB_3 = true
					end
				else
					if cursorPosition( (x+w)-10, y-5, 10, h+10 ) then
						scrollMovingB_3 = true
					end
				end
			end
		elseif button == "left" and state == "up" then
			if scrollMovingB_3 then
				scrollMovingB_3 = false
			end
		end
	end
end)
addEventHandler( "onClientCursorMove", getRootElement( ), function ( _, _, xMove )
    if scrollMovingR_1 then
		scrolR_1 = xMove
	end
    if scrollMovingG_2 then
		scrolG_2 = xMove
	end
    if scrollMovingB_3 then
		scrolB_3 = xMove
	end
end)

function click_clan_mark (button, state)
	if stat_create_clan_mark == true then
		if button == "left" and state == "down" then
			if cursorPosition(scx / 2 - 145, scy / 2 - 15, 290, 20) then
				guiSetText(edit, "")
			end
			if cursorPosition(scx / 2 - 145, scy / 2 + 36, 290, 20) then
				if name_clan and #name_clan >= 2 and #name_clan <=15 then
						local Color_1 = getElementData(localPlayer, "ColorRclan") or 255
						local Color_2 = getElementData(localPlayer, "ColorGclan") or 255
						local Color_3 = getElementData(localPlayer, "ColorBclan") or 255
						triggerServerEvent( "createNewClan", localPlayer, name_clan, Color_1, Color_2, Color_3 )
				else
					outputChatBox("#FF0000[GANG]: #FFFFFFNome invalido. O comprimento mínimo do nome é de 2 caracteres, o máximo é de 15 caracteres..", 255, 0, 0, true)
				end		
				stat_create_clan_mark = false
				showCursor(false)
				removeEventHandler("onClientRender", root, wnd_create_clan_mark)
				guiSetVisible(edit, false)
				guiSetInputMode("no_binds_when_editing", false)
			end
			if cursorPosition(scx / 2 - 145, scy / 2 + 60, 290, 20) then
				stat_create_clan_mark = false
				showCursor(false)
				removeEventHandler("onClientRender", root, wnd_create_clan_mark)
				guiSetVisible(edit, false)
				guiSetInputMode("no_binds_when_editing", false)
			end
		end
	end
end
addEventHandler("onClientClick", root, click_clan_mark)

function open_wnd_clan_mark ()
	if stat_create_clan_mark == false then
		stat_create_clan_mark = true
		showCursor(true)
		addEventHandler("onClientRender", root, wnd_create_clan_mark)
		guiSetVisible(edit, true)
		guiSetInputMode("no_binds_when_editing", true)
	else
		stat_create_clan_mark = false
		showCursor(false)
		removeEventHandler("onClientRender", root, wnd_create_clan_mark)
		guiSetVisible(edit, false)
		guiSetInputMode("no_binds_when_editing", false)
	end
end

clans = ""
memberName = nil

stat_create_clan_upravlenie = false

function wnd_create_clan_upravlenie ()
	local rank = getElementData(localPlayer,"factionrank")
	dxDrawWindow( scx / 2 - 150 , scy / 2 - 155, 300, 330, "Gang : "..clans["Name"].." | Rank : "..clanRankNames[rank])

	dxDrawRectangle(scx / 2 - 140,scy / 2 - 125,280,170,tocolor(0,0,0,200))
	
	dxDrawButton( scx / 2 - 145, scy / 2 + 50, 290, 20, "Banir jogador da gang")
	dxDrawButton( scx / 2 - 145, scy / 2 + 75, 290, 20, "Alterar a classificação do jogador")
	dxDrawButton( scx / 2 - 145, scy / 2 + 100, 290, 20, "Convidar jogador para a gang")
	dxDrawButton( scx / 2 - 145, scy / 2 + 125, 142.5, 20, "Definir Spawn")
	dxDrawButton( scx / 2 + 2.5, scy / 2 + 125, 142.5, 20, "Remover Spawn")
	dxDrawButton( scx / 2 - 145, scy / 2 + 150, 142.5, 20, "Abandonar a gang")
	dxDrawButton( scx / 2 + 2.5, scy / 2 + 150, 142.5, 20, "$ Tesouro da gang $")
	
	
	local CRL = getElementData(localPlayer, "ColorR") or standartR
	local CGL = getElementData(localPlayer, "ColorG") or standartG
	local CBL = getElementData(localPlayer, "ColorB") or standartB
	dxUpdateScreenSource( screen )
	dxSetRenderTarget( rtsi_player_list_clan,true )
	if scrollsi_player_list_clan < 0 then scrollsi_player_list_clan = 0
	elseif scrollsi_player_list_clan >= scrollMaxsi_player_list_clan then scrollsi_player_list_clan = scrollMaxsi_player_list_clan end
	local sy = 0
		for k,v in pairs(clans["Members"]) do
			if k == selectionsi_player_list_clan then
				yes_cl_w = 280
				yes_cl_x = 0
				dxDrawRectangle(yes_cl_x,sy-scrollsi_player_list_clan,yes_cl_w,15,tocolor(CRL, CGL, CBL, 255))
			else
				
				no_cl_w = 270
				no_cl_x = 5
				dxDrawRectangle(no_cl_x,sy-scrollsi_player_list_clan,no_cl_w,15,tocolor(200, 200, 200, 200))
			end
			dxDrawText("Login : "..v[1],10,sy-scrollsi_player_list_clan - 10,490,sy-scrollsi_player_list_clan+26,tocolor(255,255,255),1,1,"default-bold","left","center")
			dxDrawText("Rank : "..clanRankNames[v[2]],155,sy-scrollsi_player_list_clan - 10,490,sy-scrollsi_player_list_clan+26,tocolor(255,255,255),1,1,"default-bold","left","center")
			sy = sy + 16
		end
	dxSetRenderTarget()
	dxDrawImage( scx / 2 - 140,scy / 2 - 120,280,160,rtsi_player_list_clan)
	if sy >= 160 then
		scrollMaxsi_player_list_clan = sy-160
		local size = 160/sy*160
	end
	
	local spy = 0
	for k,v in pairs(clans["Members"]) do
		if cursorPosition(scx / 2 - 140,scy / 2 - 120,280,170) then
			if cursorPosition( scx / 2 - 140,scy / 2 - 120+spy-scrollsi_player_list_clan,280,15) then
				if getKeyState("mouse1") and not clksi_player_list_clan then
					selectionsi_player_list_clan = k
					memberName = v[1]
				end
			end
		end
		spy = spy + 16
	end	
	if getKeyState("mouse1") then clksi_player_list_clan = true else clksi_player_list_clan = false end
end

stat_set_rank = false

edit_rank = guiCreateEdit(scx / 2 - 80, scy / 2 - 205, 160, 20,"Nova classificação (1a5)",false)
guiSetVisible(edit_rank, false)

function set_rank ()
	dxDrawWindow( scx / 2 - 85 , scy / 2 - 235, 170, 80, "Alterar Classificação")
	dxDrawButton( scx / 2 - 80, scy / 2 - 180, 160, 20, "Confirmar")
end

function click_clan_set_rank (button, state)
	if stat_set_rank == true then
		if button == "left" and state == "down" then
			if cursorPosition(scx / 2 - 80, scy / 2 - 205, 160, 20) then
				guiSetText(edit_rank, "")
			end
			if cursorPosition(scx / 2 - 80, scy / 2 - 180, 160, 20) then
				if selectionsi_player_list_clan == 1 then
					outputChatBox("#ff0000[GANG]: #ffffffVocê não pode mudar a sua classificação.!",255,0,0,true)
				else
					local text = guiGetText(edit_rank)
					if tonumber(text) and tonumber(text) >= 1 and tonumber(text) <= 5 then
						local rank = tonumber(text)
						outputChatBox("#32cd32[GANG]: #ffffffVocê alterou com sucesso a classificação do jogador: #32CD32"..memberName.."#ffffff!",0,255,0,true)
						triggerServerEvent( "setNewClanRank", localPlayer, memberName, rank )
						stat_set_rank = false
						removeEventHandler("onClientRender", root, set_rank)
						guiSetVisible(edit_rank, false)
						guiSetInputMode("no_binds_when_editing", false)
					else
						outputChatBox("Valor inválido.",255,0,0)
					end
				end
			end
		end
	end
end
addEventHandler("onClientClick", root, click_clan_set_rank)

function click_clan_upravlenie (button, state)
	if stat_create_clan_upravlenie == true then
		if button == "left" and state == "down" then
			if cursorPosition(scx / 2 - 145, scy / 2 + 50, 290, 20) then
				local rank = getElementData(localPlayer,"factionrank")
				if rank == 6 or rank == 5 then 
					if memberName then	
						if selectionsi_player_list_clan == 1 then
						outputChatBox("#FF0000[GANG]: #FFFFFFO lider da #FF0000[GANG] #FFFFFFnão pode ser banido", 255, 0, 0, true)
						else
							if cc == 5 then 
							outputChatBox("#ff0000[GANG]: #ffffffVocê não pode se banir, você só pode deixar a facção!",255,255,255)							
							else
								triggerServerEvent( "kickFromClan", localPlayer, memberName )
								outputChatBox("#32cd32[GANG] #ffffffVocê excluiu com sucesso um jogador!",255,255,255,true)
							end
						end
					else
						outputChatBox("#ff0000[GANG]: #ffffffNenhum jogador selecionado!",255,255,255,true)
					end
				else
					outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true)
				end
			end
			if cursorPosition(scx / 2 - 145, scy / 2 + 75, 290, 20) then
				local rank = getElementData(localPlayer,"factionrank")
				if rank == 6 or rank == 5 then 
					if memberName then
						if stat_exit == true then
							stat_exit = false
							removeEventHandler("onClientRender", root, wnd_exit)
						end
						if stat_piglos == true then
							stat_piglos = false
							removeEventHandler("onClientRender", root, wnd_rpiglos)
							selectionsi_piglos = 0
						end
						if stat_kazna == true then
							stat_kazna = false
							removeEventHandler("onClientRender", root, wnd_kazna)
							guiSetVisible(edit_kazna, false)
							guiSetInputMode("no_binds_when_editing", false)
						end
						if stat_set_rank == false then
							stat_set_rank = true
							addEventHandler("onClientRender", root, set_rank)
							guiSetVisible(edit_rank, true)
							guiSetInputMode("no_binds_when_editing", true)
						else
							stat_set_rank = false
							removeEventHandler("onClientRender", root, set_rank)
							guiSetVisible(edit_rank, false)
							guiSetInputMode("no_binds_when_editing", false)
						end
					else
						outputChatBox("#ff0000[GANG]: #ffffffNenhum jogador selecionado!",255,255,255,true)
					end
				else
					outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true)
				end
			end
			if cursorPosition(scx / 2 - 145, scy / 2 + 100, 290, 20) then
				local rank = getElementData(localPlayer,"factionrank")
				if rank == 6 or rank == 5 then 
					if stat_exit == true then
						stat_exit = false
						removeEventHandler("onClientRender", root, wnd_exit)
					end
					if stat_set_rank == true then
						stat_set_rank = false
						removeEventHandler("onClientRender", root, set_rank)
						guiSetVisible(edit_rank, false)
						guiSetInputMode("no_binds_when_editing", false)
					end
					if stat_kazna == true then
						stat_kazna = false
						removeEventHandler("onClientRender", root, wnd_kazna)
						guiSetVisible(edit_kazna, false)
						guiSetInputMode("no_binds_when_editing", false)
					end
					if stat_piglos == false then
						stat_piglos = true
						addEventHandler("onClientRender", root, wnd_rpiglos)
						selectionsi_piglos = 0
					else
						stat_piglos = false
						removeEventHandler("onClientRender", root, wnd_rpiglos)
						selectionsi_piglos = 0
					end
				else
					outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true)
				end
			end
			if cursorPosition(scx / 2 - 145, scy / 2 + 125, 142.5, 20) then
				local rank = getElementData(localPlayer,"factionrank")
				if rank == 6 then 
					outputChatBox("#32cd32[GANG]: #ffffffVocê adicionou um ponto de renacimento para sua facção!!",255,255,255,true)
					triggerServerEvent("changeClanSpawnPoint",localPlayer,true)
				else
				    outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true)
				end
			end
			if cursorPosition(scx / 2 + 2.5, scy / 2 + 125, 142.5, 20) then
				local rank = getElementData(localPlayer,"factionrank")
				if rank == 6 then 
					triggerServerEvent("changeClanSpawnPoint",localPlayer,false)
					outputChatBox("#ff0000[GANG]: #ffffffVocê removeu o ponto de renacimento de sua facção!!",255,255,255,true)
				else
					outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true)
				end
			end
			if cursorPosition(scx / 2 + 2.5, scy / 2 + 150, 142.5, 20) then
				if stat_exit == true then
					stat_exit = false
					removeEventHandler("onClientRender", root, wnd_exit)
				end
				if stat_set_rank == true then
					stat_set_rank = false
					removeEventHandler("onClientRender", root, set_rank)
					guiSetVisible(edit_rank, false)
					guiSetInputMode("no_binds_when_editing", false)
				end
				if stat_piglos == true then
					stat_piglos = false
					removeEventHandler("onClientRender", root, wnd_rpiglos)
					selectionsi_piglos = 0
				end
				if stat_kazna == false then
					stat_kazna = true
					addEventHandler("onClientRender", root, wnd_kazna)
					guiSetVisible(edit_kazna, true)
					guiSetInputMode("no_binds_when_editing", true)
				else
					stat_kazna = false
					removeEventHandler("onClientRender", root, wnd_kazna)
					guiSetVisible(edit_kazna, false)
					guiSetInputMode("no_binds_when_editing", false)
				end
			end
			if cursorPosition(scx / 2 - 145, scy / 2 + 150, 142.5, 20) then
				if stat_exit == false then
					stat_exit = true
					addEventHandler("onClientRender", root, wnd_exit)
				else
					stat_exit = false
					removeEventHandler("onClientRender", root, wnd_exit)
				end
			end
		end
	end
end
addEventHandler("onClientClick", root, click_clan_upravlenie)

stat_exit = false

function wnd_exit ()

	dxDrawWindow( scx / 2 - 150 , scy / 2 - 235, 300, 80, "Pense bem antes de abandonar, nao tera volta.")

	dxDrawButtonText(scx / 2 - 150 , scy / 2 - 205, 300, 20, "Tem certeza que voce quer abandonar a gang?\n"..clans["Name"].." ??", 1, 1)
	
	dxDrawButton( scx / 2 - 145, scy / 2 - 180, 142.5, 20, "Sim, Abandonar")
	dxDrawButton( scx / 2 + 2.5, scy / 2 - 180, 142.5, 20, "Não, Fechar")
	
end

function click_clan_exit(button, state)
	if stat_exit == true then
		if button == "left" and state == "down" then
			if cursorPosition(scx / 2 - 145, scy / 2 - 180, 142.5, 20) then
				triggerServerEvent( "leaveClan", localPlayer)
				stat_exit = false
				removeEventHandler("onClientRender", root, wnd_exit)
				outputChatBox("Você deixou o clã com sucesso",0,255,0)
				stat_create_clan_upravlenie = false
				showCursor(false)
				removeEventHandler("onClientRender", root, wnd_create_clan_upravlenie)
				memberName = nil
				selectionsi_player_list_clan = 0
				if stat_set_rank == true then
					stat_set_rank = false
					removeEventHandler("onClientRender", root, set_rank)
					guiSetVisible(edit_rank, false)
					guiSetInputMode("no_binds_when_editing", false)
				end
				if stat_piglos == true then
					stat_piglos = false
					removeEventHandler("onClientRender", root, wnd_rpiglos)
					selectionsi_piglos = 0
				end
				if stat_kazna == true then
					stat_kazna = false
					removeEventHandler("onClientRender", root, wnd_kazna)
					guiSetVisible(edit_kazna, false)
					guiSetInputMode("no_binds_when_editing", false)
				end
			end
			if cursorPosition(scx / 2 + 2.5, scy / 2 - 180, 142.5, 20) then
				stat_exit = false
				removeEventHandler("onClientRender", root, wnd_exit)
			end
		end
	end
end
addEventHandler("onClientClick", root, click_clan_exit)



stat_kazna = false

edit_kazna = guiCreateEdit(scx / 2 - 100, scy / 2 - 205, 198.5, 20,"0",false)
guiSetVisible(edit_kazna, false)

function wnd_kazna ()

dxDrawWindow( scx / 2 - 102.5 , scy / 2 - 235, 205, 80, "Tesouro do clã : "..clans["Cash"])

dxDrawButton( scx / 2 - 98.5, scy / 2 - 180, 95, 20, "Colocar")
dxDrawButton( scx / 2 + 2.5 , scy / 2 - 180, 95, 20, "Retirar")

end


function click_clan_kazna(button, state)
	if stat_kazna == true then
		if button == "left" and state == "down" then
			if cursorPosition(scx / 2 - 100, scy / 2 - 205, 198.5, 20) then
				guiSetText(edit_kazna, "")
			end
			if cursorPosition(scx / 2 - 98.5, scy / 2 - 180, 95, 20) then
				local cashText = guiGetText(edit_kazna)
				if tonumber(cashText) and tonumber(cashText) <= getPlayerMoney(localPlayer) then
					if ( string.find ( tonumber(cashText), '-' ) ) then
						outputChatBox("Valor errado",255,0,0)
					else
						triggerServerEvent( "changeClanCash", localPlayer, "give", tonumber(cashText) )
						stat_create_clan_upravlenie = false
						showCursor(false)
						removeEventHandler("onClientRender", root, wnd_create_clan_upravlenie)
						memberName = nil
						selectionsi_player_list_clan = 0
						if stat_set_rank == true then
							stat_set_rank = false
							removeEventHandler("onClientRender", root, set_rank)
							guiSetVisible(edit_rank, false)
							guiSetInputMode("no_binds_when_editing", false)
						end
						if stat_piglos == true then
							stat_piglos = false
							removeEventHandler("onClientRender", root, wnd_rpiglos)
							selectionsi_piglos = 0
						end
						if stat_kazna == true then
							stat_kazna = false
							removeEventHandler("onClientRender", root, wnd_kazna)
							guiSetVisible(edit_kazna, false)
							guiSetInputMode("no_binds_when_editing", false)
						end
					end
				end
			end
			if cursorPosition(scx / 2 + 2.5 , scy / 2 - 180, 95, 20) then
				local rank = getElementData(localPlayer,"factionrank")
				if rank == 6 or rank == 5 then 
					local cashText = guiGetText(edit_kazna)
					if tonumber(cashText) and tonumber(cashText) <= clans["Cash"] then
						if ( string.find ( tonumber(cashText), '-' ) ) then
							outputChatBox("Valor inválido",255,0,0)
						else
							triggerServerEvent( "changeClanCash", localPlayer, "take", tonumber(cashText) )
							stat_create_clan_upravlenie = false
							showCursor(false)
							removeEventHandler("onClientRender", root, wnd_create_clan_upravlenie)
							memberName = nil
							selectionsi_player_list_clan = 0
							if stat_set_rank == true then
								stat_set_rank = false
								removeEventHandler("onClientRender", root, set_rank)
								guiSetVisible(edit_rank, false)
								guiSetInputMode("no_binds_when_editing", false)
							end
							if stat_piglos == true then
								stat_piglos = false
								removeEventHandler("onClientRender", root, wnd_rpiglos)
								selectionsi_piglos = 0
							end
							if stat_kazna == true then
								stat_kazna = false
								removeEventHandler("onClientRender", root, wnd_kazna)
								guiSetVisible(edit_kazna, false)
								guiSetInputMode("no_binds_when_editing", false)
							end
						end
					else
						outputChatBox("#ff0000[GANG]: #ffffffQuantidade inválida!",255,255,255,true)
					end
				else
					outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true)
				end
			end
		end
	end
end
addEventHandler("onClientClick", root, click_clan_kazna)






stat_piglos = false

function wnd_rpiglos ()

	dxDrawWindow( scx / 2 + 155 , scy / 2 - 155, 200, 235, "Lista de jogadores")

	dxDrawButton( scx / 2 + 160, scy / 2 + 55, 190, 20, "Convidar")
	
	dxDrawRectangle(scx / 2 + 160 , scy / 2 - 125,190,175,tocolor(0,0,0,200))
	
	local CRL = getElementData(localPlayer, "ColorR") or standartR
	local CGL = getElementData(localPlayer, "ColorG") or standartG
	local CBL = getElementData(localPlayer, "ColorB") or standartB
	dxUpdateScreenSource( screen )
	dxSetRenderTarget( rtsi_piglos,true )
	if scrollsi_piglos < 0 then scrollsi_piglos = 0
	elseif scrollsi_piglos >= scrollMaxsi_piglos then scrollsi_piglos = scrollMaxsi_piglos end
	local sy = 0
		for k,player in pairs(getElementsByType("player")) do
				if not getElementData(player,"faction") then
					if k == selectionsi_piglos then
						yes_cl_w = 190
						yes_cl_x = 0
						dxDrawRectangle(yes_cl_x,sy-scrollsi_piglos,yes_cl_w,15,tocolor(CRL, CGL, CBL, 255))
					else
						
						no_cl_w = 180
						no_cl_x = 5
						dxDrawRectangle(no_cl_x,sy-scrollsi_piglos,no_cl_w,15,tocolor(200, 200, 200, 200))
					end
					local nick = getPlayerName(player)
					dxDrawText(string.gsub( nick, "#%x%x%x%x%x%x", "", 1 ),0,sy-scrollsi_piglos - 10,190,sy-scrollsi_piglos+26,tocolor(255,255,255),1,1,"default-bold","center","center")
					sy = sy + 16
				end
		end
	dxSetRenderTarget()
	dxDrawImage(scx / 2 + 160, scy / 2 - 120,190,170,rtsi_piglos)
	if sy >= 170 then
		scrollMaxsi_piglos = sy-170
		local size = 170/sy*170
	end
	
	local spy = 0
	for k,player in pairs(getElementsByType("player")) do
			if not getElementData(player,"faction") then
				if cursorPosition(scx / 2 + 160, scy / 2 - 120,190,170) then
					if cursorPosition(scx / 2 + 160, scy / 2 - 120+spy-scrollsi_piglos,190,15) then
						if getKeyState("mouse1") and not clksi_piglos then
							if k == 1 then
								outputChatBox("você não pode se convidar")
							else
							selectionsi_piglos = k
							igrok = player
							end
						end
					end
				end
				spy = spy + 16
			end
	end	
	if getKeyState("mouse1") then clksi_piglos = true else clksi_piglos = false end

end

function click_clan_invite (button, state)
	if stat_piglos == true then
		if button == "left" and state == "down" then
			if cursorPosition(scx / 2 + 160, scy / 2 + 55, 190, 20) then
				if selectionsi_piglos == 0 then
					outputChatBox("Você não selecionou um jogador",255,0,0)
				else
					triggerServerEvent( "inviteToClan", localPlayer, igrok )
					outputChatBox("Convite para o jogador enviado com sucesso",0,255,0)
					selectionsi_piglos = 0
				end
			end
		end
	end
end
addEventHandler("onClientClick", root, click_clan_invite)

addEventHandler("onClientKey",root,function(key,presi_piglos)
	if presi_piglos then
		if not stat_piglos then return end
		if key == "mouse_wheel_down" then
			scrollsi_piglos = scrollsi_piglos + 12
		elseif key == "mouse_wheel_up" then
			scrollsi_piglos = scrollsi_piglos - 12
		end
	end
end)

addEventHandler("onClientKey",root,function(key,presi_player_list_clan)
	if presi_player_list_clan then
		if not stat_create_clan_upravlenie then return end
		if key == "mouse_wheel_down" then
			scrollsi_player_list_clan = scrollsi_player_list_clan + 12
		elseif key == "mouse_wheel_up" then
			scrollsi_player_list_clan = scrollsi_player_list_clan - 12
		end
	end
end)

function open_wnd_clan_upravlenie (clan)
	clans = clan
	if stat_create_clan_upravlenie == false then
		stat_create_clan_upravlenie = true
		showCursor(true)
		addEventHandler("onClientRender", root, wnd_create_clan_upravlenie)
		memberName = nil
		selectionsi_player_list_clan = 0
	else
		stat_create_clan_upravlenie = false
		showCursor(false)
		removeEventHandler("onClientRender", root, wnd_create_clan_upravlenie)
		memberName = nil
		selectionsi_player_list_clan = 0
		if stat_set_rank == true then
			stat_set_rank = false
			removeEventHandler("onClientRender", root, set_rank)
			guiSetVisible(edit_rank, false)
			guiSetInputMode("no_binds_when_editing", false)
		end
		if stat_piglos == true then
			stat_piglos = false
			removeEventHandler("onClientRender", root, wnd_rpiglos)
			selectionsi_piglos = 0
		end
		if stat_kazna == true then
			stat_kazna = false
			removeEventHandler("onClientRender", root, wnd_kazna)
			guiSetVisible(edit_kazna, false)
			guiSetInputMode("no_binds_when_editing", false)
		end
		if stat_exit == true then
			stat_exit = false
			removeEventHandler("onClientRender", root, wnd_exit)
		end
	end
end
addEvent( "openClanWindow", true )
addEventHandler("openClanWindow", root, open_wnd_clan_upravlenie)

function bindd_wnd_clan_upravlenie ()
	if not getElementData(localPlayer,"faction") then
		outputChatBox("#FF0000[ACESSO-NEGAGO]: #FFFFFFPara acessar esse painel, voce precisa estar em uma #FF0000[GANG]", 255, 0, 0, true)
	else
		triggerServerEvent("openClanWindowS", localPlayer)
	end
end
bindKey("F7","down",bindd_wnd_clan_upravlenie)


local inviteWindow = nil
function clanInvitation(clan)
	if not isElement(inviteWindow) then
		inviteWindow = guiCreateWindow(0.35,0.4,0.25,0.1,"Convite para gang",true,inviteWindow)
		local btnClose = guiCreateButton(0.1,0.6,0.3,0.3,"Negar",true,inviteWindow)
		local btnAccept = guiCreateButton(0.6,0.6,0.3,0.3,"Aceitar",true,inviteWindow)
		addEventHandler("onClientGUIClick",inviteWindow,function()
			if source == btnClose then
				showCursor(false)
				destroyElement(inviteWindow)
			elseif source == btnAccept then
				showCursor(false)
				destroyElement(inviteWindow)
				triggerServerEvent( "acceptInvite", localPlayer, clan )
			end
		end)
		local label = guiCreateLabel(0,0.3,1,0.2,"Você quer se juntar a gang "..clan["Name"],true,inviteWindow)
		guiLabelSetHorizontalAlign( label, "center" )
	end
end
addEvent( "clanInvitation", true )
addEventHandler("clanInvitation", root, clanInvitation)

Ranknames

clanRankNames =
{
	[1] = "Aprendiz",
	[2] = "Membro",
	[3] = "Treinador",
	[4] = "Sub-Comandante",
	[5] = "Comandante",
	[6] = "Líder"
}

please, help me out :'(

Share this post


Link to post
2 minutes ago, Dimos7 said:

That is for scoreboard? 

It's a script for creating gangs, I wanted to show the rank of the player in the gang on the scorebord. 

the rank names are in the Ranknames file,  which is this one
 

  1. clanRankNames =
  2. {
  3. [1] = "Aprendiz",
  4. [2] = "Membro",
  5. [3] = "Treinador",
  6. [4] = "Sub-Comandante",
  7. [5] = "Comandante",
  8. [6] = "Líder"
  9. }

But instead of getting shown "Comandante" on the scoreboard, I get the number 5 shown. 

I wanted the rank name shown. :( 

Share this post


Link to post

show the code in dxscoreboard_exports.lua i think u need to make something like that in it 

 
{ ["name"] = "Clan Rank", ["width"] = 80, ["friendlyName"] = "Clan Rank", ["priority"] = 3 },

to make it shown in scoreboard 

Edited by jakson

Share this post


Link to post
2 minutes ago, jakson said:

show the code in dxscoreboard_exports.lua i think u need to make something like that in it 


{ ["name"] = "Clan Rank", ["width"] = 80, ["friendlyName"] = "Clan Rank", ["priority"] = 3 },

to make it shown in scoreboard 

dxscoreboard_exports.lua ? I don't get it. 

Share this post


Link to post
1 minute ago, Pedro001 said:

dxscoreboard_exports.lua ? I don't get it. 

are you using the default mta scoreboard?

Share this post


Link to post
1 minute ago, jakson said:

are you using the default mta scoreboard?

No I've got another one, do you need it? 

MAX_PRIRORITY_SLOT = 500

scoreboardColumns = {
	{ ["name"] = "ID", ["width"] = 20, ["friendlyName"] = "ID", ["priority"] = 1 },
	{ ["name"] = "name", ["width"] = 200, ["friendlyName"] = "Name", ["priority"] = 2 },
	{ ["name"] = "fps", ["width"] = 50, ["friendlyName"] = "FPS", ["priority"] = 3 },
	--{ ["name"] = "country", ["width"] = 100, ["friendlyName"] = "Country", ["priority"] = MAX_PRIRORITY_SLOT-1 },
	{ ["name"] = "ping", ["width"] = 30, ["friendlyName"] = "Ping", ["priority"] = MAX_PRIRORITY_SLOT }
}
resourceColumns = {}

function toboolean( bool )
	bool = tostring( bool )
	if bool == "true" then
		return true
	elseif bool == "false" then
		return false
	else
		return nil
	end
end

forceShowTeams = toboolean( get( "forceShowTeams" ) ) or false
forceHideTeams = toboolean( get( "forceHideTeams" ) ) or false
allowColorcodedNames = toboolean( get( "allowColorcodedNames" ) ) or false
scrollStep = tonumber( get( "scrollStep" ) ) or 1

local function iif( cond, arg1, arg2 )
	if cond then
		return arg1
	end
	return arg2
end

function scoreboardAddColumn( name, forElement, width, friendlyName, priority )
	if type( name ) == "string" then
		width = tonumber( width ) or 70
		friendlyName = friendlyName or name
		priority = tonumber( priority ) or getNextFreePrioritySlot( scoreboardGetColumnPriority( "name" ) )
		fixPrioritySlot( priority )
		forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() )
		
		if forElement == getRootElement() then
			if not (priority > MAX_PRIRORITY_SLOT or priority < 1) then
				for key, value in ipairs( scoreboardColumns ) do
					if name == value.name then
						return false
					end
				end
				table.insert( scoreboardColumns, { ["name"] = name, ["width"] = width, ["friendlyName"] = friendlyName, ["priority"] = priority } )
				table.sort( scoreboardColumns, function ( a, b ) return a.priority < b.priority end )
				if sourceResource then
					if not resourceColumns[sourceResource] then resourceColumns[sourceResource] = {} end
					table.insert ( resourceColumns[sourceResource], name )
				end
				return triggerClientEvent( getRootElement(), "doScoreboardAddColumn", getRootElement(), name, width, friendlyName, priority, sourceResource )
			end
		else
			return triggerClientEvent( forElement, "doScoreboardAddColumn", getRootElement(), name, width, friendlyName, priority, sourceResource )
		end
	end
	return false
end

function scoreboardRemoveColumn( name, forElement )
	if type( name ) == "string" then
		forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() )
		
		if forElement == getRootElement() then
			for key, value in ipairs( scoreboardColumns ) do
				if name == value.name then
					table.remove( scoreboardColumns, key )
					for resource, content in pairs( resourceColumns ) do
						table.removevalue( content, name )
					end
					return triggerClientEvent( getRootElement(), "doScoreboardRemoveColumn", getRootElement(), name )
				end
			end
		else
			return triggerClientEvent( forElement, "doScoreboardRemoveColumn", getRootElement(), name )
		end
	end
	return false
end

function scoreboardClearColumns( forElement )
	forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() )
	
	if forElement == getRootElement() then
		while ( scoreboardColumns[1] ) do
			table.remove( scoreboardColumns, 1 )
			resourceColumns = {}
		end
		return triggerClientEvent( getRootElement(), "doScoreboardClearColumns", getRootElement() )
	else
		return triggerClientEvent( forElement, "doScoreboardClearColumns", getRootElement() )
	end
end

function scoreboardResetColumns( forElement )
	forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() )
	
	if forElement == getRootElement() then
		while ( scoreboardColumns[1] ) do
			table.remove( scoreboardColumns, 1 )
			resourceColumns = {}
		end
		local result = triggerClientEvent( getRootElement(), "doScoreboardResetColumns", getRootElement() )
		if result then
			scoreboardAddColumn( "name", 200, "Name" )
			scoreboardAddColumn( "ping", 40, "Ping" )
		end
		return result
	else
		return triggerClientEvent( forElement, "doScoreboardResetColumns", getRootElement(), false )
	end
end

function scoreboardSetForced( forced, forElement )
	if type( forced ) == "boolean" then
		forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() )
		return triggerClientEvent( forElement, "doScoreboardSetForced", getRootElement(), forced )
	else
		return false
	end
end

function scoreboardSetSortBy( name, desc, forElement )
	if type( name ) == "string" or name == nil then
		if name == nil then
			forElement = iif( type( desc ) == "userdata" and isElement( desc ), desc, getRootElement() )
		else
			forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() )
		end
		desc = iif( type( desc ) == "boolean", desc, true )
		return triggerClientEvent( forElement, "doScoreboardSetSortBy", getRootElement(), name, desc )
	else
		return false
	end
end

function scoreboardGetColumnPriority( name )
	if type( name ) == "string" then
		for key, value in ipairs( scoreboardColumns ) do
			if name == value.name then
				return value.priority
			end
		end
	end
	return false
end

function scoreboardSetColumnPriority( name, priority, forElement )
	if type( name ) == "string" and type( priority ) == "number" then
		if not (priority > MAX_PRIRORITY_SLOT or priority < 1) then
			forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() )
			if forElement == getRootElement() then
				local columnIndex = false
				for key, value in ipairs( scoreboardColumns ) do
					if name == value.name then
						columnIndex = key
					end
				end
				if columnIndex then
					scoreboardColumns[columnIndex].priority = -1 -- To empty out the current priority
					fixPrioritySlot( priority )
					scoreboardColumns[columnIndex].priority = priority
					table.sort( scoreboardColumns, function ( a, b ) return a.priority < b.priority end )
					return triggerClientEvent( forElement, "doScoreboardSetColumnPriority", getRootElement(), name, priority )
				end
			else
				return triggerClientEvent( forElement, "doScoreboardSetColumnPriority", getRootElement(), name, priority )
			end
		end
	end
	return false
end

function scoreboardForceTeamsVisible( enabled )
	if type( enabled ) == "boolean" then
		forceShowTeams = enabled
		return true
	end
	return false
end

function scoreboardForceTeamsHidden( enabled )
	if type( enabled ) == "boolean" then
		forceHideTeams = enabled
		return true
	end
	return false
end

function scoreboardGetColumnCount()
	return #scoreboardColumns
end

function onClientDXScoreboardResourceStart()
	for key, column in ipairs( scoreboardColumns ) do
		triggerClientEvent( client, "doScoreboardAddColumn", getRootElement(), column.name, column.width, column.friendlyName, column.priority )
	end
end
addEvent( "onClientDXScoreboardResourceStart", true )
addEventHandler( "onClientDXScoreboardResourceStart", getResourceRootElement( getThisResource() ), onClientDXScoreboardResourceStart )

function requestServerInfoHandler()
	local mapmanager = getResourceFromName( "mapmanager" )
	local output = {}
	output.forceshowteams = forceShowTeams
	output.forcehideteams = forceHideTeams
	output.allowcolorcodes = allowColorcodedNames
	output.scrollStep = scrollStep
	output.server = getServerName()
	output.players = getMaxPlayers()
	output.gamemode = false
	output.map = false
	if mapmanager and getResourceState( mapmanager ) == "running" then
		local gamemode = exports.mapmanager:getRunningGamemode()
		if gamemode then
			output.gamemode = getResourceInfo( gamemode, "name" ) or getResourceName( gamemode )
		end
		local map = exports.mapmanager:getRunningGamemodeMap()
		if map then
			output.map = getResourceInfo( map, "name" ) or getResourceName( map )
		end
	end
	triggerClientEvent( source, "sendServerInfo", getRootElement(), output )
end
addEvent( "requestServerInfo", true )
addEventHandler( "requestServerInfo", getRootElement(), requestServerInfoHandler )

function removeResourceScoreboardColumns( resource )
	if resourceColumns[resource] then
		while resourceColumns[resource][1] do
			local success = scoreboardRemoveColumn( resourceColumns[resource][1], getRootElement() )
			if not success then break end
		end
		resourceColumns[resource] = nil
	end
end
addEventHandler( "onResourceStop", getRootElement(), removeResourceScoreboardColumns )

-- Compability
addScoreboardColumn = 	function( name, forElement, position, size )
							if type( size ) == "number" and size >= 0 and size <= 1.0 then
								size = size*700
							end
							return scoreboardAddColumn( name, forElement, size, name, position )
						end
removeScoreboardColumn = scoreboardRemoveColumn
resetScoreboardColumns = scoreboardResetColumns
setPlayerScoreboardForced = function( forElement, forced ) return scoreboardSetForced( forced, forElement ) end



--[[function onPlayerJoinToServer()
	if source then
		findIDForPlayer(source)
		local country = call(getResourceFromName("admin"),"getPlayerCountry",source)
		if country then
			setElementData(source,"country",country)
		else
			setElementData(source,"country","?")
		end
	end
end
addEventHandler("onPlayerJoin",getRootElement(),onPlayerJoinToServer)]]--


function findIDForPlayer(thePlayer)
	if thePlayer and not getElementData(thePlayer,"ID") then
		local i = 0
		local players = getElementsByType("player")
		repeat 
			local foundID = false
			i = i + 1
			for _,player in pairs(players) do
				if player ~= thePlayer then
					local playerID = tonumber(getElementData(player,"ID"))
					if playerID == i then
						foundID = true
						break
					end
				end
			end
		until not foundID
		setElementData(thePlayer,"ID",i)
	end
end

--[[function onServerIDStart()
	for i,thePlayer in pairs(getElementsByType("player")) do
		findIDForPlayer(thePlayer)
		local country = call(getResourceFromName("admin"),"getPlayerCountry",source)
		if country then
			setElementData(source,"country",country)
		else
			setElementData(source,"country","?")
		end
	end
end
addEventHandler("onResourceStart",resourceRoot,onServerIDStart)
]]---

 

Edited by Pedro001

Share this post


Link to post
1 minute ago, Pedro001 said:

No I've got another one, do you need it? 

give me ur discord account and i will try to help u

Share this post


Link to post
clanRankNames = 
{
  [1] = "Aprediaz", 
  [2] = "Membro", 
  [3] = "Treinador", 
  [4] = "Sub-Comandante", 
  [5] = "Comandante", 
  [6] = "Lider", 
} 

exports["scoreboard"]:scoreboardAddColumn("Clan Rank", root, 80,"Clan Rank", 5) 

function startHandler() 
  for _, v in pairs(getElementsByType("player")) do 
    for i 
    =1,6 do
      if not clanRankNames[i] then 
         clanRankNames[i] = v
        setElementData(v, "Clan Rank", i) 
      break
      end
      end
    end
end 
addEventHandler("onResourceStart", resourceRoot, startHandler) 

function loginHandler() 
  for i = 1, 6 do
    if not clanRankNames[i] then 
       clanRankNames[i] = source 
       setElementData(source, "Clan Rank", i) 
      break
    end
  end
end 
addEventHandler("onPlayerLogin", root, loginHandler) 

 

Edited by Dimos7

Share this post


Link to post
1 hour ago, Dimos7 said:

clanRankNames = 
{
  [1] = "Aprediaz", 
  [2] = "Membro", 
  [3] = "Treinador", 
  [4] = "Sub-Comandante", 
  [5] = "Comandante", 
  [6] = "Lider", 
} 

exports["scoreboard"]:scoreboardAddColumn("Clan Rank", root, 80,"Clan Rank", 5) 

function startHandler() 
  for _, v in pairs(getElementsByType("player")) do 
    for i 
    =1,6 do
      if not clanRankNames[i] then 
         clanRankNames[i] = v
        setElementData(v, "Clan Rank", i) 
      break
      end
      end
    end
end 
addEventHandler("onResourceStart", resourceRoot, startHandler) 

function loginHandler() 
  for i = 1, 6 do
    if not clanRankNames[i] then 
       clanRankNames[i] = source 
       setElementData(source, "Clan Rank", i) 
      break
    end
  end
end 
addEventHandler("onPlayerLogin", root, loginHandler) 

 

Hii. I tried this one, but now it shows nothing, it stays blank. :( 

Share this post


Link to post

Any errors or warnings in /debugscipt 3? 

clanRankNames = 
{
  [1] = "Aprediaz", 
  [2] = "Membro", 
  [3] = "Treinador", 
  [4] = "Sub-Comandante", 
  [5] = "Comandante", 
  [6] = "Lider", 
} 
exports["scoreboard"]:scoreboardAddColumn("clanRank", root, 80,"clanRank", 5) 
function startHandler() 
  for _, v in pairs(getElementsByType("player")) do 
    for #clanRankNames do
        for i =1,6 do
             if not clanRankNames[i] then 
                 clanRankNames[i] = v
                 setElementData(v, "clanRank", i) 
                  break
             end
          end
        end
    end
end 
addEventHandler("onResourceStart", resourceRoot, startHandler) 
function loginHandler() 
  for #clanRankNames do
      for i = 1, 6 do
          if not clanRankNames[i] then 
              clanRankNames[i] = source 
              setElementData(source, "clanRank", i) 
               break
           end
        end
    end 
end 
addEventHandler("onPlayerLogin", root, loginHandler)

 

Edited by Dimos7

Share this post


Link to post
18 minutes ago, Dimos7 said:

Any errors or warnings in /debugscipt 3? 


clanRankNames = {  [1] = "Aprediaz",   [2] = "Membro",   [3] = "Treinador",   [4] = "Sub-Comandante",   [5] = "Comandante",   [6] = "Lider", } exports["scoreboard"]:scoreboardAddColumn("clanRank", root, 80,"clanRank", 5) function startHandler()   for _, v in pairs(getElementsByType("player")) do     for #clanRankNames do        for i =1,6 do             if not clanRankNames[i] then                  clanRankNames[i] = v                 setElementData(v, "clanRank", i)                   break             end          end        end    endend addEventHandler("onResourceStart", resourceRoot, startHandler) function loginHandler()   for #clanRankNames do      for i = 1, 6 do          if not clanRankNames[i] then               clanRankNames[i] = source               setElementData(source, "clanRank", i)                break           end        end    end end addEventHandler("onPlayerLogin", root, loginHandler)

 

'<name>' expected near '#' on line 13 

attempt to index global 'clanRankNames' (a nil value) on line 161

Share this post


Link to post
function setFactionOnLogin()
    local faction, player_rank = getPlayerFaction(source)
    local data = getFactionData(faction)
    if faction and player_rank then
        for rank,kk in pairs(clanRankNames) do
            if ( rank == player_rank ) then
                local GangRank = clanRankNames[rank]
                setElementData(source,"faction",faction)
                setElementData(source,"GangRank",GangRank)
                if getTeamFromName (faction) then
                    setPlayerTeam(source,getTeamFromName (faction))
                else
                    local team = createTeam(faction,unpack(data["Color"]))
                    setPlayerTeam(source,team)
                end
                local oldName = getPlayerName(source)
                local newName = "["..faction.."]"..oldName
                setPlayerName(source, newName )
                if data["X"] ~= 0 and data["Y"] ~= 0 and data["Z"] ~= 0 then
                    setElementPosition(source,data["X"],data["Y"],data["Z"]+0.2)
                end
                break
            end
        end
    end
end
addEventHandler("onPlayerLogin",root,setFactionOnLogin)

function setFactionOnStart()

    exports.scoreboard:addScoreboardColumn("GangRank")

    for i, v in ipairs (getElementsByType ("player")) do

        local acc = getPlayerAccount (v)
        if not isGuestAccount (acc) then
            local faction, player_rank = getPlayerFaction(v)
            local data = getFactionData(faction)
            if faction and player_rank then
                for rank,kk in pairs(clanRankNames) do
                    if ( rank == player_rank ) then
                        local GangRank = clanRankNames[rank]
                        setElementData(v,"faction",faction)
                        setElementData(v,"GangRank",GangRank)
                        if getTeamFromName (faction) then
                            setPlayerTeam(v,getTeamFromName (faction))
                        else
                            local team = createTeam(faction,unpack(data["Color"]))
                            setPlayerTeam(v,team)
                        end
                        local oldName = getPlayerName(v)
                        local newName = "["..faction.."]"..oldName
                        setPlayerName(v, newName )
                        if data["X"] ~= 0 and data["Y"] ~= 0 and data["Z"] ~= 0 then
                            setElementPosition(v,data["X"],data["Y"],data["Z"]+0.2)
                        end
                        break
                    end
                end
            end
        end
    end
end
addEventHandler("onResourceStart",resourceRoot,setFactionOnStart)

 

Edited by Shux
Small correction!
  • Thanks 1

Share this post


Link to post
4 minutes ago, Shux said:

function setFactionOnLogin()    local faction, player_rank = getPlayerFaction(source)    local data = getFactionData(faction)    if faction and rank then        for rank,kk in pairs(clanRankNames) do            if ( rank == player_rank ) then                local GangRank = clanRankNames[rank]                setElementData(source,"faction",faction)                setElementData(source,"GangRank",GangRank)                if getTeamFromName (faction) then                    setPlayerTeam(source,getTeamFromName (faction))                else                    local team = createTeam(faction,unpack(data["Color"]))                    setPlayerTeam(source,team)                end                local oldName = getPlayerName(source)                local newName = "["..faction.."]"..oldName                setPlayerName(source, newName )                if data["X"] ~= 0 and data["Y"] ~= 0 and data["Z"] ~= 0 then                    setElementPosition(source,data["X"],data["Y"],data["Z"]+0.2)                end                break            end        end    endendaddEventHandler("onPlayerLogin",root,setFactionOnLogin)function setFactionOnStart()    exports.scoreboard:addScoreboardColumn("GangRank")    for i, v in ipairs (getElementsByType ("player")) do        local acc = getPlayerAccount (v)        if not isGuestAccount (acc) then            local faction, player_rank = getPlayerFaction(v)            local data = getFactionData(faction)            if faction and rank then                for rank,kk in pairs(clanRankNames) do                    if ( rank == player_rank ) then                        local GangRank = clanRankNames[rank]                        setElementData(v,"faction",faction)                        setElementData(v,"GangRank",GangRank)                        if getTeamFromName (faction) then                            setPlayerTeam(v,getTeamFromName (faction))                        else                            local team = createTeam(faction,unpack(data["Color"]))                            setPlayerTeam(v,team)                        end                        local oldName = getPlayerName(v)                        local newName = "["..faction.."]"..oldName                        setPlayerName(v, newName )                        if data["X"] ~= 0 and data["Y"] ~= 0 and data["Z"] ~= 0 then                            setElementPosition(v,data["X"],data["Y"],data["Z"]+0.2)                        end                        break                    end                end            end        end    endendaddEventHandler("onResourceStart",resourceRoot,setFactionOnStart)

 

Thank you for responding. but where do I put this? :(

 

4 minutes ago, Pedro001 said:

Thank you for responding. but where do I put this? :(

 

I guess I found it, But I still get the number on the scoreboard. Is it really possible to get the name shown instead of the number? 

I don't wanna bother you guys. 

Share this post


Link to post

Use that as a replacement of the code in your server file where your 'onPlayerLogin' and 'onResourceStart' events triggers

Edited by Shux
  • Thanks 1

Share this post


Link to post
8 minutes ago, Shux said:

Use that as a replacement of the code in your server file where your 'onPlayerLogin' and 'onResourceStart' events triggers

I did it, I don't get eny errors, but nothing is shown on the scoreboard though. 

Share this post


Link to post
2 minutes ago, Pedro001 said:

I did it, I don't get eny errors, but nothing is shown on the scoreboard though. 

Oops! Forgot to replace something that I changed in your code leading to me checking a variable that didn't exist. I edited my code, try it now.

  • Thanks 1

Share this post


Link to post
21 minutes ago, Shux said:

Oops! Forgot to replace something that I changed in your code leading to me checking a variable that didn't exist. I edited my code, try it now.

MAAAAAAAAAN! I WORKED!!! :D Thank you sooo much! I was almost giving it up! 

Thank you very much for that!! I really appreciate it! 

  • Like 1

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.