Jump to content

Erro ao colocar getElementData em scoreboard


Recommended Posts

Boa noite, tenho uma scoreboard e estou tentando colocar o nome do grupo ACL do jogador para aparecer nela, faço a checagem de um ACL por um, porém ao abrir a sscoreboard aparece apenas "-" no local de que era para aparecer a ACL, o código está no client-side:

addEventHandler ( "onPlayerJoin", root, 
    function ( ) 
        setElementData ( source, "GRUPO", "Civil" ) 
    end 
) 
  
addEventHandler ( "onPlayerLogin", root, 
    function ( _, acc ) 
        local accountName = getAccountName ( acc ) 
        if isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "EB" ) ) then 
            setElementData ( source, "GRUPO", "EB" ) 
        elseif isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "GARRA" ) ) then 
            setElementData ( source, "GRUPO", "GARRA" )
		elseif isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "ROTA" ) ) then 
            setElementData ( source, "GRUPO", "ROTA" )
		elseif isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "PMSP" ) ) then 
            setElementData ( source, "GRUPO", "PSMP" )
		elseif isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "ROCAM" ) ) then 
            setElementData ( source, "GRUPO", "ROCAM" )
		elseif isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "PCC" ) ) then 
            setElementData ( source, "GRUPO", "PCC" )
		elseif isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "CV" ) ) then 
            setElementData ( source, "GRUPO", "CV" )	
        end
    end 
)









scoreboard = {}
function playersShow()
    scoreboard = {}
    for i,player in ipairs(getElementsByType("player")) do
	    --if not getPlayerTeam(player) then
	        table.insert(scoreboard,{"player",player})
		--end
	end
	--[[for i,team in ipairs(getElementsByType("team")) do
	    if (tonumber(countPlayersInTeam(team))>=1) then
	        table.insert(scoreboard,{"teamName",team})
            for i,playerTeam in ipairs (getPlayersInTeam(team)) do
			    table.insert(scoreboard,{"player",playerTeam})
            end
		end
	end--]]
end


