Using the below native is returning a nil value for a global function called client-side.
Native
RegisterPedheadshotTransparent(PlayerPedId())
Error
SCRIPT ERROR: @resource/file.lua:<line>: attempt to call a nil value (global 'RegisterPedheadshotTransparent')
However, the below bit of code works somewhat.
Citizen.InvokeNative(0x953563CE563143AF, PlayerPedId())
Code to replicate
local setup = false
local headshot
RegisterCommand('test', function(source, args, rawCommand)
loadImageProfil()
end)
Citizen.CreateThread(function()
while true do
if setup then
DrawSprite(headshot, headshot, 0.5, 0.5, 0.0375, 0.0653, 0.0, 255, 255, 255, 1000)
end
Citizen.Wait(1)
end
end)
function loadImageProfil()
if not setup then
CurrentPedModel = GetEntityModel(PlayerPedId())
-- local handle = Citizen.InvokeNative(0x953563CE563143AF, PlayerPedId())
local handle = RegisterPedheadshotTransparent(PlayerPedId())
print(handle)
while not IsPedheadshotReady(handle) or not IsPedheadshotValid(handle) do
Wait(100)
end
Citizen.Wait(100)
headshot = GetPedheadshotTxdString(handle)
setup = not setup
elseif setup and headshot ~= nil then
UnregisterPedheadshot(handle)
setup = not setup
print("removed")
end
end