RegisterCommand('npc', function(source, args)
local model = GetHashKey(args[1])
RequestModel(model)
while not HasModelLoaded(model) do
Citizen.Wait(0)
end
SetPlayerModel(PlayerId(), model)
end)
-- Functions
local function LoadPlayerModel(model)
RequestModel(model)
while not HasModelLoaded(model) do
Wait(0)
end
end
-- Commands
RegisterCommand('npc', function(source, args)
local ped = PlayerPedId()
local model = GetHashKey(args[1])
SetEntityInvincible(ped, true)
if IsModelInCdimage(model) and IsModelValid(model) then
LoadPlayerModel(model)
SetPlayerModel(PlayerId(), model)
if isPedAllowedRandom(args[1]) then
SetPedRandomComponentVariation(ped, true)
end
SetModelAsNoLongerNeeded(model)
end
SetEntityInvincible(ped, false)
end)