rowNow = 0
rowsCount = math.floor(sY/22)-6
function drawScoreboard()
    playersShow()
	count = math.min(#scoreboard,rowsCount)
	local x = sX/2 - 320
	local y = sY/2 - count*20 / 2
	local cx, cy = 0,0
	if isCursorShowing() then
		cx, cy = getCursorPosition()
		cx = cx * sX
		cy = cy * sY
	end
	showCursor(getKeyState("mouse2"))
	dxDrawRectangle(x,y-52,640,count*22+52,tocolor(0,0,0,150))
	dxDrawRecLine(x,y-52,640,count*22+52,tocolor(0,0,0,0))
	dxDrawRectangle(x+1,y-22,638,22,tocolor(0,0,0,0))
	_dxText("************************",x+150,y-51,sX,sY,255,255,255,255,1,sor,"left","top",true,false,false,false)
	_dxText(#getElementsByType("player").." / "..maxPlayer,x,y-50,x+632,y-28,255,255,255,255,1,sor,"right","center",true,false,false,false)
	_dxText("ID",x,y-22,x+35,y,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
	_dxText("Nome",x+40,y-22,sX,y,255,255,255,255,1,"default-bold","left","center",true,false,false,false)
	_dxText("País",x+178,y-22,x+244,y,255,255,255,255,1,"default-bold","left","center",true,false,false,false)
	_dxText("Emprego",x+244,y-22,x+310,y,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
	_dxText("Level",x+310,y-22,x+376,y,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
	_dxText("Fac/Corp",x+376,y-22,x+442,y,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
	_dxText("Morreu",x+442,y-22,x+508,y,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
	_dxText("Tempo",x+500,y-22,x+568,y,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
	_dxText("Ping",x+574,y-22,x+640,y,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
	for i=1,count do
	    posY = y+(i-1)*22
	    if scoreboard[i+rowNow][1] == "player" then
		    if scoreboard[i+rowNow][2] == localPlayer then
			    dxDrawRectangle(x,posY,640,22,tocolor(0,50,0,100))
			end
			if isCursorShowing() and cx > x and cx < x + 640 and cy > posY and cy < posY + 22 then
			    dxDrawRectangle(x,posY,640,22,tocolor(0,0,0,200))
			end
			_dxText(getElementData(scoreboard[i+rowNow][2],"ID")or"?",x,posY,x+35,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
			if getElementData(scoreboard[i+rowNow][2],"AFK") then afk="#FF0000AFK- " else afk="" end
			_dxText(afk.._getPlayerName(scoreboard[i+rowNow][2]),x+40,posY,sX,posY+22,255,255,255,255,1,"default-bold","left","center",false,false,false,true)
			country = getElementData(scoreboard[i+rowNow][2],"country") or "?"
			if country == "" then country = "?" end
			_dxText(string.upper(country),x+204,posY,sX,posY+22,255,255,255,255,1,"default-bold","left","center",true,false,false,false)
			if country == "?" then country = "World" end
			if country and fileExists(":admin/client/images/flags/"..country..".png") then
				dxDrawImage(x+184,posY+2,16,16,":admin/client/images/flags/"..country..".png",0,0,0,tocolor(255,255,255,255))
			end
			_dxText(getElementData(scoreboard[i+rowNow][2],"Emprego")or"-",x+225,posY,x+325,posY+22,255,255,255,255,1,"default-bold","left","center",true,false,false,false)
			_dxText(getElementData(scoreboard[i+rowNow][2],"Level")or"-",x+310,posY,x+376,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
			_dxText(getElementData(scoreboard[i+rowNow][2],"GRUPO")or"-",x+376,posY,x+442,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
			_dxText(getElementData(scoreboard[i+rowNow][2],"deaths")or"-",x+442,posY,x+508,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
			_dxText(getElementData(scoreboard[i+rowNow][2],"Tempo")or"-",x+500,posY,x+568,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
			_dxText(getPlayerPing(scoreboard[i+rowNow][2]),x+574,posY,x+640,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false)

		end
		if scoreboard[i+rowNow][1] == "teamName" then
		    dxDrawRectangle(x,posY,640,22,tocolor(255,255,255,15))
			r,g,b = getTeamColor(scoreboard[i+rowNow][2])
		    _dxText(getTeamName(scoreboard[i+rowNow][2]),x+10,posY,sX,posY+22,r,g,b,255,1,"default-bold","left","center",false,false,false,true)
		end
	end
	if rowsCount < #scoreboard then
		size = rowsCount*22
		_size = size/#scoreboard
		__size = _size*rowsCount
		dxDrawRectangle(x+630,y,10,size,tocolor(255,255,255,20))
		dxDrawRectangle(x+630,y+rowNow*_size,10,__size,tocolor(0,0,0,255))
	end
end

 

Edited by Nadion
Link to comment
4 hours ago, Jonas^ said:

Como quer que funcione usando funções server-side em client-side?

Acabei alterando e colocando o setElementData no server e ainda sim aparece a mesma coisa: "-"

Server:

addEventHandler ( "onPlayerJoin", root, 
    function ( ) 
        setElementData ( source, "GRUPO", Civil ) 
    end 
) 
  
addEventHandler ( "onPlayerLogin", root, 
    function ( _, acc ) 
        local accountName = getAccountName ( acc ) 
        if isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "EB" ) ) then 
            setElementData ( source, "GRUPO", EB ) 
        elseif isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "GARRA" ) ) then 
            setElementData ( source, "GRUPO", GARRA )
		elseif isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "ROTA" ) ) then 
            setElementData ( source, "GRUPO", ROTA )
		elseif isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "PMSP" ) ) then 
            setElementData ( source, "GRUPO", PSMP )
		elseif isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "ROCAM" ) ) then 
            setElementData ( source, "GRUPO", ROCAM )
		elseif isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "PCC" ) ) then 
            setElementData ( source, "GRUPO", PCC )
		elseif isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "CV" ) ) then 
            setElementData ( source, "GRUPO", CV )	
        end
    end 
)

Client:

