Closed tmgbdark closed 5 years ago
Ligne 67 esx_policejob/client/main.lua Voici ou placer les TriggerServerEvent("player:serviceOn", "police")
function setUniform(job, playerPed)
TriggerEvent('skinchanger:getSkin', function(skin)
if skin.sex == 0 then
if Config.Uniforms[job].male ~= nil then
TriggerEvent('skinchanger:loadClothes', skin, Config.Uniforms[job].male)
TriggerServerEvent("player:serviceOn", "police")
else
ESX.ShowNotification(_U('no_outfit'))
end
if job == 'bullet_wear' then
SetPedArmour(playerPed, 100)
end
else
if Config.Uniforms[job].female ~= nil then
TriggerEvent('skinchanger:loadClothes', skin, Config.Uniforms[job].female)
TriggerServerEvent("player:serviceOn", "police")
else
ESX.ShowNotification(_U('no_outfit'))
end
if job == 'bullet_wear' then
SetPedArmour(playerPed, 100)
end
end
end)
end
Voici ou placer les TriggerServerEvent("player:serviceOff", "police")
function OpenCloakroomMenu()
local playerPed = PlayerPedId()
local grade = PlayerData.job.grade_name
local elements = {
{ label = _U('citizen_wear'), value = 'citizen_wear' },
{ label = _U('bullet_wear'), value = 'bullet_wear' },
{ label = _U('gilet_wear'), value = 'gilet_wear' }
}
if grade == 'recruit' then
table.insert(elements, {label = _U('police_wear'), value = 'recruit_wear'})
elseif grade == 'officer' then
table.insert(elements, {label = _U('police_wear'), value = 'officer_wear'})
elseif grade == 'sergeant' then
table.insert(elements, {label = _U('police_wear'), value = 'sergeant_wear'})
elseif grade == 'intendent' then
table.insert(elements, {label = _U('police_wear'), value = 'intendent_wear'})
elseif grade == 'lieutenant' then
table.insert(elements, {label = _U('police_wear'), value = 'lieutenant_wear'})
elseif grade == 'chef' then
table.insert(elements, {label = _U('police_wear'), value = 'chef_wear'})
elseif grade == 'boss' then
table.insert(elements, {label = _U('police_wear'), value = 'boss_wear'})
end
if Config.EnableNonFreemodePeds then
table.insert(elements, {label = 'Sheriff wear', value = 'freemode_ped', maleModel = 's_m_y_sheriff_01', femaleModel = 's_f_y_sheriff_01'})
table.insert(elements, {label = 'Police wear', value = 'freemode_ped', maleModel = 's_m_y_cop_01', femaleModel = 's_f_y_cop_01'})
table.insert(elements, {label = 'Swat wear', value = 'freemode_ped', maleModel = 's_m_y_swat_01', femaleModel = 's_m_y_swat_01'})
end
ESX.UI.Menu.CloseAll()
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'cloakroom',
{
title = _U('cloakroom'),
align = 'top-left',
elements = elements
}, function(data, menu)
cleanPlayer(playerPed)
if data.current.value == 'citizen_wear' then
if Config.EnableNonFreemodePeds then
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
local isMale = skin.sex == 0
TriggerEvent('skinchanger:loadDefaultModel', isMale, function()
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin)
TriggerEvent('skinchanger:loadSkin', skin)
TriggerServerEvent("player:serviceOff", "police")
TriggerEvent('esx:restoreLoadout')
end)
end)
end)
else
TriggerServerEvent("player:serviceOff", "police")
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin)
TriggerEvent('skinchanger:loadSkin', skin)
end)
end
if Config.MaxInService ~= -1 then
ESX.TriggerServerCallback('esx_service:isInService', function(isInService)
if isInService then
playerInService = false
local notification = {
title = _U('service_anonunce'),
subject = '',
msg = _U('service_out_announce', GetPlayerName(PlayerId())),
iconType = 1
}
TriggerServerEvent('esx_service:notifyAllInService', notification, 'police')
TriggerServerEvent('esx_service:disableService', 'police')
TriggerEvent('esx_policejob:updateBlip')
ESX.ShowNotification(_U('service_out'))
end
end, 'police')
end
end
if Config.MaxInService ~= -1 and data.current.value ~= 'citizen_wear' then
local serviceOk = 'waiting'
ESX.TriggerServerCallback('esx_service:isInService', function(isInService)
if not isInService then
ESX.TriggerServerCallback('esx_service:enableService', function(canTakeService, maxInService, inServiceCount)
if not canTakeService then
ESX.ShowNotification(_U('service_max', inServiceCount, maxInService))
else
serviceOk = true
playerInService = true
local notification = {
title = _U('service_anonunce'),
subject = '',
msg = _U('service_in_announce', GetPlayerName(PlayerId())),
iconType = 1
}
TriggerServerEvent('esx_service:notifyAllInService', notification, 'police')
TriggerEvent('esx_policejob:updateBlip')
ESX.ShowNotification(_U('service_in'))
end
end, 'police')
else
serviceOk = true
end
end, 'police')
while type(serviceOk) == 'string' do
Citizen.Wait(5)
end
-- if we couldn't enter service don't let the player get changed
if not serviceOk then
return
end
end
if
data.current.value == 'recruit_wear' or
data.current.value == 'officer_wear' or
data.current.value == 'sergeant_wear' or
data.current.value == 'intendent_wear' or
data.current.value == 'lieutenant_wear' or
data.current.value == 'chef_wear' or
data.current.value == 'boss_wear' or
data.current.value == 'bullet_wear' or
data.current.value == 'gilet_wear'
then
setUniform(data.current.value, playerPed)
end
if data.current.value == 'freemode_ped' then
local modelHash = ''
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
if skin.sex == 0 then
modelHash = GetHashKey(data.current.maleModel)
else
modelHash = GetHashKey(data.current.femaleModel)
end
ESX.Streaming.RequestModel(modelHash, function()
SetPlayerModel(PlayerId(), modelHash)
SetModelAsNoLongerNeeded(modelHash)
TriggerEvent('esx:restoreLoadout')
end)
end)
end
end, function(data, menu)
menu.close()
CurrentAction = 'menu_cloakroom'
CurrentActionMsg = _U('open_cloackroom')
CurrentActionData = {}
end)
end
Pour rΓ©sumer il faut les placer au moment de la prise de l'uniforme et de la prise de la tenue de civil
bonjour tu aurais un exemple pour mettre levent dans les metier stp