Jump to content

Carteira lagada


Recommended Posts

        dxDrawImage(x*767, y*280, x*34, y*32, "carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText("R$ "..convertNumber(getPlayerMoney()), x*811, y*280, x*969, y*312, tocolor(19, 169, 0, 254), x*1.00, "default", "center", "center", false, false, false, false, false)
        dxDrawText("CARTEIRAS DE VEÍCULOS:", x*391, y*278, x*545, y*315, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("A:", x*392, y*325, x*423, y*348, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "center", "center", false, false, false, false, false)
		if getElementData(localPlayer, "temCategoriaA") then
        dxDrawText("POSSUI", x*440, y*325, x*545, y*348, tocolor(0, 255, 0, 255), x*1.00, "default-bold", "center", "center", false, false, false, false, false)
		else
        dxDrawText("NÃO POSSUI", x*440, y*325, x*545, y*348, tocolor(255, 0, 0, 255), x*1.00, "default-bold", "center", "center", false, false, false, false, false)
		end
        dxDrawText("B:", x*392, y*358, x*423, y*381, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("C:", x*392, y*391, x*423, y*414, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("D:", x*392, y*424, x*423, y*447, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("E:", x*392, y*457, x*423, y*480, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "center", "center", false, false, false, false, false)
		if getElementData(localPlayer, "temCategoriaB") then
        dxDrawText("POSSUI", x*440, y*358, x*545, y*381, tocolor(0, 255, 0, 255), x*1.00, "default-bold", "center", "center", false, false, false, false, false)
		else
		dxDrawText("NÃO POSSUI", x*440, y*358, x*545, y*381, tocolor(255, 0, 0, 255), x*1.00, "default-bold", "center", "center", false, false, false, false, false)
		end
		if getElementData(localPlayer, "temCategoriaC") then
        dxDrawText("POSSUI", x*440, y*424, x*545, y*447, tocolor(0, 255, 0, 255), x*1.00, "default-bold", "center", "center", false, false, false, false, false)
		else
		dxDrawText("NÃO POSSUI", x*440, y*424, x*545, y*447, tocolor(255, 0, 0, 255), x*1.00, "default-bold", "center", "center", false, false, false, false, false)
		end
		if getElementData(localPlayer, "temCategoriaD") then
        dxDrawText("POSSUI", x*440, y*391, x*545, y*414, tocolor(0, 255, 0, 255), x*1.00, "default-bold", "center", "center", false, false, false, false, false)
		else
		dxDrawText("NÃO POSSUI", x*440, y*391, x*545, y*414, tocolor(255, 0, 0, 255), x*1.00, "default-bold", "center", "center", false, false, false, false, false)
		end
		if getElementData(localPlayer, "temCategoriaE") then
        dxDrawText("POSSUI", x*440, y*457, x*545, y*480, tocolor(0, 255, 0, 255), x*1.00, "default-bold", "center", "center", false, false, false, false, false)
		else
		dxDrawText("NÃO POSSUI", x*440, y*457, x*545, y*480, tocolor(255, 0, 0, 255), x*1.00, "default-bold", "center", "center", false, false, false, false, false)
		end
		if getElementData(localPlayer, "personSistema") then
		local personSistema = getElementData(localPlayer, "personSistema")
		local mc = split(personSistema, ',')
        dxDrawText("NOME: #ffdead".. mc[1], x*745, y*316, x*969, y*346, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "left", "center", false, false, false, true, false)
		else
        dxDrawText("NOME: #ffdead", x*745, y*316, x*969, y*346, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "left", "center", false, false, false, true, false)
		end
		local mess = getElementData(localPlayer, "moneyPraMostrarNaCarteiraEtrab")
		local mc = split(mess, ',')
        dxDrawText("TRABALHO ATUAL: #FFDEAD"..mc[2], x*745, y*356, x*969, y*389, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "left", "center", false, false, false, true, false)
		if getElementData(localPlayer, "personSistema") then
		local personSistema = getElementData(localPlayer, "personSistema")
		local mc = split(personSistema, ',') 
		dxDrawText("RG: #FFDEAD".. mc[2], x*805, y*394, x*927, y*427, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "left", "center", false, false, false, true, false)
		else
		dxDrawText("RG: #FFDEADOito digitos - 0", x*805, y*394, x*927, y*427, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "left", "center", false, false, false, true, false)
		end
		dxDrawRectangle(x*575, y*509, x*220, y*34, tocolor(254, 254, 254, 170), false)
        dxDrawText("Pressione 'M' para fechar a carteira", x*594, y*509, x*772, y*543, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("feito por: +zMpyster", x*866, y*530, x*975, y*543, tocolor(255, 255, 255, 255), x*1.00, "default", "left", "top", false, false, false, false, false)
		if getElementData(localPlayer, "personSistema") then
		local personSistema = getElementData(localPlayer, "personSistema")
		local mc = split(personSistema, ',')	
		dxDrawText("País: #FFDEAD".. mc[3], x*800, y*432, x*931, y*465, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "left", "center", false, false, false, true, false)
		else
		dxDrawText("País: #FFDEAD", x*800, y*432, x*931, y*465, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "left", "center", false, false, false, true, false)
		end
		if getElementData(localPlayer, "personSistema") then
		local personSistema = getElementData(localPlayer, "personSistema")
		local mc = split(personSistema, ',')
		dxDrawText("Sexo: #FFDEAD".. mc[4], x*800, y*470, x*931, y*503, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "left", "center", false, false, false, true, false)
		else
		dxDrawText("Sexo: #FFDEAD", x*800, y*470, x*931, y*503, tocolor(255, 255, 255, 255), x*1.00, "default-bold", "left", "center", false, false, false, true, false)

Esse código verifica a carteira de veículo, dinheiro, trabalho,  sexo, nome, rg e para abrir a carteira é só apertar a tecla 'M', o problema é que toda vez que alguém abre a carteira o uso do client no /ipb vai de 0% para 5,50%, como posso reduzir esse uso de cpu?

Link to comment
  • Moderators

Nesse script tem só esse código ou ele é maior?  O que eu faria nesse mesmo código DX seria verificar os dados do jogador sem ser com a função getElementData. Pode não ter relação com essa função, nunca testei o quanto essa função causa à performance, mas sei que a função setElementData deve sempre evitar o seu uso excessivo.

Tente uma forma alternativa, armazenando esses dados numa tabela e faça o mesmo teste.

Edited by DNL291
Link to comment
playerInfo = {}
function abrir1213241141241 ()
if not isPedInVehicle(localPlayer) then
if pqwd == false then
addEventHandler ("onClientRender", root, dx123433632312312)
if getElementData(localPlayer, "moneyPraMostrarNaCarteiraEtrab") then
local mess = getElementData(localPlayer, "moneyPraMostrarNaCarteiraEtrab")
local mc = split(mess, ',')
playerInfo[1] = mc[2]
end
if getElementData(localPlayer, "personSistema") then
local personSistema = getElementData(localPlayer, "personSistema")
local mc = split(personSistema, ',')
playerInfo[2] = mc[1]
playerInfo[3] = mc[2]
playerInfo[4] = mc[3]
playerInfo[5] = mc[4]
if getElementData(localPlayer, "temCategoriaA") then
playerInfo[6] = true
end
if getElementData(localPlayer, "temCategoriaB") then
playerInfo[7] = true
end
if getElementData(localPlayer, "temCategoriaC") then
playerInfo[8] = true
end
if getElementData(localPlayer, "temCategoriaD") then
playerInfo[9] = true
end
if getElementData(localPlayer, "temCategoriaE") then
playerInfo[10] = true
end
end
pqwd = true
elseif pqwd == true then
removeEventHandler("onClientRender", root, dx123433632312312)
pqwd = false
end
end
end
bindKey("M", "down", abrir1213241141241)

Aqui o teste

13 minutes ago, DNL291 said:

Nesse script tem só esse código ou ele é maior?  O que eu faria nesse mesmo código DX seria verificar os dados do jogador sem ser com a função getElementData. Pode não ter relação com essa função, nunca testei o quanto essa função causa à performance, mas sei que a função setElementData deve sempre evitar o seu uso excessivo.

Tente uma forma alternativa, armazenando esses dados numa tabela e faça o mesmo teste.

Eu fiz isso no próprio lado do cliente, e coloquei uma função sem evento manipulador em cima da onClientRender, a onClientRender só iria acontecer se a função onde eu passava as informções fosse chamada, sim só tem isso no código

Edited by zMpyster
Link to comment
3 minutes ago, DNL291 said:

E quanto ao resultado mostrado pelo ipb, como ficou?

Obs: indente o seu código por favor.

Mesma coisa, 5 mb quando eu abria a carteira

playerInfo = {}
function abrir1213241141241 ()
	if not isPedInVehicle(localPlayer) then
		if pqwd == false then
			addEventHandler ("onClientRender", root, dx123433632312312)
			if getElementData(localPlayer, "moneyPraMostrarNaCarteiraEtrab") then
				local mess = getElementData(localPlayer, "moneyPraMostrarNaCarteiraEtrab")
				local mc = split(mess, ',')
				playerInfo[1] = mc[2]
			end
			if getElementData(localPlayer, "personSistema") then
				local personSistema = getElementData(localPlayer, "personSistema")
				local mc = split(personSistema, ',')
				playerInfo[2] = mc[1]
				playerInfo[3] = mc[2]
				playerInfo[4] = mc[3]
				playerInfo[5] = mc[4]
					if getElementData(localPlayer, "temCategoriaA") then
						playerInfo[6] = true
					end
				if getElementData(localPlayer, "temCategoriaB") then
					playerInfo[7] = true
				end	
				if getElementData(localPlayer, "temCategoriaC") then
					playerInfo[8] = true
				end
				if getElementData(localPlayer, "temCategoriaD") then
					playerInfo[9] = true
				end
				if getElementData(localPlayer, "temCategoriaE") then
					playerInfo[10] = true
				end
			end
			pqwd = true
		elseif pqwd == true then
			removeEventHandler("onClientRender", root, dx123433632312312)
			pqwd = false
		end
	end
end
bindKey("M", "down", abrir1213241141241)

Aqui o código identado

Link to comment
  • Moderators

Tente assim:


local playerInfo = {}
local pqwd

function abrir1213241141241 ()
	if not isPedInVehicle(localPlayer) then
		if pqwd == false then
			addEventHandler ("onClientRender", root, dx123433632312312)
			pqwd = true
		elseif pqwd == true then
			removeEventHandler("onClientRender", root, dx123433632312312)
			pqwd = false
		end
	end
end
bindKey("M", "down", abrir1213241141241)

addEventHandler( "onClientElementDataChange", localPlayer,
	function( data )
		if data == "moneyPraMostrarNaCarteiraEtrab" then
		
			local mess = getElementData(source, data)
			if mess then
				local mc = split(mess, ',')
				playerInfo[1] = mc[2]
			end
		elseif data == "personSistema" then
		
			local personSistema = getElementData(source, data)
			if personSistema then
				local mc = split(personSistema, ',')
				playerInfo[2] = mc[1]
				playerInfo[3] = mc[2]
				playerInfo[4] = mc[3]
				playerInfo[5] = mc[4]
			end
		elseif data == "temCategoriaA" then
		
			playerInfo[6] = getElementData(source, data) and true or false
			
		elseif data == "temCategoriaB" then
			
			playerInfo[7] = getElementData(source, data) and true or false
			
		elseif data == "temCategoriaC" then
			
			playerInfo[8] = getElementData(source, data) and true or false
			
		elseif data == "temCategoriaD" then
		
			playerInfo[9] = getElementData(source, data) and true or false
		
		elseif data == "temCategoriaE" then
		
			playerInfo[10] = getElementData(source, data) and true or false
			
		end
	end
)

Se continuar mesma coisa, mostre aqui como está a função do render.

Link to comment
  • Moderators

Acho que o evento não será chamado em certas ocasiões por estar no cliente. Qual a frequência que você tá setando essas datas?

Aquela outra versão do código sua setando na tabela acho que não causaria nenhum problema; o aumento no uso de cpu deve estar sendo causado dentro do "onClientRender", mas acho muito anormal esse código estar fazendo o uso de cpu ir para 5,50%. Pode ter coisa a mais aí... Ou o processador do cliente é fraco demais?

Se quiser me passe o código por privado pra mim analisar melhor ?

Edited by DNL291
Link to comment
38 minutes ago, DNL291 said:

Acho que o evento não será chamado em certas ocasiões por estar no cliente. Qual a frequência que você tá setando essas datas?

Aquela outra versão do código sua setando na tabela acho que não causaria nenhum problema; o aumento no uso de cpu deve estar sendo causado dentro do "onClientRender", mas acho muito anormal esse código estar fazendo o uso de cpu ir para 5,50%. Pode ter coisa a mais aí... Ou o processador do cliente é fraco demais?

Se quiser me passe o código por privado pra mim analisar melhor ?

Mandei lá

  • Like 1
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...