I’m running quite new but fast growing FiveM RP server called SuomiRP.
I was thinking could someone help me with removing the crosshair when u aim down sight ? I’ve seen that some servers has that thing but i’ve not figured it out yet.
--[[------------------------------------------------------------------------
Remove Reticle on ADS (Third Person)
------------------------------------------------------------------------]]--
function ManageReticle()
local ped = GetPlayerPed( -1 )
if ( DoesEntityExist( ped ) and not IsEntityDead( ped ) ) then
if ( GetFollowPedCamViewMode() ~= 4 and IsPlayerFreeAiming() ) then
HideHudComponentThisFrame( 14 )
end
end
end
Citizen.CreateThread( function()
while true do
ManageReticle()
Citizen.Wait( 0 )
end
end )
Changed the code a bit, so now the crosshair dosen’t show up anymore just like i want it to be.
--[[------------------------------------------------------------------------
Remove Reticle on ADS (Third Person)
------------------------------------------------------------------------]]--
function ManageReticle()
local ped = GetPlayerPed( -1 )
if ( DoesEntityExist( ped ) and not IsEntityDead( ped ) ) then
if ( GetFollowPedCamViewMode() ~= 4 and IsPlayerFreeAiming() ) then
HideHudComponentThisFrame( 14 )
end
Citizen.Wait( 0 )
end
HideHudComponentThisFrame( 14 )
end
Citizen.CreateThread( function()
while true do
ManageReticle()
end
end )
I think it’s fine, gonna test it tomorrow on my server.
The piece of code by @WolfKnight179 is enough to make it functional, just create a recourse__.lua and put the code in a seperate .lua as a client script.
I have an issue with this code, now when i aim in first person with a long range weapon there is no ironsight. For example the sniper has no ironsight at all. How to correct it ?
Thanks for the idea !
I’ve tried this and it seems to change nothing, any idea ?
function ManageReticle()
local ped = GetPlayerPed( -1 )
local sniper = {"WEAPON_HEAVYSNIPER", "WEAPON_SNIPERRIFLE", "WEAPON_REMOTESNIPER"}
local weaponsniper = GetCurrentPedWeapon(ped, GetHashKey(sniper), 1)
if ( DoesEntityExist( ped ) and not IsEntityDead( ped ) ) and not weaponsniper then
if ( GetFollowPedCamViewMode() ~= 4 and IsPlayerFreeAiming() ) then
HideHudComponentThisFrame( 14 )
end
end
HideHudComponentThisFrame( 14 )
end
Citizen.CreateThread( function()
while true do
ManageReticle()
Citizen.Wait( 0 )
end
end )
Sort of there, you should define static tables outside of looped functions, also, you’re hiding the crosshair no matter what, as you put HideHudComponentThisFrame( 14 ) under the if statement.
Use this to fix the scope’s being removed:
--[[------------------------------------------------------------------------
Remove Reticle on ADS (Third Person)
------------------------------------------------------------------------]]--
local scopedWeapons =
{
100416529, -- WEAPON_SNIPERRIFLE
205991906, -- WEAPON_HEAVYSNIPER
3342088282 -- WEAPON_MARKSMANRIFLE
}
function HashInTable( hash )
for k, v in pairs( scopedWeapons ) do
if ( hash == v ) then
return true
end
end
return false
end
function ManageReticle()
local ped = GetPlayerPed( -1 )
if ( DoesEntityExist( ped ) and not IsEntityDead( ped ) ) then
local _, hash = GetCurrentPedWeapon( ped, true )
if ( GetFollowPedCamViewMode() ~= 4 and IsPlayerFreeAiming() and not HashInTable( hash ) ) then
HideHudComponentThisFrame( 14 )
end
end
end
Citizen.CreateThread( function()
while true do
ManageReticle()
Citizen.Wait( 0 )
end
end )