Jump to content

Painel não atualiza a lista de players


Recommended Posts

local screenH, screenW = guiGetScreenSize()
local x, y = (screenH/1366), (screenW/768)
local font2 = dxCreateFont("gfx/Blix-Black.ttf", 19)
local dxfont1_font = dxCreateFont("gfx/font.ttf", 11)
local dxfont2_font = dxCreateFont("gfx/font.ttf", 10)

gridListDoar = guiCreateGridList(495, 302, 176, 257, false)
colunaDoar = guiGridListAddColumn(gridListDoar, "Jogadores", 0.9)
guiGridListSetSelectionMode(gridListDoar, 2)
guiSetAlpha(gridListDoar, 0.50)
guiSetVisible(gridListDoar, false)
editBoxDoar = guiCreateEdit(724, 343, 184, 23, tonumber("0"), false)
guiSetVisible(editBoxDoar, false)
guiSetAlpha(editBoxDoar, 0.50)
guiEditSetMaxLength(editBoxDoar, 85555)

for _, player in ipairs(getElementsByType("player")) do
	local rowDoar = guiGridListAddRow(gridListDoar)
	guiGridListSetItemText(gridListDoar, rowDoar, colunaDoar, getPlayerName(player), false, false)
	guiGridListSetItemColor(gridListDoar, rowDoar, colunaDoar, 0, 255, 145)
end

function getPlayerFromPartialName(name)
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
    if name then
        for _, player in ipairs(getElementsByType("player")) do
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
            if name_:find(name, 1, true) then
                return player
            end
        end
    end
end

function SetAll()
	if (trans == true) then
		if tonumber(guiGetText(editBoxDoar)) ~= nil then
			totalDoar = tonumber(guiGetText(editBoxDoar))
		end
	end
end
setTimer(SetAll, 50, 0)
cor = {}
totalDoar = 0
trans = false
function server()
	local dinheiro =  exports.dinheirosujo:getPlayerDirty(getLocalPlayer())
  cor[1] = tocolor(255,255,255,255)
  cor[2] = tocolor(0, 0, 0, 140)
   if cursorPosition(x*948,y*259,x*962,y*288) then cor[1] = tocolor(255,0,0,255) end
   if cursorPosition(x*774,y*376,x*91,y*27) then cor[2] = tocolor(247, 142, 7, 200) end
        dxDrawRectangle(474, 265, 498, 323, tocolor(0, 0, 0, 226), false)
        dxDrawRectangle(474, 265, 498, 26, tocolor(0, 0, 0, 187), false)
		dxDrawText("Enviar Dinheiro Sujo", 473, 265, 972, 292, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawRectangle(x*774,y*376,x*91,y*27,cor[2], false)
        dxDrawText("Enviar", 773, 376, 864, 402, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Dinheiro SUJO : "..dinheiro,x*756,y*413,x*1040,y*430, tocolor(255, 255, 255, 255), 1.00, dxfont2_font, "left", "top", false, false, false, false, false)    
    end

function getPlayerFromPartialName(name)
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
    if name then
        for _, player in ipairs(getElementsByType("player")) do
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
            if name_:find(name, 1, true) then
                return player
            end
        end
    end
end


function getGridlistPlayer()
	local player = getPlayerFromName(guiGridListGetItemText(gridList, guiGridListGetSelectedItem(gridList), 1))
	if (player) then
		return player
	end
end

function dxDrawXeets(absX, absY, sizeX, sizeY, color, ancho)
	dxDrawRectangle(absX, absY, sizeX, ancho, color)
	dxDrawRectangle(absX, absY + ancho, ancho, sizeY - ancho, color)
	dxDrawRectangle(absX + ancho, absY + sizeY - ancho, sizeX - ancho, ancho, color)
	dxDrawRectangle(absX + sizeX - ancho, absY + ancho, ancho, sizeY - ancho * 2, color)
end

function onGridClick()
	local player = getGridlistPlayer()
	if (player == "" or player == nil) then
		return
	else
		triggerServerEvent("onGridClick", getLocalPlayer(), player)
	end
end

function refreshDoar()
	guiGridListClear(gridListDoar)
	if coluna then
		for _, playeritem in ipairs(getElementsByType("player")) do
			local rowDoar = guiGridListAddRow(gridListDoar)
			setTimer(guiGridListSetItemText, 2000, 1, gridListDoar, rowDoar, colunaDoar, getPlayerName(playeritem), false, false)
			setTimer(guiGridListSetItemColor, 2000, 1, gridListDoar, rowDoar, colunaDoar, 0, 255, 145)
		end
	end
end



function getPlayerFromPartialName(name)
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil
    if name then
        for _, player in ipairs(getElementsByType("player")) do
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower()
            if name_:find(name, 1, true) then
                return player
            end
        end
    end
end

function convertNumber(number)
	local formated = number
	while true do
		formated, k = string.gsub(formated, "^(-?%d+)(%d%d%d)", "%1,%2")
		if (k == 0) then
			break
		end
	end
	return formated
end

local componentes = {"armour", "wanted", "weapon", "money", "health", "clock", "breath", "ammo"}
local tableSkins = {1, 2, 7, 9, 10, 11, 12, 14, 15, 16, 18, 28, 310, 311, 312}

function enviar(_,state)
if trans == true then
if state == "down" then
if cursorPosition(x*774,y*376,x*91,y*27) then
selectedDoar = guiGridListGetItemText(gridListDoar, guiGridListGetSelectedItem(gridListDoar), 1)
amount = guiGetText(editBoxDoar)
triggerServerEvent("onGridClickDoar", getLocalPlayer(), selectedDoar, amount)
end
end
end
end
addEventHandler ("onClientClick", root, enviar)

function OpenTrasf()
	if trans == false then
		showCursor (true)
		addEventHandler ("onClientRender", root, server)
		trans = true
		guiSetVisible (gridListDoar,true)
		guiSetVisible (editBoxDoar,true)
		guiSetVisible (coluna,true)
	else
		showCursor (false)
		removeEventHandler ("onClientRender", root,server)
		trans = false
		guiSetVisible (gridListDoar,false)
		guiSetVisible (editBoxDoar,false)
		guiSetVisible (colunaDoar,false)
	end
end
bindKey ("F6", "down", OpenTrasf)

function cursorPosition(x, y, w, h)
	if (not isCursorShowing()) then
		return false
	end
	local mx, my = getCursorPosition()
	local fullx, fully = guiGetScreenSize()
	cursorx, cursory = mx*fullx, my*fully
	if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
		return true
	else
		return false
	end
end

O painel está funcionando perfeitamente porém, não está atualizando a lista dos players. Exemplo: quando um jogador troca de nome em jogo, o nome dele não muda na lista dentro do painel.

Link to comment
function refreshList()
guiGridListClear(gridListDoar)
for _, player in ipairs(getElementsByType("player")) do
	local rowDoar = guiGridListAddRow(gridListDoar)
	guiGridListSetItemText(gridListDoar, rowDoar, colunaDoar, getPlayerName(player), false, false)
	guiGridListSetItemColor(gridListDoar, rowDoar, colunaDoar, 0, 255, 145)
end
end
addEventHandler ("onClientPlayerChangeNick",root,refreshList)
addEventHandler ( "onClientPlayerJoin",root,refreshList)
addEventHandler ( "onClientPlayerQuit",root,refreshList)
refreshList()

 

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