Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local CurrentActionData, handcuffTimer, dragStatus, currentTask = {}, {}, {}, {}
- local HasAlreadyEnteredMarker, isDead, isHandcuffed, hasAlreadyJoined, playerInService = false, false, false, false, false
- local LastStation, LastPart, LastPartNum, LastEntity, CurrentAction, CurrentActionMsg
- dragStatus.isDragged, isInShopMenu = false, false
- ESX = nil
- Citizen.CreateThread(function()
- while ESX == nil do
- TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
- Citizen.Wait(0)
- end
- while ESX.GetPlayerData().job2 == nil do
- Citizen.Wait(10)
- end
- ESX.PlayerData = ESX.GetPlayerData()
- end)
- RegisterNetEvent('esx:setJob2')
- AddEventHandler('esx:setJob2', function(job2)
- PlayerData.job2 = job2
- end)
- function cleanPlayer(playerPed)
- SetPedArmour(playerPed, 0)
- ClearPedBloodDamage(playerPed)
- ResetPedVisibleDamage(playerPed)
- ClearPedLastWeaponDamage(playerPed)
- ResetPedMovementClipset(playerPed, 0)
- end
- function setUniform(uniform, playerPed)
- TriggerEvent('skinchanger:getSkin', function(skin)
- local uniformObject
- if skin.sex == 0 then
- uniformObject = Config.Uniforms[uniform].male
- else
- uniformObject = Config.Uniforms[uniform].female
- end
- if uniformObject then
- TriggerEvent('skinchanger:loadClothes', skin, uniformObject)
- if uniform == 'bullet_wear' then
- SetPedArmour(playerPed, 100)
- end
- else
- ESX.ShowNotification(_U('no_outfit'))
- end
- end)
- end
- function OpenCloakroomMenu()
- local playerPed = PlayerPedId()
- local grade = ESX.PlayerData.job2.grade_name
- local elements = {
- {label = _U('citizen_wear'), value = 'citizen_wear'},
- {label = _U('rhodes_wear'), uniform = grade},
- {label = _U('work_wear'), uniform = 'work_wear'},
- {label = _U('workv2_wear'), uniform = 'workv2_wear'}
- }
- if Config.EnableCustomPeds then
- for k,v in ipairs(Config.CustomPeds.shared) do
- table.insert(elements, {label = v.label, value = 'freemode_ped', maleModel = v.maleModel, femaleModel = v.femaleModel})
- end
- for k,v in ipairs(Config.CustomPeds[grade]) do
- table.insert(elements, {label = v.label, value = 'freemode_ped', maleModel = v.maleModel, femaleModel = v.femaleModel})
- end
- 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)
- TriggerEvent('esx:restoreLoadout')
- end)
- end)
- end)
- else
- ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin)
- TriggerEvent('skinchanger:loadSkin', skin)
- end)
- end
- end
- if data.current.uniform then
- setUniform(data.current.uniform, playerPed)
- elseif 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)
- SetPedDefaultComponentVariation(PlayerPedId())
- TriggerEvent('esx:restoreLoadout')
- end)
- end)
- end
- end, function(data, menu)
- menu.close()
- CurrentAction = 'menu_cloakroom'
- CurrentActionMsg = _U('open_cloackroom')
- CurrentActionData = {}
- end)
- end
- function OpenArmoryMenu(station)
- local elements = {
- {label = _U('buy_weapons'), value = 'buy_weapons'}
- }
- if Config.EnableArmoryManagement then
- table.insert(elements, {label = _U('get_weapon'), value = 'get_weapon'})
- end
- ESX.UI.Menu.CloseAll()
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'armory', {
- title = _U('armory'),
- align = 'top-left',
- elements = elements
- }, function(data, menu)
- if data.current.value == 'buy_weapons' then
- OpenBuyWeaponsMenu()
- end
- end, function(data, menu)
- menu.close()
- CurrentAction = 'menu_armory'
- CurrentActionMsg = _U('open_armory')
- CurrentActionData = {station = station}
- end)
- end
- function OpenrhodesActionsMenu()
- ESX.UI.Menu.CloseAll()
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'rhodes_actions', {
- title = 'rhodes',
- align = 'top-left',
- elements = {
- {label = _U('citizen_interaction'), value = 'citizen_interaction'},
- {label = _U('vehicle_interaction'), value = 'vehicle_interaction'},
- }}, function(data, menu)
- if data.current.value == 'citizen_interaction' then
- local elements = {
- {label = _U('id_card'), value = 'identity_card'},
- {label = _U('search'), value = 'search'},
- {label = _U('handcuff'), value = 'handcuff'},
- {label = _U('drag'), value = 'drag'},
- {label = _U('put_in_vehicle'), value = 'put_in_vehicle'},
- {label = _U('out_the_vehicle'), value = 'out_the_vehicle'},
- }
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'citizen_interaction', {
- title = _U('citizen_interaction'),
- align = 'top-left',
- elements = elements
- }, function(data2, menu2)
- local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
- if closestPlayer ~= -1 and closestDistance <= 3.0 then
- local action = data2.current.value
- if action == 'identity_card' then
- OpenIdentityCardMenu(closestPlayer)
- elseif action == 'search' then
- OpenBodySearchMenu(closestPlayer)
- elseif action == 'handcuff' then
- TriggerServerEvent('r_rhodes:handcuff', GetPlayerServerId(closestPlayer))
- elseif action == 'drag' then
- TriggerServerEvent('r_rhodes:drag', GetPlayerServerId(closestPlayer))
- elseif action == 'put_in_vehicle' then
- TriggerServerEvent('r_rhodes:putInVehicle', GetPlayerServerId(closestPlayer))
- elseif action == 'out_the_vehicle' then
- TriggerServerEvent('r_rhodes:OutVehicle', GetPlayerServerId(closestPlayer))
- end
- else
- ESX.ShowNotification(_U('no_players_nearby'))
- end
- end, function(data2, menu2)
- menu2.close()
- end)
- elseif data.current.value == 'vehicle_interaction' then
- local elements = {}
- local playerPed = PlayerPedId()
- local vehicle = ESX.Game.GetVehicleInDirection()
- if DoesEntityExist(vehicle) then
- table.insert(elements, {label = _U('vehicle_info'), value = 'vehicle_infos'})
- table.insert(elements, {label = _U('pick_lock'), value = 'hijack_vehicle'})
- table.insert(elements, {label = _U('impound'), value = 'impound'})
- end
- table.insert(elements, {label = _U('search_database'), value = 'search_database'})
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_interaction', {
- title = _U('vehicle_interaction'),
- align = 'top-left',
- elements = elements
- }, function(data2, menu2)
- local coords = GetEntityCoords(playerPed)
- vehicle = ESX.Game.GetVehicleInDirection()
- action = data2.current.value
- if action == 'search_database' then
- LookupVehicle()
- elseif DoesEntityExist(vehicle) then
- if action == 'vehicle_infos' then
- local vehicleData = ESX.Game.GetVehicleProperties(vehicle)
- OpenVehicleInfosMenu(vehicleData)
- elseif action == 'hijack_vehicle' then
- if IsAnyVehicleNearPoint(coords.x, coords.y, coords.z, 3.0) then
- TaskStartScenarioInPlace(playerPed, 'WORLD_HUMAN_WELDING', 0, true)
- Citizen.Wait(20000)
- ClearPedTasksImmediately(playerPed)
- SetVehicleDoorsLocked(vehicle, 1)
- SetVehicleDoorsLockedForAllPlayers(vehicle, false)
- ESX.ShowNotification(_U('vehicle_unlocked'))
- end
- elseif action == 'impound' then
- if currentTask.busy then
- return
- end
- ESX.ShowHelpNotification(_U('impound_prompt'))
- TaskStartScenarioInPlace(playerPed, 'CODE_HUMAN_MEDIC_TEND_TO_DEAD', 0, true)
- currentTask.busy = true
- currentTask.task = ESX.SetTimeout(10000, function()
- ClearPedTasks(playerPed)
- ImpoundVehicle(vehicle)
- Citizen.Wait(100)
- end)
- Citizen.CreateThread(function()
- while currentTask.busy do
- Citizen.Wait(1000)
- vehicle = GetClosestVehicle(coords.x, coords.y, coords.z, 3.0, 0, 71)
- if not DoesEntityExist(vehicle) and currentTask.busy then
- ESX.ShowNotification(_U('impound_canceled_moved'))
- ESX.ClearTimeout(currentTask.task)
- ClearPedTasks(playerPed)
- currentTask.busy = false
- break
- end
- end
- end)
- end
- else
- ESX.ShowNotification(_U('no_vehicles_nearby'))
- end
- end, function(data2, menu2)
- menu2.close()
- end)
- end
- end, function(data, menu)
- menu.close()
- end)
- end
- function OpenIdentityCardMenu(player)
- ESX.TriggerServerCallback('r_rhodes:getOtherPlayerData', function(data)
- local elements = {
- {label = _U('name', data.name)},
- {label = _U('job2', ('%s - %s'):format(data.job2, data.grade))}
- }
- if Config.EnableESXIdentity then
- table.insert(elements, {label = _U('sex', _U(data.sex))})
- table.insert(elements, {label = _U('dob', data.dob)})
- table.insert(elements, {label = _U('height', data.height)})
- end
- if data.drunk then
- table.insert(elements, {label = _U('bac', data.drunk)})
- end
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'citizen_interaction', {
- title = _U('citizen_interaction'),
- align = 'top-left',
- elements = elements
- }, nil, function(data, menu)
- menu.close()
- end)
- end, GetPlayerServerId(player))
- end
- function OpenBodySearchMenu(player)
- ESX.TriggerServerCallback('r_rhodes:getOtherPlayerData', function(data)
- local elements = {}
- for i=1, #data.accounts, 1 do
- if data.accounts[i].name == 'black_money' and data.accounts[i].money > 0 then
- table.insert(elements, {
- label = _U('confiscate_dirty', ESX.Math.Round(data.accounts[i].money)),
- value = 'black_money',
- itemType = 'item_account',
- amount = data.accounts[i].money
- })
- break
- end
- end
- table.insert(elements, {label = _U('guns_label')})
- for i=1, #data.weapons, 1 do
- table.insert(elements, {
- label = _U('confiscate_weapon', ESX.GetWeaponLabel(data.weapons[i].name), data.weapons[i].ammo),
- value = data.weapons[i].name,
- itemType = 'item_weapon',
- amount = data.weapons[i].ammo
- })
- end
- table.insert(elements, {label = _U('inventory_label')})
- for i=1, #data.inventory, 1 do
- if data.inventory[i].count > 0 then
- table.insert(elements, {
- label = _U('confiscate_inv', data.inventory[i].count, data.inventory[i].label),
- value = data.inventory[i].name,
- itemType = 'item_standard',
- amount = data.inventory[i].count
- })
- end
- end
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'body_search', {
- title = _U('search'),
- align = 'top-left',
- elements = elements
- }, function(data, menu)
- if data.current.value then
- TriggerServerEvent('r_rhodes:confiscatePlayerItem', GetPlayerServerId(player), data.current.itemType, data.current.value, data.current.amount)
- OpenBodySearchMenu(player)
- end
- end, function(data, menu)
- menu.close()
- end)
- end, GetPlayerServerId(player))
- end
- function LookupVehicle()
- ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'lookup_vehicle', {
- title = _U('search_database_title'),
- }, function(data, menu)
- local length = string.len(data.value)
- if not data.value or length < 2 or length > 8 then
- ESX.ShowNotification(_U('search_database_error_invalid'))
- else
- ESX.TriggerServerCallback('r_rhodes:getVehicleInfos', function(retrivedInfo)
- local elements = {{label = _U('plate', retrivedInfo.plate)}}
- menu.close()
- if not retrivedInfo.owner then
- table.insert(elements, {label = _U('owner_unknown')})
- else
- table.insert(elements, {label = _U('owner', retrivedInfo.owner)})
- end
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_infos', {
- title = _U('vehicle_info'),
- align = 'top-left',
- elements = elements
- }, nil, function(data2, menu2)
- menu2.close()
- end)
- end, data.value)
- end
- end, function(data, menu)
- menu.close()
- end)
- end
- function OpenVehicleInfosMenu(vehicleData)
- ESX.TriggerServerCallback('r_rhodes:getVehicleInfos', function(retrivedInfo)
- local elements = {{label = _U('plate', retrivedInfo.plate)}}
- if not retrivedInfo.owner then
- table.insert(elements, {label = _U('owner_unknown')})
- else
- table.insert(elements, {label = _U('owner', retrivedInfo.owner)})
- end
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_infos', {
- title = _U('vehicle_info'),
- align = 'top-left',
- elements = elements
- }, nil, function(data, menu)
- menu.close()
- end)
- end, vehicleData.plate)
- end
- function OpenBuyWeaponsMenu()
- local elements = {}
- local playerPed = PlayerPedId()
- for k,v in ipairs(Config.AuthorizedWeapons[ESX.PlayerData.job2.grade_name]) do
- local weaponNum, weapon = ESX.GetWeapon(v.weapon)
- local components, label = {}
- local hasWeapon = HasPedGotWeapon(playerPed, GetHashKey(v.weapon), false)
- if v.components then
- for i=1, #v.components do
- if v.components[i] then
- local component = weapon.components[i]
- local hasComponent = HasPedGotWeaponComponent(playerPed, GetHashKey(v.weapon), component.hash)
- if hasComponent then
- label = ('%s: <span style="color:green;">%s</span>'):format(component.label, _U('armory_owned'))
- else
- if v.components[i] > 0 then
- label = ('%s: <span style="color:green;">%s</span>'):format(component.label, _U('armory_item', ESX.Math.GroupDigits(v.components[i])))
- else
- label = ('%s: <span style="color:green;">%s</span>'):format(component.label, _U('armory_free'))
- end
- end
- table.insert(components, {
- label = label,
- componentLabel = component.label,
- hash = component.hash,
- name = component.name,
- price = v.components[i],
- hasComponent = hasComponent,
- componentNum = i
- })
- end
- end
- end
- if hasWeapon and v.components then
- label = ('%s: <span style="color:green;">></span>'):format(weapon.label)
- elseif hasWeapon and not v.components then
- label = ('%s: <span style="color:green;">%s</span>'):format(weapon.label, _U('armory_owned'))
- else
- if v.price > 0 then
- label = ('%s: <span style="color:green;">%s</span>'):format(weapon.label, _U('armory_item', ESX.Math.GroupDigits(v.price)))
- else
- label = ('%s: <span style="color:green;">%s</span>'):format(weapon.label, _U('armory_free'))
- end
- end
- table.insert(elements, {
- label = label,
- weaponLabel = weapon.label,
- name = weapon.name,
- components = components,
- price = v.price,
- hasWeapon = hasWeapon
- })
- end
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'armory_buy_weapons', {
- title = _U('armory_weapontitle'),
- align = 'top-left',
- elements = elements
- }, function(data, menu)
- if data.current.hasWeapon then
- if #data.current.components > 0 then
- OpenWeaponComponentShop(data.current.components, data.current.name, menu)
- end
- else
- ESX.TriggerServerCallback('r_rhodes:buyWeapon', function(bought)
- if bought then
- if data.current.price > 0 then
- ESX.ShowNotification(_U('armory_bought', data.current.weaponLabel, ESX.Math.GroupDigits(data.current.price)))
- end
- menu.close()
- OpenBuyWeaponsMenu()
- else
- ESX.ShowNotification(_U('armory_money'))
- end
- end, data.current.name, 1)
- end
- end, function(data, menu)
- menu.close()
- end)
- end
- AddEventHandler('r_rhodes:hasEnteredMarker', function(station, part, partNum)
- if part == 'Cloakroom' then
- CurrentAction = 'menu_cloakroom'
- CurrentActionMsg = _U('open_cloackroom')
- CurrentActionData = {}
- elseif part == 'Armory' then
- CurrentAction = 'menu_armory'
- CurrentActionMsg = _U('open_armory')
- CurrentActionData = {station = station}
- end
- end)
- AddEventHandler('r_rhodes:hasExitedMarker', function(station, part, partNum)
- if not isInShopMenu then
- ESX.UI.Menu.CloseAll()
- end
- CurrentAction = nil
- end)
- RegisterNetEvent('r_rhodes:handcuff')
- AddEventHandler('r_rhodes:handcuff', function()
- isHandcuffed = not isHandcuffed
- local playerPed = PlayerPedId()
- if isHandcuffed then
- RequestAnimDict('mp_arresting')
- while not HasAnimDictLoaded('mp_arresting') do
- Citizen.Wait(100)
- end
- TaskPlayAnim(playerPed, 'mp_arresting', 'idle', 8.0, -8, -1, 49, 0, 0, 0, 0)
- SetEnableHandcuffs(playerPed, true)
- DisablePlayerFiring(playerPed, true)
- SetCurrentPedWeapon(playerPed, GetHashKey('WEAPON_UNARMED'), true)
- SetPedCanPlayGestureAnims(playerPed, false)
- FreezeEntityPosition(playerPed, false)
- DisplayRadar(false)
- if Config.EnableHandcuffTimer then
- if handcuffTimer.active then
- ESX.ClearTimeout(handcuffTimer.task)
- end
- StartHandcuffTimer()
- end
- else
- if Config.EnableHandcuffTimer and handcuffTimer.active then
- ESX.ClearTimeout(handcuffTimer.task)
- end
- ClearPedSecondaryTask(playerPed)
- SetEnableHandcuffs(playerPed, false)
- DisablePlayerFiring(playerPed, false)
- SetPedCanPlayGestureAnims(playerPed, true)
- FreezeEntityPosition(playerPed, false)
- DisplayRadar(true)
- end
- end)
- RegisterNetEvent('r_rhodes:unrestrain')
- AddEventHandler('r_rhodes:unrestrain', function()
- if isHandcuffed then
- local playerPed = PlayerPedId()
- isHandcuffed = false
- ClearPedSecondaryTask(playerPed)
- SetEnableHandcuffs(playerPed, false)
- DisablePlayerFiring(playerPed, false)
- SetPedCanPlayGestureAnims(playerPed, true)
- FreezeEntityPosition(playerPed, false)
- DisplayRadar(true)
- if Config.EnableHandcuffTimer and handcuffTimer.active then
- ESX.ClearTimeout(handcuffTimer.task)
- end
- end
- end)
- RegisterNetEvent('r_rhodes:drag')
- AddEventHandler('r_rhodes:drag', function(copId)
- if isHandcuffed then
- dragStatus.isDragged = not dragStatus.isDragged
- dragStatus.CopId = copId
- end
- end)
- Citizen.CreateThread(function()
- local wasDragged
- while true do
- Citizen.Wait(0)
- local playerPed = PlayerPedId()
- if isHandcuffed and dragStatus.isDragged then
- local targetPed = GetPlayerPed(GetPlayerFromServerId(dragStatus.CopId))
- if DoesEntityExist(targetPed) and IsPedOnFoot(targetPed) and not IsPedDeadOrDying(targetPed, true) then
- if not wasDragged then
- AttachEntityToEntity(playerPed, targetPed, 11816, 0.54, 0.54, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true)
- wasDragged = true
- else
- Citizen.Wait(1000)
- end
- else
- wasDragged = false
- dragStatus.isDragged = false
- DetachEntity(playerPed, true, false)
- end
- elseif wasDragged then
- wasDragged = false
- DetachEntity(playerPed, true, false)
- else
- Citizen.Wait(500)
- end
- end
- end)
- RegisterNetEvent('r_rhodes:putInVehicle')
- AddEventHandler('r_rhodes:putInVehicle', function()
- if isHandcuffed then
- local playerPed = PlayerPedId()
- local coords = GetEntityCoords(playerPed)
- if IsAnyVehicleNearPoint(coords, 5.0) then
- local vehicle = GetClosestVehicle(coords, 5.0, 0, 71)
- if DoesEntityExist(vehicle) then
- local maxSeats, freeSeat = GetVehicleMaxNumberOfPassengers(vehicle)
- for i=maxSeats - 1, 0, -1 do
- if IsVehicleSeatFree(vehicle, i) then
- freeSeat = i
- break
- end
- end
- if freeSeat then
- TaskWarpPedIntoVehicle(playerPed, vehicle, freeSeat)
- dragStatus.isDragged = false
- end
- end
- end
- end
- end)
- RegisterNetEvent('r_rhodes:OutVehicle')
- AddEventHandler('r_rhodes:OutVehicle', function()
- local playerPed = PlayerPedId()
- if IsPedSittingInAnyVehicle(playerPed) then
- local vehicle = GetVehiclePedIsIn(playerPed, false)
- TaskLeaveVehicle(playerPed, vehicle, 16)
- end
- end)
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- local playerPed = PlayerPedId()
- if isHandcuffed then
- DisableControlAction(0, 1, true)
- DisableControlAction(0, 2, true)
- DisableControlAction(0, 24, true)
- DisableControlAction(0, 257, true)
- DisableControlAction(0, 25, true)
- DisableControlAction(0, 263, true)
- DisableControlAction(0, 45, true)
- DisableControlAction(0, 22, true)
- DisableControlAction(0, 44, true)
- DisableControlAction(0, 37, true)
- DisableControlAction(0, 23, true)
- DisableControlAction(0, 288, true)
- DisableControlAction(0, 289, true)
- DisableControlAction(0, 170, true)
- DisableControlAction(0, 167, true)
- DisableControlAction(0, 0, true)
- DisableControlAction(0, 26, true)
- DisableControlAction(0, 73, true)
- DisableControlAction(2, 199, true)
- DisableControlAction(0, 59, true)
- DisableControlAction(0, 71, true)
- DisableControlAction(0, 72, true)
- DisableControlAction(2, 36, true)
- DisableControlAction(0, 47, true)
- DisableControlAction(0, 264, true)
- DisableControlAction(0, 257, true)
- DisableControlAction(0, 140, true)
- DisableControlAction(0, 141, true)
- DisableControlAction(0, 142, true)
- DisableControlAction(0, 143, true)
- DisableControlAction(0, 75, true)
- DisableControlAction(27, 75, true)
- if IsEntityPlayingAnim(playerPed, 'mp_arresting', 'idle', 3) ~= 1 then
- ESX.Streaming.RequestAnimDict('mp_arresting', function()
- TaskPlayAnim(playerPed, 'mp_arresting', 'idle', 8.0, -8, -1, 49, 0.0, false, false, false)
- end)
- end
- else
- Citizen.Wait(500)
- end
- end
- end)
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- if ESX.PlayerData.job2 and ESX.PlayerData.job2.name == 'rhodes' then
- local playerPed = PlayerPedId()
- local playerCoords = GetEntityCoords(playerPed)
- local isInMarker, hasExited, letSleep = false, false, true
- local currentStation, currentPart, currentPartNum
- for k,v in pairs(Config.rhodesStations) do
- for i=1, #v.Cloakrooms, 1 do
- local distance = #(playerCoords - v.Cloakrooms[i])
- if distance < Config.DrawDistance then
- DrawMarker(20, v.Cloakrooms[i], 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0.5, 0.5, 0.5, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, true, false, false, false)
- letSleep = false
- if distance < Config.MarkerSize.x then
- isInMarker, currentStation, currentPart, currentPartNum = true, k, 'Cloakroom', i
- end
- end
- end
- for i=1, #v.Armories, 1 do
- local distance = #(playerCoords - v.Armories[i])
- if distance < Config.DrawDistance then
- DrawMarker(20, v.Armories[i], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, true, false, false, false)
- letSleep = false
- if distance < Config.MarkerSize.x then
- isInMarker, currentStation, currentPart, currentPartNum = true, k, 'Armory', i
- end
- end
- end
- end
- if isInMarker and not HasAlreadyEnteredMarker or (isInMarker and (LastStation ~= currentStation or LastPart ~= currentPart or LastPartNum ~= currentPartNum)) then
- if
- (LastStation and LastPart and LastPartNum) and
- (LastStation ~= currentStation or LastPart ~= currentPart or LastPartNum ~= currentPartNum)
- then
- TriggerEvent('r_rhodes:hasExitedMarker', LastStation, LastPart, LastPartNum)
- hasExited = true
- end
- HasAlreadyEnteredMarker = true
- LastStation = currentStation
- LastPart = currentPart
- LastPartNum = currentPartNum
- TriggerEvent('r_rhodes:hasEnteredMarker', currentStation, currentPart, currentPartNum)
- end
- if not hasExited and not isInMarker and HasAlreadyEnteredMarker then
- HasAlreadyEnteredMarker = false
- TriggerEvent('r_rhodes:hasExitedMarker', LastStation, LastPart, LastPartNum)
- end
- if letSleep then
- Citizen.Wait(500)
- end
- else
- Citizen.Wait(500)
- end
- end
- end)
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- if CurrentAction then
- ESX.ShowHelpNotification(CurrentActionMsg)
- if IsControlJustReleased(0, 38) and ESX.PlayerData.job2 and ESX.PlayerData.job2.name == 'rhodes' then
- if CurrentAction == 'menu_cloakroom' then
- OpenCloakroomMenu()
- elseif CurrentAction == 'menu_armory' then
- OpenArmoryMenu(CurrentActionData.station)
- elseif CurrentAction == 'remove_entity' then
- DeleteEntity(CurrentActionData.entity)
- end
- CurrentAction = nil
- end
- end
- if IsControlJustReleased(0, 167) and not isDead and ESX.PlayerData.job2 and ESX.PlayerData.job2.name == 'rhodes' and not ESX.UI.Menu.IsOpen('default', GetCurrentResourceName(), 'rhodes_actions') then
- OpenrhodesActionsMenu()
- end
- if IsControlJustReleased(0, 38) and currentTask.busy then
- ESX.ShowNotification(_U('impound_canceled'))
- ESX.ClearTimeout(currentTask.task)
- ClearPedTasks(PlayerPedId())
- currentTask.busy = false
- end
- end
- end)
- AddEventHandler('playerSpawned', function(spawn)
- isDead = false
- TriggerEvent('r_rhodes:unrestrain')
- if not hasAlreadyJoined then
- TriggerServerEvent('r_rhodes:spawned')
- end
- hasAlreadyJoined = true
- end)
- AddEventHandler('esx:onPlayerDeath', function(data)
- isDead = true
- end)
- AddEventHandler('onResourceStop', function(resource)
- if resource == GetCurrentResourceName() then
- TriggerEvent('r_rhodes:unrestrain')
- if Config.EnableHandcuffTimer and handcuffTimer.active then
- ESX.ClearTimeout(handcuffTimer.task)
- end
- end
- end)
- function StartHandcuffTimer()
- if Config.EnableHandcuffTimer and handcuffTimer.active then
- ESX.ClearTimeout(handcuffTimer.task)
- end
- handcuffTimer.active = true
- handcuffTimer.task = ESX.SetTimeout(Config.HandcuffTimer, function()
- ESX.ShowNotification(_U('unrestrained_timer'))
- TriggerEvent('r_rhodes:unrestrain')
- handcuffTimer.active = false
- end)
- end
- local PlayerData = {}
- Citizen.CreateThread(function ()
- while ESX == nil do
- TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
- Citizen.Wait(1)
- end
- while ESX.GetPlayerData() == nil do
- Citizen.Wait(10)
- end
- PlayerData = ESX.GetPlayerData()
- LoadMarkers()
- end)
- RegisterNetEvent('esx:playerLoaded')
- AddEventHandler('esx:playerLoaded', function(xPlayer)
- PlayerData = xPlayer
- end)
- function LoadMarkers()
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(5)
- local plyCoords = GetEntityCoords(PlayerPedId())
- for location, val in pairs(Config.Teleporters) do
- local Enter = val['Enter']
- local Exit = val['Exit']
- local Job2Needed = val['Job2']
- local dstCheckEnter, dstCheckExit = GetDistanceBetweenCoords(plyCoords, Enter['x'], Enter['y'], Enter['z'], true), GetDistanceBetweenCoords(plyCoords, Exit['x'], Exit['y'], Exit['z'], true)
- if dstCheckEnter <= 7.5 then
- if Job2Needed ~= 'none' then
- if PlayerData.job2.name == Job2Needed then
- if dstCheckEnter <= 1.2 then
- if IsControlJustPressed(0, 38) then
- Teleport(val, 'enter')
- end
- end
- end
- else
- if dstCheckEnter <= 1.2 then
- if IsControlJustPressed(0, 38) then
- Teleport(val, 'enter')
- end
- end
- end
- end
- if dstCheckExit <= 7.5 then
- if Job2Needed ~= 'none' then
- if PlayerData.job2.name == Job2Needed then
- if dstCheckExit <= 1.2 then
- if IsControlJustPressed(0, 38) then
- Teleport(val, 'exit')
- end
- end
- end
- else
- if dstCheckExit <= 1.2 then
- if IsControlJustPressed(0, 38) then
- Teleport(val, 'exit')
- end
- end
- end
- end
- end
- end
- end)
- end
- function Teleport(table, location)
- if location == 'enter' then
- DoScreenFadeOut(100)
- Citizen.Wait(750)
- ESX.Game.Teleport(PlayerPedId(), table['Exit'])
- DoScreenFadeIn(100)
- else
- DoScreenFadeOut(100)
- Citizen.Wait(750)
- ESX.Game.Teleport(PlayerPedId(), table['Enter'])
- DoScreenFadeIn(100)
- end
- end
- local blips = {
- {title="Rhodes Informatique", colour=3, id=606, x=263.7, y=-643.4, 108.468},
- }
- Citizen.CreateThread(function()
- for _, info in pairs(blips) do
- info.blip = AddBlipForCoord(info.x, info.y, info.z)
- SetBlipSprite(info.blip, info.id)
- SetBlipDisplay(info.blip, 4)
- SetBlipScale(info.blip, 0.8)
- SetBlipColour(info.blip, info.colour)
- SetBlipAsShortRange(info.blip, true)
- BeginTextCommandSetBlipName("STRING")
- AddTextComponentString(info.title)
- EndTextCommandSetBlipName(info.blip)
- end
- end)
- local CurrentActionData, this_Spawner = {}, {}
- local HasAlreadyEnteredMarker, IsInMainMenu = false, false
- local LastZone, CurrentAction, CurrentActionMsg
- Citizen.CreateThread(function()
- while ESX == nil do
- TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
- Citizen.Wait(0)
- end
- end)
- function OpenSpawnerMenu()
- IsInMainMenu = true
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_spawner', {
- title = _U('vehicle_spawner'),
- align = GetConvar('esx_MenuAlign', 'top-left'),
- elements = {
- {label = _U('default_veh'), value = 'default_veh'}
- }}, function(data, menu)
- local action = data.current.value
- if action == 'default_veh' then
- local elements2 = {}
- for i=1, #Config.Vehicles, 1 do
- table.insert(elements2, {
- label = Config.Vehicles[i].label,
- model = Config.Vehicles[i].model
- })
- end
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'default_veh', {
- title = _U('default_veh'),
- align = GetConvar('esx_MenuAlign', 'top-left'),
- elements = elements2
- }, function(data, menu)
- if ESX.Game.IsSpawnPointClear(this_Spawner.Loc, 5.0) then
- IsInMainMenu = false
- menu.close()
- SpawnVehicle(data.current.model)
- ESX.ShowNotification(_U('spawn_vehicle'))
- else
- ESX.ShowNotification(_U('spawnpoint_blocked'))
- end
- end)
- end
- end, function(data, menu)
- IsInMainMenu = false
- menu.close()
- CurrentAction = 'spawner_point'
- CurrentActionMsg = _U('press_to_enter')
- CurrentActionData = {}
- end)
- end
- function OpenReturnMenu()
- local playerCoords = GetEntityCoords(PlayerPedId())
- vehicles = ESX.Game.GetVehiclesInArea(playerCoords, 5.0)
- if #vehicles > 0 then
- for k,v in ipairs(vehicles) do
- ESX.Game.DeleteVehicle(v)
- end
- end
- end
- function SpawnVehicle(model)
- ESX.Game.SpawnVehicle(model, this_Spawner.Loc, this_Spawner.Heading)
- end
- AddEventHandler('esx_vehiclespawner:hasEnteredMarker', function(zone)
- if zone == 'spawner_point' then
- CurrentAction = 'spawner_point'
- CurrentActionMsg = _U('press_to_enter')
- CurrentActionData = {}
- elseif zone == 'deleter_point' then
- CurrentAction = 'deleter_point'
- CurrentActionMsg = _U('press_to_enter2')
- CurrentActionData = {}
- end
- end)
- AddEventHandler('esx_vehiclespawner:hasExitedMarker', function()
- if not IsInMainMenu or IsInMainMenu then
- ESX.UI.Menu.CloseAll()
- end
- CurrentAction = nil
- end)
- AddEventHandler('onResourceStop', function(resource)
- if resource == GetCurrentResourceName() then
- if IsInMainMenu then
- ESX.UI.Menu.CloseAll()
- end
- end
- end)
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- local plyCoords = GetEntityCoords(PlayerPedId())
- local playerCoords = GetEntityCoords(PlayerPedId())
- local isInMarker, letSleep, currentZone = false, true
- for k,v in pairs(Config.Zones) do
- local distance = #(playerCoords - v.Pos)
- local distance2 = #(playerCoords - v.Del)
- if distance < Config.DrawDistance then
- letSleep = false
- if ESX.PlayerData.job2.name == "rhodes" then
- if Config.MenuMarker.Type ~= -1 then
- DrawMarker(Config.MenuMarker.Type, v.Pos, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.MenuMarker.x, Config.MenuMarker.y, Config.MenuMarker.z, Config.MenuMarker.r, Config.MenuMarker.g, Config.MenuMarker.b, 100, false, true, 2, false, false, false, false)
- end
- if Config.DelMarker.Type ~= -1 then
- DrawMarker(Config.DelMarker.Type, v.Del, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.DelMarker.x, Config.DelMarker.y, Config.DelMarker.z, Config.DelMarker.r, Config.DelMarker.g, Config.DelMarker.b, 100, false, true, 2, false, false, false, false)
- end
- if distance < Config.MenuMarker.x then
- isInMarker, currentZone = true, 'spawner_point'
- this_Spawner = v
- end
- if distance2 < Config.DelMarker.x then
- isInMarker, currentZone = true, 'deleter_point'
- this_Spawner = v
- end
- end
- end
- if (isInMarker and not HasAlreadyEnteredMarker) or (isInMarker and LastZone ~= currentZone) then
- HasAlreadyEnteredMarker, LastZone = true, currentZone
- TriggerEvent('esx_vehiclespawner:hasEnteredMarker', currentZone)
- end
- if not isInMarker and HasAlreadyEnteredMarker then
- HasAlreadyEnteredMarker = false
- TriggerEvent('esx_vehiclespawner:hasExitedMarker', LastZone)
- end
- if letSleep then
- Citizen.Wait(500)
- end
- end
- end
- end)
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- if CurrentAction then
- ESX.ShowHelpNotification(CurrentActionMsg)
- if IsControlJustReleased(0, 38) then
- if CurrentAction == 'spawner_point' then
- OpenSpawnerMenu()
- elseif CurrentAction == 'deleter_point' then
- OpenReturnMenu()
- ESX.ShowNotification(_U('delete_vehicle'))
- end
- CurrentAction = nil
- end
- else
- Citizen.Wait(500)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement