So, there are a few scripts that let you spawn NPCs. But I couldn’t find any that let you change their clothes. So I decided to code my own one. My NPC can have clothes and even hair using the SetPedComponentVariation
native. But then I noticed that this native doesn’t have the option to change the hair color. So I searched for another native and found SetPedHairColor
. It worked for my character when I did SetPedHairColor(GetPlayerPed(-1), hair_color, 0)
, but when I tried SetPedHairColor(npcPed, 0, 0)
, it didn’t work for my NPC. This is my first own script, so if anything in the code doesn’t make sense - just don’t ask.
This is my code:
local characterModel = GetHashKey('mp_m_freemode_01')
local spawnPos = vector4(-372.6020, -273.4057, 32.9582, 323.7569)
local npcPed = CreatePed(4, characterModel, spawnPos.x, spawnPos.y, spawnPos.z, spawnPos.w, false, false)
SetPedComponentVariation(npcPed, 2, 18, 0, 1)
SetPedHairTint(npcPed, 0, 0)
SetPedComponentVariation(npcPed, 11, 190, 0, 2)
SetPedComponentVariation(npcPed, 8, 56, 1, 2)
SetPedComponentVariation(npcPed, 3, 85, 0, 2)
SetPedComponentVariation(npcPed, 4, 35, 0, 2)
SetPedComponentVariation(npcPed, 6, 25, 0, 2)
SetPedComponentVariation(npcPed, 5, 52, 2, 2)
SetPedComponentVariation(npcPed, 9, 64, 0, 2)
SetPedComponentVariation(npcPed, 10, 44, 0, 2)
SetPedComponentVariation(npcPed, 7, 8, 0, 2)
FreezeEntityPosition(npcPed, true)
SetEntityInvincible(npcPed, true)
SetPedCanRagdoll(npcPed, false)
SetBlockingOfNonTemporaryEvents(npcPed, true)
end)
Thanks in advance