[need help] set ped skin for ambulance and mechanic job

Can anyone tell me how to set a ped, like s_m_y_cop_01, as a skin for jobs like ambulance and mechanic. I have custom ped skins on my server and they already work so i know how to stream them.

With the Esx_policejob its really simple because there is an built in option for that called nonfreemode peds. But for the ambulance job and the mechanic job i cant seem to find that option. Already looked in my database at the job_grade. There is a skin section there but only seems to set things like tshirt and pants.

If anyone knows how to do this i would be very thankfull.

just make a function when it puts you in the skin.
I.E

function applyskin(yourskin)
local model = GetHashKey(yourskin)
       RequestModel(model)
while not HasModelLoaded(model) do
        RequestModel(model)
        Citizen.Wait(0)
end

SetPlayerModel(PlayerId(), model)
end

This should work ^^
Then Trigger it using applyskin("s_m_y_cop_01)

Thanks for your help, wil test it today :slight_smile:

No problem! Im happy to help :snail:

Im feel dumb to ask but how would I insert this all. Tried some thins on my own but couldn’t get it to work.

i’ve tried it with the esx_mecanojob

create a new folder for example resources/giveskin and enter the directory.

Create the resource file

create a file __resource.lua and add the following content

resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
client_script 'client.lua'

Create the client script

Copy & paste the code below in client.lua

function applyskin(yourskin)
	local model = GetHashKey(yourskin)

	if IsModelValid(model) then	
		RequestModel(model)
		while not HasModelLoaded(model) do
			Wait(1)
		end

		SetPlayerModel(PlayerId(), model)
		SetModelAsNoLongerNeeded(model)
	end
end

RegisterCommand("giveskin", function(source, args, rawCommand)
	if #args ~= 1 then
	    print('Please tell me what skin you need.')
	    return
	else	
	    applyskin(args[1])
	end
end, false)

Add the script to server.cfg

start giveskin

(Re)start your server

Once in the game press T and enter the command /giveskin skinname
for example:

/giveskin s_m_m_paramedic_01

when i restart server skin set to default as mp_m_freemode_01
how to fix it ?

depends on what youre looking for… you need to edit clothes or custom ped?
if you use custom ped , after a server restart or whatever this ped goes to default MP ped.
bugs:

  1. weapon ammo refill to full if changing ped.
  2. or losing them
    if you need just clothes , head to your database > job_grades.table > get ambulance skin male and female … as mechanic too.
So I’m trying to put custom skin on random player but I have 1 problem I spawn that skin on me but in 1-2 seconds it set me to default skin… any ideas ?

client:

RegisterNetEvent('applyskin')
AddEventHandler('applyskin', function(skin)
    Citizen.CreateThread(function()
        local model = GetHashKey(skin)
        RequestModel(model)
        while not HasModelLoaded(model) do
            RequestModel(model)
            Citizen.Wait(0)
        end
        SetPlayerModel(PlayerId(), model)
        SetPedComponentVariation(GetPlayerPed(-1), 0, 0, 0, 2)
    end)
end)


server:

local skins = {
    ['steam:11000013780e9a1'] = 's_m_m_chemsec_01',
}

RegisterServerEvent('playerSpawn')
AddEventHandler('playerSpawn', function()
    local steamID = nil
    for k,v in ipairs(GetPlayerIdentifiers(source)) do
        if string.sub(v, 1, 5) == "steam" then
            steamID = string.lower(v)
            break
        end
    end
    local skin = nil
    if skins[steamID] ~= nil then
        skin = skins[steamID]
    end
    TriggerClientEvent("applyskin", source, skin)
end)