Spawn as 'model'

Hello all ,
i have some custom peds ( player models ) on my server , mostly for police , ambulance ,etc .
Now i want when u go on duty with Police or Ambulance that u spawn as the custom player model instead of taking the cloths only.
because it will take the normal police clothes instead of the new custom models .
only for swat it Will take the custom player model …

I am using ESX_Policejob , and after reading in the codes i found this in client/main.lua :

 --Taken from SuperCoolNinja
      if data.current.value == 'citizen_wear' then
        ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
          local model = nil

          if skin.sex == 0 then
            model = GetHashKey("mp_m_freemode_01")
          else
            model = GetHashKey("mp_f_freemode_01")
          end

          RequestModel(model)
          while not HasModelLoaded(model) do
            RequestModel(model)
            Citizen.Wait(1)
          end

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

          TriggerEvent('skinchanger:loadSkin', skin)
          TriggerEvent('esx:restoreLoadout')
        end)
      end

      if data.current.value == 'police_wear' then

        ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)

          if skin.sex == 0 then
            TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_male)
          else
            TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_female)
          end

        end)

      end

      if data.current.value == 'veste_wear' then
        ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function()
          SetPedComponentVariation(GetPlayerPed(-1), 9, 10, 1, 2)--Gilet
          local playerPed = GetPlayerPed(-1)
          SetPedArmour(playerPed, 100)
          ClearPedBloodDamage(playerPed)
          ResetPedVisibleDamage(playerPed)
          ClearPedLastWeaponDamage(playerPed)
        end)
      end

      if data.current.value == 'veste_wear' then
          ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function()
            SetPedComponentVariation(GetPlayerPed(-1), 9, 10, 1, 2)--Gilet
          end)
      end

      if data.current.value == 'gilet_wear' then
        ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function()
          SetPedComponentVariation(GetPlayerPed(-1), 9, 14, 1, 2)--Sans Gilet
          local playerPed = GetPlayerPed(-1)
          SetPedArmour(playerPed, 0)
          ClearPedBloodDamage(playerPed)
          ResetPedVisibleDamage(playerPed)
          ClearPedLastWeaponDamage(playerPed)
        end)
      end
      if data.current.value == 'sheriff_wear' then

        ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)

        if skin.sex == 0 then

          local model = GetHashKey("s_m_y_sheriff_01")

          RequestModel(model)
          while not HasModelLoaded(model) do
            RequestModel(model)
            Citizen.Wait(0)
          end

          SetPlayerModel(PlayerId(), model)
          SetModelAsNoLongerNeeded(model)
      else
          local model = GetHashKey("s_f_y_sheriff_01")

          RequestModel(model)
          while not HasModelLoaded(model) do
            RequestModel(model)
            Citizen.Wait(0)
          end

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

        end)
      end

      if data.current.value == 'lieutenant_wear' then

        ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)

        if skin.sex == 0 then
          local model = GetHashKey("s_m_y_swat_01")

          RequestModel(model)
          while not HasModelLoaded(model) do
            RequestModel(model)
            Citizen.Wait(0)
          end

          SetPlayerModel(PlayerId(), model)
          SetModelAsNoLongerNeeded(model)
      else
          local model = GetHashKey("s_m_y_swat_01")

          RequestModel(model)
          while not HasModelLoaded(model) do
            RequestModel(model)
            Citizen.Wait(0)
          end

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

        end)
      end

      if data.current.value == 'commandant_wear' then

        ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)

        if skin.sex == 0 then
          local model = GetHashKey("s_m_y_swat_01")

          RequestModel(model)
          while not HasModelLoaded(model) do
            RequestModel(model)
            Citizen.Wait(0)
          end

          SetPlayerModel(PlayerId(), model)
          SetModelAsNoLongerNeeded(model)
      else
          local model = GetHashKey("s_m_y_swat_01")

          RequestModel(model)
          while not HasModelLoaded(model) do
            RequestModel(model)
            Citizen.Wait(0)
          end

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

        end)
      end


      CurrentAction     = 'menu_cloakroom'
      CurrentActionMsg  = _U('open_cloackroom')
      CurrentActionData = {}

    end,
    function(data, menu)

      menu.close()

      CurrentAction     = 'menu_cloakroom'
      CurrentActionMsg  = _U('open_cloackroom')
      CurrentActionData = {}
    end
  )

end

Is it possible to change these codes so u will spawn as the model instead of your personal skin ?,

i appreciate the help :slight_smile:

hey the only thing i was able to do this this code is to change the skin from mp_m_freemode_01 to s_m_y_cop_01 and that was the only way but only problem is that everyone in the server could have the skin. but if disable esx_skin and skin customizer the code will use the local models.

oh yea i found something ,

in the config of esx police :

Config.EnableNonFreemodePeds      = true -- turn this on if you want custom peds  set this to true 

and add this to main.lua

if Config.EnableNonFreemodePeds then
      table.insert(elements, {label = _U('sheriff_wear'), value = 'sheriff_wear'})
      table.insert(elements, {label = _U('lieutenant_wear'), value = 'lieutenant_wear'})
      table.insert(elements, {label = _U('commandant_wear'), value = 'commandant_wear'})
      table.insert(elements, {label = _U('moto_wear'), value = 'moto_wear'})
      table.insert(elements, {label = _U('dea_wear'), value = 'dea_wear'})
      table.insert(elements, {label = _U('invest_wear'), value = 'invest_wear'})
      table.insert(elements, {label = _U('specops_wear'), value = 'specops_wear'})
      table.insert(elements, {label = _U('statepd_wear'), value = 'statepd_wear'})
      table.insert(elements, {label = _U('cstaff_wear'), value = 'cstaff_wear'})
    end
1 Like

nice find!! ill try it out.

Which main.lua is this? Server or client?

Client

hi guys. im try add this on my armyjob and when im click on specops_wear not changed my skin soory guys my english not good