Jump to content

speedometer lagging players


Recommended Posts

Posted (edited)

Hello! I made a speedometer to show some vehicle parameters. however, it is lagging players when enabled. I can not find a solution. can anybody help me?

This is my Client-side 

local rx, ry = guiGetScreenSize ( )


function vehiclestatus ( )
	if ( isPedInVehicle ( localPlayer ) == false ) then return false end
	local x, y, z = getElementPosition( localPlayer )
	local car = getPedOccupiedVehicle ( localPlayer )
	local sx, sy, sz = getElementVelocity ( car )
	local kphSpeed = math.ceil( ( ( sx^2 + sy^2 + sz^2 ) ^ ( 0.5 ) ) * 161 )
	local mphSpeed = math.ceil( ( ( ( sx^2 + sy^2 + sz^2 ) ^ ( 0.5 ) ) * 161 ) / 1.61 )
	local health = getElementHealth ( car )
	--local name = getVehicleName ( car )
	local currenthealth = math.floor( health/10 )
	getElementHealth ( vehicle )	
	dxDrawRectangle( ( rx-205 ), ( ry-78 ), 199, 65, tocolor(0, 0, 0, 180), true)
	dxDrawText ( "#1e90ffVelocidade: #FFFFFF"..tostring(kphSpeed).." Kmh / "..tostring(mphSpeed).." Mph", ( rx - 199 ), ( ry - 77 ), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1,"default-bold", "left", "top", false, false, true, true, false )
	dxDrawText ( "#1e90ffDurabilidade: #FFFFFF"..tostring(currenthealth).."/100", ( rx - 199 ), ( ry - 53 ), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1,"default-bold", "left", "top", false, false, true, true, false )
	dxDrawText ( "#1e90ffLocalidade: #FFFFFF" .. getZoneName(x, y, z), (rx - 199 ), ( ry - 29), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1, "default-bold", "left", "top", false, false, true, true, false )
end
addEventHandler ( "onClientRender", root, vehiclestatus )

 

Edited by Nickqq
  • Moderators
Posted

@Nickqq

Line 14, might show a warning every frame. It also has no purpose, so feel free to remove it.

 

Can you show me the debugconsole?

 

 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
5 hours ago, IIYAMA said:

@Nickqq

Line 14, might show a warning every frame. It also has no purpose, so feel free to remove it.

 

Can you show me the debugconsole?

 

 

It worked! How did I not realize that ?! hahaha Thank you so much!

  • Like 1

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