function drawScoreboard()
    playersShow()
	count = math.min(#scoreboard,rowsCount)
	local x = sX/2 - 320
	local y = sY/2 - count*20 / 2
	local cx, cy = 0,0
	if isCursorShowing() then
		cx, cy = getCursorPosition()
		cx = cx * sX
		cy = cy * sY
	end
	showCursor(getKeyState("mouse2"))
	dxDrawRectangle(x,y-52,640,count*22+52,tocolor(0,0,0,150))
	dxDrawRecLine(x,y-52,640,count*22+52,tocolor(0,0,0,0))
	dxDrawRectangle(x+1,y-22,638,22,tocolor(0,0,0,0))
	_dxText("           ",x+150,y-51,sX,sY,255,255,255,255,1,sor,"left","top",true,false,false,false)
	_dxText(#getElementsByType("player").." / "..maxPlayer,x,y-50,x+632,y-28,255,255,255,255,1,sor,"right","center",true,false,false,false)
	_dxText("ID",x,y-22,x+35,y,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
	_dxText("Nome",x+40,y-22,sX,y,255,255,255,255,1,"default-bold","left","center",true,false,false,false)
	_dxText("País",x+178,y-22,x+244,y,255,255,255,255,1,"default-bold","left","center",true,false,false,false)
	_dxText("Emprego",x+244,y-22,x+310,y,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
	_dxText("Level",x+310,y-22,x+376,y,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
	_dxText("Fac/Corp",x+376,y-22,x+442,y,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
	_dxText("Morreu",x+442,y-22,x+508,y,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
	_dxText("Tempo",x+500,y-22,x+568,y,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
	_dxText("Ping",x+574,y-22,x+640,y,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
	for i=1,count do
	    posY = y+(i-1)*22
	    if scoreboard[i+rowNow][1] == "player" then
		    if scoreboard[i+rowNow][2] == localPlayer then
			    dxDrawRectangle(x,posY,640,22,tocolor(0,50,0,100))
			end
			if isCursorShowing() and cx > x and cx < x + 640 and cy > posY and cy < posY + 22 then
			    dxDrawRectangle(x,posY,640,22,tocolor(0,0,0,200))
			end
			_dxText(getElementData(scoreboard[i+rowNow][2],"ID")or"?",x,posY,x+35,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
			if getElementData(scoreboard[i+rowNow][2],"AFK") then afk="#FF0000AFK- " else afk="" end
			_dxText(afk.._getPlayerName(scoreboard[i+rowNow][2]),x+40,posY,sX,posY+22,255,255,255,255,1,"default-bold","left","center",false,false,false,true)
			country = getElementData(scoreboard[i+rowNow][2],"country") or "?"
			if country == "" then country = "?" end
			_dxText(string.upper(country),x+204,posY,sX,posY+22,255,255,255,255,1,"default-bold","left","center",true,false,false,false)
			if country == "?" then country = "World" end
			if country and fileExists(":admin/client/images/flags/"..country..".png") then
				dxDrawImage(x+184,posY+2,16,16,":admin/client/images/flags/"..country..".png",0,0,0,tocolor(255,255,255,255))
			end
			_dxText(getElementData(scoreboard[i+rowNow][2],"Emprego")or"-",x+225,posY,x+325,posY+22,255,255,255,255,1,"default-bold","left","center",true,false,false,false)
			_dxText(getElementData(scoreboard[i+rowNow][2],"Level")or"-",x+310,posY,x+376,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
			_dxText(getElementData(scoreboard[i+rowNow][2],"GRUPO")or"-",x+376,posY,x+442,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
			_dxText(getElementData(scoreboard[i+rowNow][2],"deaths")or"-",x+442,posY,x+508,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
			_dxText(getElementData(scoreboard[i+rowNow][2],"Tempo")or"-",x+500,posY,x+568,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false)
			_dxText(getPlayerPing(scoreboard[i+rowNow][2]),x+574,posY,x+640,posY+22,255,255,255,255,1,"default-bold","center","center",true,false,false,false)

		end
		if scoreboard[i+rowNow][1] == "teamName" then
		    dxDrawRectangle(x,posY,640,22,tocolor(255,255,255,15))
			r,g,b = getTeamColor(scoreboard[i+rowNow][2])
		    _dxText(getTeamName(scoreboard[i+rowNow][2]),x+10,posY,sX,posY+22,r,g,b,255,1,"default-bold","left","center",false,false,false,true)
		end
	end
	if rowsCount < #scoreboard then
		size = rowsCount*22
		_size = size/#scoreboard
		__size = _size*rowsCount
		dxDrawRectangle(x+630,y,10,size,tocolor(255,255,255,20))
		dxDrawRectangle(x+630,y+rowNow*_size,10,__size,tocolor(0,0,0,255))
	end
end

 

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