Jump to content

Removing HUD?


AserOsama

Recommended Posts

Well, I want to delete the GTA SA original HUD. So I made a script using SetPlayerHudComponentVisible function and It worked but here the problem comes when I get killed and I respawn, It shows again!

local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted" }

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
function ()
	for _, component in ipairs( components ) do
		setPlayerHudComponentVisible( component, false )
	end
end)

I want to know the function I can use to disable HUD on resource start and on player respawn.

Thanks!
 

Edited by AserOsama
Link to comment
7 minutes ago, AserOsama said:

Well, I want to delete the GTA SA original HUD. So I made a script using SetPlayerHudComponentVisible function and It worked but here the problem comes when I get killed and I respawn, It shows again!


local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted" }

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
function ()
	for _, component in ipairs( components ) do
		setPlayerHudComponentVisible( component, false )
	end
end)

I want to know the function I can use to disable HUD on resource start and on player respawn.

Thanks!
 

Either the current spawn/death script does that intentionally, or it is a built-in thing.

Just hide it again depending where it happens, either onClientPlayerWasted or onClientPlayerSpawn, or both. Try stopping the default spawn/death resource and try again.

Link to comment
3 minutes ago, MadnessReloaded said:

Either the current spawn/death script does that intentionally, or it is a built-in thing.

Just hide it again depending where it happens, either onClientPlayerWasted or onClientPlayerSpawn, or both. Try stopping the default spawn/death resource and try again.

If you could explain more?

like this? 

local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted" }

addEventHandler("onClientPlayerWasted", getResourceRootElement(getThisResource()),
function ()
	for _, component in ipairs( components ) do
		setPlayerHudComponentVisible( component, false )
	end
end)

local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted" }

addEventHandler("onClientPlayerSpawn", getResourceRootElement(getThisResource()),
function ()
	for _, component in ipairs( components ) do
		setPlayerHudComponentVisible( component, false )
	end
end)

 

Link to comment

Exactly, but don't use getResourceRootElement in this case, it has nothing to do with the event. Use localPlayer, since you want to check if you die, not others.

local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted" }

addEventHandler("onClientPlayerWasted", localPlayer,
function ()
	for _, component in ipairs( components ) do
		setPlayerHudComponentVisible( component, false )
	end
end)

local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted" }

addEventHandler("onClientPlayerSpawn", localPlayer,
function ()
	for _, component in ipairs( components ) do
		setPlayerHudComponentVisible( component, false )
	end
end)

 

  • Thanks 1
Link to comment
  • 4 weeks later...

Bump,

It's now working but when I login, The ammo and weapon shows up.

Quote

local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted", "area_name", "vehicle_name", "radio" }

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
function ()
	for _, component in ipairs( components ) do
		setPlayerHudComponentVisible( component, false )
	end
end) 

local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted", "area_name", "vehicle_name", "radio" }

addEventHandler("onClientPlayerWasted", localPlayer,
function ()
	for _, component in ipairs( components ) do
		setPlayerHudComponentVisible( component, false )
	end
end)

local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted", "area_name", "vehicle_name", "radio" }

addEventHandler("onClientPlayerSpawn", localPlayer,
function ()
	for _, component in ipairs( components ) do
		setPlayerHudComponentVisible( component, false )
	end
end)

local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted", "area_name", "vehicle_name", "radio" }

addEventHandler("onClientPlayerJoin", localPlayer,
function ()
	for _, component in ipairs( components ) do
		setPlayerHudComponentVisible( component, false )
	end
end)

local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted", "area_name", "vehicle_name", "radio" }

addEventHandler("onClientPlayerLogin", localPlayer,
function ()
	for _, component in ipairs( components ) do
		setPlayerHudComponentVisible( component, false )
	end
end)

 

3g27ZCO.png

Link to comment

You can use setTimer and check

like this;


local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted", "area_name", "vehicle_name", "radio" }
setTimer(function()
	for i,v in pairs(components)
		if isPlayerHudComponentVisible(v)then 
			setPlayerHudComponentVisible( v, false ) 
		end
	end
end, 1000,0)

 

Link to comment
1 hour ago, Mahlukat said:

You can use setTimer and check

like this;


local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted", "area_name", "vehicle_name", "radio" }
setTimer(function()
	for i,v in pairs(components)
		if isPlayerHudComponentVisible(v)then 
			setPlayerHudComponentVisible( v, false ) 
		end
	end
end, 1000,0)

 

 

1 hour ago, CodyJ(L) said:

setTimer(setPlayerHudComponentVisible, 1000,0,'all', false )

 

That's correct?

local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted", "area_name", "vehicle_name", "radio" }

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),
function ()
	for _, component in ipairs( components ) do
	setTimer(setPlayerHudComponentVisible 1000,0, component, false )
	end
end) 

 

Link to comment
function hideall(player)
	showPlayerHudComponent ( "ammo", false )
	showPlayerHudComponent ( "area_name", false )
	showPlayerHudComponent ( "armour", false )
	showPlayerHudComponent ( "breath", false )
	showPlayerHudComponent ( "clock", false )
	showPlayerHudComponent ( "health", false )
	showPlayerHudComponent ( "money", false )
	showPlayerHudComponent ( "vehicle_name", false )
	showPlayerHudComponent ( "weapon", false )
	showPlayerHudComponent ( "radio", false )
end
addEventHandler ( "onClientResourceStart", getRootElement(), hideall )

function showall(player)
	showPlayerHudComponent ( "ammo", true )
	showPlayerHudComponent ( "area_name", true )
	showPlayerHudComponent ( "armour", true )
	showPlayerHudComponent ( "breath", true )
	showPlayerHudComponent ( "clock", true )
	showPlayerHudComponent ( "health", true )
	showPlayerHudComponent ( "money", true )
	showPlayerHudComponent ( "vehicle_name", true )
	showPlayerHudComponent ( "weapon", true )
	showPlayerHudComponent ( "radio", true )
end
addEventHandler ( "onClientResourceStop", resourceRoot, showall )

This should be work. Add this on client side.

  • Like 1
Link to comment
  • 3 years later...

Nice its worked Thanks a lot!

 

On 24/01/2018 at 08:12, DRW said:

Exactly, but don't use getResourceRootElement in this case, it has nothing to do with the event. Use localPlayer, since you want to check if you die, not others.

local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted" }

addEventHandler("onClientPlayerWasted", localPlayer,
function ()
	for _, component in ipairs( components ) do
		setPlayerHudComponentVisible( component, false )
	end
end)

local components = { "weapon", "ammo", "health", "clock", "money", "breath", "armour", "wanted" }

addEventHandler("onClientPlayerSpawn", localPlayer,
function ()
	for _, component in ipairs( components ) do
		setPlayerHudComponentVisible( component, false )
	end
end)

 

This worked correcty for me :)

 

  • Like 1
Link to comment
  • 8 months later...

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