Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Keys = {
- ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
- ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
- ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
- ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
- ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
- ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
- ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
- ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
- ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
- }
- ---esx
- local ESX = nil
- local PlayerData = {}
- ---custom scripts
- local cardOpen = false
- local snoing = 0
- local hasHandcuffs = false
- local hasNyckel = false
- local hasBlindfold = false
- local hasDyrkset = false
- local hasBulletproof = false
- -- Servern callback
- RegisterNetEvent('jsfour-legitimation:open')
- AddEventHandler('jsfour-legitimation:open', function(playerData)
- cardOpen = true
- SendNUIMessage({
- action = "open",
- array = playerData
- })
- end)
- -- Funktioner
- function GetPed() return GetPlayerPed(-1) end
- function GetCar() return GetVehiclePedIsIn(GetPlayerPed(-1),false) end
- local isSearching = false
- local isBlindfolded = false
- local hasEquipped = false
- local isDead = false
- local playerCars = {}
- -- ESX
- Citizen.CreateThread(function()
- while ESX == nil do
- TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
- Citizen.Wait(0)
- end
- end)
- RegisterNetEvent('esx:setJob')
- AddEventHandler('esx:setJob', function(job)
- PlayerData.job = job
- end)
- --för att öppna menyn i andra scripts TriggerEvent('esx_qalle:openMenu')
- RegisterNetEvent('esx_qalle:openMenu')
- AddEventHandler('esx_qalle:openMenu', function()
- openMenu()
- end)
- AddEventHandler('esx:onPlayerDeath', function(data)
- isDead = true
- end)
- AddEventHandler('playerSpawned', function(spawn)
- isDead = false
- end)
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- if IsControlPressed(0, Keys['F9']) and GetEntityHealth() <= 101 then
- ClearPedTasksImmediately(GetPlayerPed(-1))
- end
- end
- end)
- function ShowBillsMenu()
- ESX.TriggerServerCallback('esx_billing:getBills', function(bills)
- local elements = {}
- for i=1, #bills, 1 do
- table.insert(elements, {label = bills[i].label .. ' ' .. bills[i].amount .. ' SEK', value = bills[i].id})
- end
- ESX.UI.Menu.Open(
- 'default', GetCurrentResourceName(), 'billing',
- {
- title = ('Fakturor'),
- align = 'bottom-right',
- elements = elements
- },
- function(data, menu)
- menu.close()
- local billId = data.current.value
- ESX.TriggerServerCallback('esx_billing:payBill', function()
- ShowBillsMenu()
- end, billId)
- end,
- function(data, menu)
- menu.close()
- end
- )
- end)
- end
- --- meny f5
- function openMenu()
- ESX.UI.Menu.CloseAll()
- ESX.UI.Menu.Open(
- 'default', GetCurrentResourceName(), 'f3_menu',
- {
- title = 'Personliga Meny',
- align = 'top-right',
- elements = {
- {label = 'Person-Handlingar', value = 'id-card'},
- {label = 'Individ-Åtgärder', value = 'citizen'},
- {label = 'Fordons-meny', value = 'vehiclemenu'},
- {label = 'Fakturor', value = 'my_bills'},
- {label = 'Animationer', value = 'animations'},
- {label = 'Accessoarer', value = 'mask'},
- {label = 'Företags-Meny', value = 'test'},
- }
- },
- function(data, menu)
- if data.current.value == 'animations' then
- TriggerEvent("esx_animations")
- elseif data.current.value == 'pee' then
- TriggerEvent('pee')
- elseif data.current.value == 'my_bills' then
- ShowBillsMenu()
- elseif data.current.value == 'vehiclemenu' then
- openVehicleMenu()
- elseif data.current.value == 'poop' then
- TriggerEvent('poop')
- elseif data.current.value == 'id-card' then
- ESX.UI.Menu.Open(
- 'default', GetCurrentResourceName(), 'id_card_menu',
- {
- title = 'Identitet',
- align = 'top-right',
- elements = {
- --{label = 'Arbete: ' .. PlayerData.job.label .. ' - ' .. PlayerData.job.grade_label, value = 'work'},
- --{label = 'Mina nycklar', value = 'keys'},
- {label = 'Kolla på ditt ID', value = 'checkID'},
- {label = 'Visa ditt ID', value = 'showID'},
- {label = 'Kolla på ditt Körkort', value = 'checkDriver'},
- {label = 'Visa ditt Körkort', value = 'showDriver'},
- --{label = 'Mina körkort', value = 'korkort'},
- --{label = 'Mina nycklar', value = 'keys'}
- -- {label = 'Telefon AV/PÅ', value = 'phone'}
- }
- },
- function(data2, menu2)
- if data2.current.value == 'checkID' then
- TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()))
- elseif data2.current.value == 'showID' then
- local player, distance = ESX.Game.GetClosestPlayer()
- if distance ~= -1 and distance <= 3.0 then
- TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player))
- ESX.ShowNotification('du visar ditt id')
- else
- ESX.ShowNotification('Ingen i närheten')
- end
- end
- if data2.current.value == 'checkDriver' then
- TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(PlayerId()), 'driver')
- elseif data2.current.value == 'showDriver' then
- local player, distance = ESX.Game.GetClosestPlayer()
- if distance ~= -1 and distance <= 3.0 then
- TriggerServerEvent('jsfour-idcard:open', GetPlayerServerId(PlayerId()), GetPlayerServerId(player), 'driver')
- ESX.ShowNotification('du visar ditt körkort')
- else
- ESX.ShowNotification('Ingen i närheten')
- end
- end
- end,
- function(data2, menu2)
- menu2.close()
- end
- )
- elseif data.current.value == 'mask' then
- ESX.UI.Menu.Open(
- 'default', GetCurrentResourceName(), 'asccesories_menu',
- {
- title = 'Accessoarer',
- align = 'top-right',
- elements = {
- {label = 'Huvudbonad PÅ/AV', value = 'Helmet'},
- {label = 'Glasögon PÅ/AV', value = 'Glasses'},
- {label = 'Mask PÅ/AV', value = 'Mask'}
- }
- },
- function(data2, menu2)
- if data2.current.value == 'Helmet' then
- menu2.close()
- SetUnsetAccessory(data2.current.value)
- end
- if data2.current.value == 'Ears' then
- menu2.close()
- SetUnsetAccessory(data2.current.value)
- end
- if data2.current.value == 'Glasses' then
- menu2.close()
- SetUnsetAccessory(data2.current.value)
- end
- if data2.current.value == 'Watches' then
- menu2.close()
- SetUnsetAccessory(data2.current.value)
- end
- if data2.current.value == 'bulletproof' then
- if hasBulletproof and not hasEquipped then
- menu2.close()
- TriggerEvent('esx_qalle:bulletproof')
- hasEquipped = true
- elseif hasEquipped then
- TriggerEvent('esx_qalle:bulletproofoff')
- hasEquipped = false
- else
- sendNotification('Du har ingen Skottsäkervest', 'error', 2500)
- end
- end
- if data2.current.value == 'Mask' then
- menu2.close()
- SetUnsetAccessory(data2.current.value)
- end
- end,
- function(data2, menu2)
- menu2.close()
- end
- )
- elseif data.current.value == 'citizen' then
- ESX.UI.Menu.Open(
- 'default', GetCurrentResourceName(), 'citizen_menu',
- {
- title = 'Individåtgärder',
- align = 'top-right',
- elements = {
- {label = 'Genomsök närmsta person', value = 'search'},
- {label = ('Sätt PÅ/AV Buntband'), value = 'handcuff'},
- {label = ('Bär närmsta person'), value = 'drag'},
- }
- },
- function(data2, menu2)
- if data2.current.value == 'blind' then
- local player, distance = ESX.Game.GetClosestPlayer()
- if distance ~= -1 and distance <= 3.0 then
- ESX.TriggerServerCallback('blindfold:itemCheck', function( hasItem )
- TriggerServerEvent('blindfold', GetPlayerServerId(player), hasItem)
- end)
- else
- sendNotification('Ingen person nära', 'error', 2500)
- end
- elseif data2.current.value == 'search' then
- local player, distance = ESX.Game.GetClosestPlayer()
- local target, distance = ESX.Game.GetClosestPlayer()
- if distance ~= -1 and distance <= 3.0 then
- --- kollar ifall spelaren håller upp händerna eller cuffad eller död.
- if IsEntityPlayingAnim(GetPlayerPed(player), "random@mugging3", "handsup_standing_base", 3) or IsEntityPlayingAnim(GetPlayerPed(player), "mp_arresting", "idle", 3) or IsPedDeadOrDying(GetPlayerPed(player)) then
- OpenBodySearchMenu(target)
- end
- --- kollar ifall spelaren inte håller upp händerna
- if not IsEntityPlayingAnim(GetPlayerPed(player), "random@mugging3", "handsup_standing_base", 3) then
- sendNotification('Personen håller inte upp händerna', 'error', 2500)
- end
- else
- sendNotification('Ingen person nära', 'error', 2500)
- end
- elseif data2.current.value == 'handcuff' then
- local player, distance = ESX.Game.GetClosestPlayer()
- if distance ~= -1 and distance <= 3.0 then
- if hasHandcuffs then
- TriggerServerEvent('esx_qalle:removeInventoryItem','buntband', 1)
- TriggerServerEvent('esx_policejob:handcuff', GetPlayerServerId(player))
- else
- sendNotification('Du har inga buntband', 'error', 2500)
- end
- else
- sendNotification('Ingen person nära', 'error', 2500)
- end
- elseif data2.current.value == 'drag' then
- local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
- if closestPlayer == -1 or closestDistance > 4.0 then
- ESX.ShowNotification(_U('no_players'))
- else
- RequestAnimDict('anim@heists@load_box')
- while not HasAnimDictLoaded('anim@heists@load_box') do
- Wait(1)
- end
- TaskPlayAnim(GetPlayerPed(-1), 'anim@heists@load_box', 'idle', 8.0, -8, -1, 49, 0, 0, 0, 0)
- Citizen.Wait(500)
- TriggerServerEvent('esx_ambulancejob:drag', GetPlayerServerId(closestPlayer))
- end
- elseif data2.current.value == 'death' then
- TriggerEvent('esx_damage:check')
- end
- if data2.current.value == 'Mask' then
- menu2.close()
- SetUnsetAccessory(data2.current.value)
- end
- end,
- function(data2, menu2)
- menu2.close()
- end
- )
- elseif data.current.value == 'vehicle' then
- ESX.UI.Menu.Open(
- 'default', GetCurrentResourceName(), 'vehicle_menu',
- {
- title = 'Fordonåtgärder',
- align = 'top-right',
- elements = {
- {label = 'Lås / Lås upp', value = 'lock'},
- {label = 'Stäng av motor', value = 'engine'},
- {label = 'Motorhuven', value = 'door_f'},
- {label = 'Bakluckan', value = 'door_f2'},
- {label = 'Bakdörrarna', value = 'door_f3'},
- {label = 'Framdörrarna', value = 'door_f4'},
- {label = 'Farthållare', value = 'hastighet'},
- }
- },
- function(data2, menu2)
- if data.current.value == 'lock' then
- OpenCloseVehicle()
- end
- if data2.current.value == 'engine' then
- TriggerEvent("engine")
- end
- if data2.current.value == 'door_f' then
- TriggerEvent("hood")
- end
- if data2.current.value == 'door_f2' then
- TriggerEvent("trunk")
- end
- if data2.current.value == 'door_f3' then
- TriggerEvent("rdoors")
- end
- if data2.current.value == 'door_f4' then
- TriggerEvent("fdoors")
- end
- if data2.current.value == 'hastighet' then
- ESX.UI.Menu.Open(
- 'default', GetCurrentResourceName(), 'citizen_menu',
- {
- title = 'Lås Hastighetsmeny',
- elements = {
- {label = '40', value = '40'},
- {label = '60', value = '60'},
- {label = '80', value = '80'},
- {label = ('100'), value = '100'},
- {label = ('120'), value = '120'},
- {label = ('Återställ din farthållare'), value = '0'}
- }
- },
- function(data2, menu2)
- if data2.current.value == '0' then
- local veh = GetVehiclePedIsIn(GetPlayerPed(-1), false)
- SetEntityMaxSpeed(veh, 10000/3.65)
- else
- local veh = GetVehiclePedIsIn(GetPlayerPed(-1), false)
- SetEntityMaxSpeed(veh, data2.current.value/3.65)
- end
- end,
- function(data2, menu2)
- menu2.close()
- end
- )
- end
- end,
- function(data2, menu2)
- menu2.close()
- end
- )
- elseif data.current.value == 'test' and PlayerData.job.grade_name == 'boss' then
- ESX.UI.Menu.Open(
- 'default', GetCurrentResourceName(), 'boss_menu',
- {
- title = 'Direktör meny',
- align = 'top-right',
- elements = {
- {label = 'Företagskassa', value = 'society_money'},
- {label = 'Anställ (Närmsta Spelare)', value = 'recruit_player'},
- {label = 'Sparka (Närmsta Spelare)', value = 'kick_player'},
- {label = 'Höj Position (Närmsta Spelare)', value = 'promote_player'},
- {label = 'Sänk Position (Närmsta Spelare)', value = 'demote_player'}
- }
- },
- function(data2, menu2)
- if data2.current.value == 'society_money' then
- money = nil
- ESX.TriggerServerCallback('esx_society:getSocietyMoney', function(money)
- sendNotification('Ditt företag ligger just nu på ' .. money .. ' SEK', 'success', 5500)
- end, PlayerData.job.name)
- end
- if data2.current.value == 'recruit_player' then
- if PlayerData.job.grade_name == 'boss' then
- local job = PlayerData.job.name
- local grade = 0
- local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
- if closestPlayer == -1 or closestDistance > 3.0 then
- sendNotification('Ingen person nära', 'error', 2500)
- else
- TriggerServerEvent('esx_qalle:recruit_player', GetPlayerServerId(closestPlayer), job,grade)
- end
- else
- sendNotification('Du har inte rättigheterna', 'error', 2500)
- end
- end
- if data2.current.value == 'kick_player' then
- if PlayerData.job.grade_name == 'boss' then
- local job = PlayerData.job.name
- local grade = 0
- local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
- if closestPlayer == -1 or closestDistance > 3.0 then
- sendNotification('Ingen person nära', 'error', 2500)
- else
- TriggerServerEvent('esx_qalle:kick_player', GetPlayerServerId(closestPlayer))
- end
- else
- sendNotification('Du har inte rättigheterna', 'error', 2500)
- end
- end
- if data2.current.value == 'promote_player' then
- if PlayerData.job.grade_name == 'boss' then
- local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
- if closestPlayer == -1 or closestDistance > 3.0 then
- sendNotification('Ingen person nära', 'error', 2500)
- else
- TriggerServerEvent('esx_qalle:promote_player', GetPlayerServerId(closestPlayer))
- end
- else
- sendNotification('Du har inte rättigheterna', 'error', 2500)
- end
- end
- if data2.current.value == 'demote_player' then
- if PlayerData.job.grade_name == 'boss' then
- local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
- if closestPlayer == -1 or closestDistance > 3.0 then
- sendNotification('Ingen person nära', 'error', 2500)
- else
- TriggerServerEvent('esx_qalle:demote_player', GetPlayerServerId(closestPlayer))
- end
- else
- sendNotification('Du har inte rättigheterna', 'error', 2500)
- end
- end
- end,
- function(data2, menu2)
- menu2.close()
- end
- )
- elseif data.current.value == 'material' then
- end
- end,
- function(data, menu)
- menu.close()
- end
- )
- end
- ---sökigenommeny
- function OpenBodySearchMenu(player)
- ESX.TriggerServerCallback('esx_qalle:getOtherPlayerData', function(data)
- local elements = {}
- table.insert(elements, {label = '--- Nycklar ---', value = nil})
- --[[if data.nycklar ~= nil then
- for i=1, #data.nycklar, 1 do
- table.insert(elements, {label = 'Nyckel #' ..data.nycklar[i].kU.. ' ' ..data.nycklar[i].kN, keyName = data.nycklar[i].kN, keyUnit = data.nycklar[i].kU, action = 'take_key'})
- end
- end]]
- for i=1, #data.data.inventory, 1 do
- if data.data.inventory[i].count > 0 and data.data.inventory[i].name == 'policecard' then
- table.insert(elements, {
- label = 'Polis Nyckel #' ..math.random(1,10),
- value = data.data.inventory[i].name,
- itemType = 'item_standard',
- amount = data.data.inventory[i].count,
- })
- end
- end
- local blackMoney = 0
- for i=1, #data.data.accounts, 1 do
- if data.data.accounts[i].name == 'black_money' then
- blackMoney = data.data.accounts[i].money
- end
- end
- table.insert(elements, {label = '--- Pengar ---', value = nil})
- table.insert(elements, {
- label = 'Konfiskera Kontanter: ' .. data.data.money .. ' SEK',
- value = 'money',
- itemType = 'item_money',
- amount = data.data.money,
- })
- table.insert(elements, {
- label = 'Konfiskera Svarta: ' .. blackMoney .. ' SEK',
- value = 'black_money',
- itemType = 'item_account',
- amount = blackMoney
- })
- table.insert(elements, {label = '--- Vapen ---', value = nil})
- for i=1, #data.data.weapons, 1 do
- table.insert(elements, {
- label = 'Konfiskera: ' .. ESX.GetWeaponLabel(data.data.weapons[i].name),
- value = data.data.weapons[i].name,
- itemType = 'item_weapon',
- amount = data.data.ammo,
- })
- end
- table.insert(elements, {label = '--- Föremål ---', value = nil})
- for i=1, #data.data.inventory, 1 do
- if data.data.inventory[i].count > 0 and data.data.inventory[i].name ~= 'policecard' then
- table.insert(elements, {
- label = 'Konfiskera: ' .. data.data.inventory[i].count .. 'st ' .. data.data.inventory[i].label,
- value = data.data.inventory[i].name,
- itemType = 'item_standard',
- amount = data.data.inventory[i].count,
- })
- end
- end
- ESX.UI.Menu.Open(
- 'default', GetCurrentResourceName(), 'body_search',
- {
- title = 'Söker individ',
- align = 'top-right',
- elements = elements,
- },
- function(data, menu)
- local itemType = data.current.itemType
- local itemName = data.current.value
- local amount = data.current.amount
- if data.current.value ~= nil then
- local player, distance = ESX.Game.GetClosestPlayer()
- if snoing == 0 then
- snoing = 1
- RequestAnimDict("amb@medic@standing@kneel@exit")
- RequestAnimDict("anim@gangops@facility@servers@bodysearch@")
- RequestAnimDict("amb@medic@standing@kneel@base")
- while not HasAnimDictLoaded("amb@medic@standing@kneel@exit") do
- Citizen.Wait(0)
- end
- while not HasAnimDictLoaded("anim@gangops@facility@servers@bodysearch@") do
- Citizen.Wait(0)
- end
- while not HasAnimDictLoaded("amb@medic@standing@kneel@base") do
- Citizen.Wait(0)
- end
- if IsEntityDead(GetPlayerPed(player)) then
- TaskPlayAnim(GetPlayerPed(-1), "amb@medic@standing@kneel@base" ,"base" ,8.0, -8.0, -1, 1, 0, false, false, false )
- end
- TaskPlayAnim(GetPlayerPed(-1), "anim@gangops@facility@servers@bodysearch@" ,"player_search" ,8.0, -8.0, -1, 48, 0, false, false, false )
- Citizen.Wait(6200)
- snoing = 0
- local target, distance = ESX.Game.GetClosestPlayer()
- if IsEntityPlayingAnim(GetPlayerPed(-1), "anim@gangops@facility@servers@bodysearch@" ,"player_search", 3) and distance ~= -1 and distance <= 3.0 then
- TriggerServerEvent('esx_qalle:confiscatePlayerItem', GetPlayerServerId(target), itemType, itemName, amount)
- OpenBodySearchMenu(player)
- Citizen.Wait(800)
- else
- menu.close()
- sendNotification('Personen är för långt bort', 'error', 2500)
- end
- if IsEntityPlayingAnim(GetPlayerPed(-1), "amb@medic@standing@kneel@base" ,"base", 3) then
- TaskPlayAnim(GetPlayerPed(-1), "amb@medic@standing@kneel@exit" ,"exit" ,8.0, -8.0, -1, 0, 0, false, false, false )
- end
- end
- else
- local player, distance = ESX.Game.GetClosestPlayer()
- if snoing == 0 then
- snoing = 1
- RequestAnimDict("amb@medic@standing@kneel@exit")
- RequestAnimDict("anim@gangops@facility@servers@bodysearch@")
- RequestAnimDict("amb@medic@standing@kneel@base")
- while not HasAnimDictLoaded("amb@medic@standing@kneel@exit") do
- Citizen.Wait(0)
- end
- while not HasAnimDictLoaded("anim@gangops@facility@servers@bodysearch@") do
- Citizen.Wait(0)
- end
- while not HasAnimDictLoaded("amb@medic@standing@kneel@base") do
- Citizen.Wait(0)
- end
- if IsEntityDead(GetPlayerPed(player)) then
- TaskPlayAnim(GetPlayerPed(-1), "amb@medic@standing@kneel@base" ,"base" ,8.0, -8.0, -1, 1, 0, false, false, false )
- end
- TaskPlayAnim(GetPlayerPed(-1), "anim@gangops@facility@servers@bodysearch@" ,"player_search" ,8.0, -8.0, -1, 48, 0, false, false, false )
- Citizen.Wait(6200)
- snoing = 0
- local target, distance = ESX.Game.GetClosestPlayer()
- if IsEntityPlayingAnim(GetPlayerPed(-1), "anim@gangops@facility@servers@bodysearch@" ,"player_search", 3) and distance ~= -1 and distance <= 3.0 then
- TriggerServerEvent('esx-qalle-storage:stealKey', GetPlayerServerId(target), data.current.keyUnit, data.current.keyName)
- Citizen.Wait(800)
- OpenBodySearchMenu(player)
- Citizen.Wait(800)
- else
- menu.close()
- sendNotification('Personen är för långt bort', 'error', 2500)
- end
- if IsEntityPlayingAnim(GetPlayerPed(-1), "amb@medic@standing@kneel@base" ,"base", 3) then
- TaskPlayAnim(GetPlayerPed(-1), "amb@medic@standing@kneel@exit" ,"exit" ,8.0, -8.0, -1, 0, 0, false, false, false )
- end
- end
- end
- end,
- function(data, menu)
- menu.close()
- end
- )
- end, GetPlayerServerId(player))
- end
- function openVehicleMenu()
- ESX.UI.Menu.Open(
- 'default', GetCurrentResourceName(), 'vehicle_menu',
- {
- title = 'Fordonåtgärder',
- align = 'top-right',
- elements = {
- {label = 'Lås / Lås upp', value = 'lock'},
- {label = 'Motor Av / På', value = 'engine'},
- {label = 'Huven', value = 'door_f'},
- {label = 'Bakluckan', value = 'door_f2'},
- {label = 'Bakdörrarna', value = 'door_f3'},
- {label = 'Framdörrarna', value = 'door_f4'},
- {label = 'Farthållare', value = 'hastighet'},
- }
- },
- function(data, menu)
- if data.current.value == 'lock' then
- OpenCloseVehicle()
- end
- if data.current.value == 'engine' then
- TriggerEvent("engine")
- end
- if data.current.value == 'door_f' then
- TriggerEvent("hood")
- end
- if data.current.value == 'door_f2' then
- TriggerEvent("trunk")
- end
- if data.current.value == 'door_f3' then
- TriggerEvent("rdoors")
- end
- if data.current.value == 'door_f4' then
- TriggerEvent("fdoors")
- end
- if data.current.value == 'hastighet' then
- ESX.UI.Menu.Open(
- 'default', GetCurrentResourceName(), 'hastighet',
- {
- title = 'Farthållare',
- align = 'top-right',
- elements = {
- {label = '40', value = '40'},
- {label = '60', value = '60'},
- {label = '80', value = '80'},
- {label = ('100'), value = '100'},
- {label = ('120'), value = '120'},
- {label = ('Återställ'), value = '0'}
- }
- },
- function(data2, menu2)
- if data2.current.value == '0' then
- local veh = GetVehiclePedIsIn(GetPlayerPed(-1), false)
- SetEntityMaxSpeed(veh, 10000/3.65)
- else
- local veh = GetVehiclePedIsIn(GetPlayerPed(-1), false)
- SetEntityMaxSpeed(veh, data2.current.value/3.65)
- end
- end,
- function(data2, menu2)
- menu2.close()
- end
- )
- end
- end,
- function(data, menu)
- menu.close()
- end
- )
- end
- --låsa / låsa upp
- function OpenCloseVehicle()
- local playerPed = GetPlayerPed(-1)
- local coords = GetEntityCoords(playerPed)
- local coords2 = GetOffsetFromEntityInWorldCoords(playerPed, 0.0, 5.0, 0.0)
- local vehicle = nil
- if IsPedInAnyVehicle(playerPed, false) then
- vehicle = GetVehiclePedIsIn(playerPed, false)
- else
- vehicle = GetClosestVehicle(coords.x, coords.y, coords.z, 7.0, 0, 71 )
- end
- --print(vehicle)
- if vehicle == 0 then
- local coordA = GetEntityCoords(GetPlayerPed(-1), 1)
- local coordB = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0.0, 20.0, 0.0)
- local targetVehicle = getVehicleInDirection(coordA, coordB)
- if targetVehicle ~= nil then
- vehicle = targetVehicle
- end
- end
- ESX.TriggerServerCallback('esx_qalle:requestPlayerCars', function(isOwnedVehicle)
- local vehicleProps = ESX.Game.GetVehicleProperties(vehicle)
- print (vehicleProps.plate)
- if isOwnedVehicle or (PlayerData.job.name == 'police' and vehicleProps.plate == 'POLIS' or PlayerData.job.name == 'mecano' and vehicleProps.plate == 'MEKA' or PlayerData.job.name == 'ambulance' and vehicleProps.plate == 'AMBU' or PlayerData.job.name == 'taxi' and vehicleProps.plate == 'TAXI') then
- local locked = GetVehicleDoorLockStatus(vehicle)
- local heading = GetEntityHeading(playerPed)
- if locked == 1 then -- if unlocked
- SetVehicleDoorsLocked(vehicle, 2)
- PlayVehicleDoorCloseSound(vehicle, 1)
- ESX.ShowNotification("Du har LÅST ditt fordon.")
- elseif locked == 2 then -- if locked
- SetVehicleDoorsLocked(vehicle, 1)
- PlayVehicleDoorOpenSound(vehicle, 0)
- if not IsPedInAnyVehicle(playerPed, false) then
- SetPedIntoVehicle(playerPed, vehicle, -1)
- TaskLeaveVehicle(playerPed, vehicle, 16)
- SetEntityCoords(playerPed, coords.x, coords.y, coords.z-0.99, 1, 0, 0, 1)
- SetEntityHeading(playerPed, heading)
- end
- ESX.ShowNotification("Du har LÅST UPP ditt fordon.")
- end
- else
- ESX.ShowNotification("Du har inga bilnycklar till denna bil.")
- end
- end, GetVehicleNumberPlateText(vehicle))
- end
- ---alla grejer
- RegisterNetEvent('esx:playerLoaded')
- AddEventHandler('esx:playerLoaded', function(xPlayer)
- PlayerData = xPlayer
- TriggerEvent('esx_qalle:hasNotBulletproof')
- TriggerEvent('esx_qalle:hasNotHandcuffs')
- TriggerEvent('esx_qalle:hasNotNyckel')
- TriggerEvent('esx_qalle:hasNotBlindfold')
- TriggerEvent('esx_qalle:hasNotDyrkset')
- TriggerEvent('esx_qalle:hasNotECM')
- for i=1, #PlayerData.inventory, 1 do
- if PlayerData.inventory[i].name == 'buntband' then
- if PlayerData.inventory[i].count > 0 then
- TriggerEvent('esx_qalle:hasHandcuffs')
- end
- end
- end
- for i=1, #PlayerData.inventory, 1 do
- if PlayerData.inventory[i].name == 'nyckel' then
- if PlayerData.inventory[i].count > 0 then
- TriggerEvent('esx_qalle:hasNyckel')
- end
- end
- end
- for i=1, #PlayerData.inventory, 1 do
- if PlayerData.inventory[i].name == 'blindfold' then
- if PlayerData.inventory[i].count > 0 then
- TriggerEvent('esx_qalle:hasBlindfold')
- end
- end
- end
- for i=1, #PlayerData.inventory, 1 do
- if PlayerData.inventory[i].name == 'bulletproof' then
- if PlayerData.inventory[i].count > 0 then
- TriggerEvent('esx_qalle:hasBulletproof')
- end
- end
- end
- for i=1, #PlayerData.inventory, 1 do
- if PlayerData.inventory[i].name == 'dyrkset' then
- if PlayerData.inventory[i].count > 0 then
- TriggerEvent('esx_qalle:hasDyrkset')
- end
- end
- end
- end)
- RegisterNetEvent('esx_qalle:hasNyckel')
- AddEventHandler('esx_qalle:hasNyckel', function()
- hasNyckel = true
- end)
- RegisterNetEvent('esx_qalle:hasNotNyckel')
- AddEventHandler('esx_qalle:hasNotNyckel', function()
- hasNyckel = false
- end)
- RegisterNetEvent('esx_qalle:hasHandcuffs')
- AddEventHandler('esx_qalle:hasHandcuffs', function()
- hasHandcuffs = true
- end)
- RegisterNetEvent('esx_qalle:hasNotHandcuffs')
- AddEventHandler('esx_qalle:hasNotHandcuffs', function()
- hasHandcuffs = false
- end)
- RegisterNetEvent('esx_qalle:hasBlindfold')
- AddEventHandler('esx_qalle:hasBlindfold', function()
- hasBlindfold = true
- end)
- RegisterNetEvent('esx_qalle:hasNotBlindfold')
- AddEventHandler('esx_qalle:hasNotBlindfold', function()
- hasBlindfold = false
- end)
- RegisterNetEvent('esx_qalle:hasDyrkset')
- AddEventHandler('esx_qalle:hasDyrkset', function()
- hasDyrkset = true
- end)
- RegisterNetEvent('esx_qalle:hasNotDyrkset')
- AddEventHandler('esx_qalle:hasNotDyrkset', function()
- hasDyrkset = false
- end)
- RegisterNetEvent('esx_qalle:hasBulletproof')
- AddEventHandler('esx_qalle:hasBulletproof', function()
- hasBulletproof = true
- end)
- RegisterNetEvent('esx_qalle:hasNotBulletproof')
- AddEventHandler('esx_qalle:hasNotBulletproof', function()
- hasBulletproof = false
- end)
- -- asccesories
- function SetUnsetAccessory(accessory)
- ESX.TriggerServerCallback('esx_accessories:get', function(hasAccessory, accessorySkin)
- local _accessory = string.lower(accessory)
- if hasAccessory then
- TriggerEvent('skinchanger:getSkin', function(skin)
- local mAccessory = -1
- local mColor = 0
- if _accessory == "mask" then
- mAccessory = 0
- end
- if skin[_accessory .. '_1'] == mAccessory then
- mAccessory = accessorySkin[_accessory .. '_1']
- mColor = accessorySkin[_accessory .. '_2']
- end
- local accessorySkin = {}
- accessorySkin[_accessory .. '_1'] = mAccessory
- accessorySkin[_accessory .. '_2'] = mColor
- TriggerEvent('skinchanger:loadClothes', skin, accessorySkin)
- end)
- else
- sendNotification('Du har ingen ' .. _accessory, 'error', 2500)
- end
- end, accessory)
- end
- -- C O N F I G --
- interactionDistance = 9.5 --The radius you have to be in to interact with the vehicle.
- lockDistance = 25 --The radius you have to be in to lock your vehicle.
- -- V A R I A B L E S --
- engineoff = false
- saved = false
- controlsave_bool = false
- -- E N G I N E --
- IsEngineOn = true
- RegisterNetEvent('engine')
- AddEventHandler('engine',function()
- local player = GetPlayerPed(-1)
- if (IsPedSittingInAnyVehicle(player)) then
- local vehicle = GetVehiclePedIsIn(player,false)
- if IsEngineOn == true then
- IsEngineOn = false
- SetVehicleEngineOn(vehicle,false,false,false)
- else
- IsEngineOn = true
- SetVehicleUndriveable(vehicle,false)
- SetVehicleEngineOn(vehicle,true,false,false)
- end
- while (IsEngineOn == false) do
- SetVehicleUndriveable(vehicle,true)
- Citizen.Wait(0)
- end
- end
- end)
- -- T R U N K --
- RegisterNetEvent('trunk')
- AddEventHandler('trunk',function()
- local player = GetPlayerPed(-1)
- if controlsave_bool == true then
- vehicle = saveVehicle
- else
- vehicle = GetVehiclePedIsIn(player,true)
- end
- local isopen = GetVehicleDoorAngleRatio(vehicle,5)
- local distanceToVeh = GetDistanceBetweenCoords(GetEntityCoords(player), GetEntityCoords(vehicle), 1)
- if distanceToVeh <= interactionDistance then
- if (isopen == 0) then
- SetVehicleDoorOpen(vehicle,5,0,0)
- else
- SetVehicleDoorShut(vehicle,5,0)
- end
- else
- end
- end)
- RegisterNetEvent('fdoors')
- AddEventHandler('fdoors',function()
- local player = GetPlayerPed(-1)
- if controlsave_bool == true then
- vehicle = saveVehicle
- else
- vehicle = GetVehiclePedIsIn(player,true)
- end
- local isopen = GetVehicleDoorAngleRatio(vehicle,0) and GetVehicleDoorAngleRatio(vehicle,1)
- local distanceToVeh = GetDistanceBetweenCoords(GetEntityCoords(player), GetEntityCoords(vehicle), 1)
- if distanceToVeh <= interactionDistance then
- if (isopen == 0) then
- SetVehicleDoorOpen(vehicle,0,0,0)
- SetVehicleDoorOpen(vehicle,1,0,0)
- else
- SetVehicleDoorShut(vehicle,0,0)
- SetVehicleDoorShut(vehicle,1,0)
- end
- else
- end
- end)
- -- R E A R D O O R S --
- RegisterNetEvent('rdoors')
- AddEventHandler('rdoors',function()
- local player = GetPlayerPed(-1)
- if controlsave_bool == true then
- vehicle = saveVehicle
- else
- vehicle = GetVehiclePedIsIn(player,true)
- end
- local isopen = GetVehicleDoorAngleRatio(vehicle,2) and GetVehicleDoorAngleRatio(vehicle,3)
- local distanceToVeh = GetDistanceBetweenCoords(GetEntityCoords(player), GetEntityCoords(vehicle), 1)
- if distanceToVeh <= interactionDistance then
- if (isopen == 0) then
- SetVehicleDoorOpen(vehicle,2,0,0)
- SetVehicleDoorOpen(vehicle,3,0,0)
- else
- SetVehicleDoorShut(vehicle,2,0)
- SetVehicleDoorShut(vehicle,3,0)
- end
- else
- end
- end)
- -- H O O D --
- RegisterNetEvent('hood')
- AddEventHandler('hood',function()
- local player = GetPlayerPed(-1)
- if controlsave_bool == true then
- vehicle = saveVehicle
- else
- vehicle = GetVehiclePedIsIn(player,true)
- end
- local isopen = GetVehicleDoorAngleRatio(vehicle,4)
- local distanceToVeh = GetDistanceBetweenCoords(GetEntityCoords(player), GetEntityCoords(vehicle), 1)
- if distanceToVeh <= interactionDistance then
- if (isopen == 0) then
- SetVehicleDoorOpen(vehicle,4,0,0)
- else
- SetVehicleDoorShut(vehicle,4,0)
- end
- else
- end
- end)
- -- notification
- function sendNotification(message, messageType, messageTimeout)
- TriggerEvent("pNotify:SendNotification", {
- text = message,
- type = messageType,
- queue = "qalle",
- timeout = messageTimeout,
- layout = "bottomCenter"
- })
- end
- -- Key events
- Citizen.CreateThread(function()
- while true do
- Wait(0)
- if IsControlPressed(0, Keys['F5']) then
- openMenu()
- end
- end
- end)
- function drawTxt(x,y ,width,height,scale, text, r,g,b,a)
- SetTextFont(4)
- SetTextProportional(0)
- SetTextScale(scale, scale)
- SetTextColour(r, g, b, a)
- SetTextDropShadow(0, 0, 0, 0,255)
- SetTextEdge(2, 0, 0, 0, 255)
- SetTextDropShadow()
- SetTextOutline()
- SetTextEntry("STRING")
- AddTextComponentString(text)
- DrawText(x - width/2, y - height/2 + 0.005)
- end
- function drawRct(x,y,width,height,r,g,b,a)
- DrawRect(x + width/2, y + height/2, width, height, r, g, b, a)
- end
- -- Bälte
- local speedBuffer = {}
- local velBuffer = {}
- local beltOn = false
- local wasInCar = false
- IsCar = function(veh)
- local vc = GetVehicleClass(veh)
- return (vc >= 0 and vc <= 7) or (vc >= 9 and vc <= 12) or (vc >= 17 and vc <= 20)
- end
- Fwv = function (entity)
- local hr = GetEntityHeading(entity) + 90.0
- if hr < 0.0 then hr = 360.0 + hr end
- hr = hr * 0.0174533
- return { x = math.cos(hr) * 2.0, y = math.sin(hr) * 2.0 }
- end
- Citizen.CreateThread(function()
- Citizen.Wait(500)
- while true do
- local ped = GetPlayerPed(-1)
- local car = GetVehiclePedIsIn(ped)
- if car ~= 0 and (wasInCar or IsCar(car)) then
- wasInCar = true
- if beltOn then DisableControlAction(0, 75) end
- -- if beltOn and IsControlJustReleased(29)
- -- TriggerEvent("pNotify:SendNotification", {text = "Du har bälte på dig!", type = "error", queue = "belt", timeout = 700, layout = "bottomCenter"})
- -- end
- speedBuffer[2] = speedBuffer[1]
- speedBuffer[1] = GetEntitySpeed(car)
- if speedBuffer[2] ~= nil
- and not beltOn
- and GetEntitySpeedVector(car, true).y > 1.0
- and speedBuffer[1] > 19.25
- and (speedBuffer[2] - speedBuffer[1]) > (speedBuffer[1] * 0.255) then
- local co = GetEntityCoords(ped)
- local fw = Fwv(ped)
- SetEntityCoords(ped, co.x + fw.x, co.y + fw.y, co.z - 0.47, true, true, true)
- SetEntityVelocity(ped, velBuffer[2].x, velBuffer[2].y, velBuffer[2].z)
- Citizen.Wait(1)
- SetPedToRagdoll(ped, 1000, 1000, 0, 0, 0, 0)
- end
- velBuffer[2] = velBuffer[1]
- velBuffer[1] = GetEntityVelocity(car)
- if IsControlJustReleased(0, 29) then
- beltOn = not beltOn
- if beltOn then TriggerEvent("pNotify:SendNotification", {text = _U('seatbelt_on'), type = "success", queue = "belt", timeout = 700, layout = "bottomCenter"})
- else TriggerEvent("pNotify:SendNotification", {text = _U('seatbelt_off'), type = "error", queue = "belt", timeout = 700, layout = "bottomCenter"}) end
- end
- elseif wasInCar then
- wasInCar = false
- beltOn = false
- speedBuffer[1], speedBuffer[2] = 0.0, 0.0
- end
- Citizen.Wait(0)
- end
- end)
- local disableShuffle = true
- function disableSeatShuffle(flag)
- disableShuffle = flag
- end
- function getVehicleInDirection(coordFrom, coordTo)
- local rayHandle = CastRayPointToPoint(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z, 10, GetPlayerPed(-1), 0)
- local a, b, c, d, vehicle = GetRaycastResult(rayHandle)
- return vehicle
- end
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- if IsPedInAnyVehicle(GetPlayerPed(-1), false) and disableShuffle then
- if GetPedInVehicleSeat(GetVehiclePedIsIn(GetPlayerPed(-1), false), 0) == GetPlayerPed(-1) then
- if GetIsTaskActive(GetPlayerPed(-1), 165) then
- SetPedIntoVehicle(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 0)
- end
- end
- end
- end
- end)
- RegisterNetEvent("SeatShuffle")
- AddEventHandler("SeatShuffle", function()
- if IsPedInAnyVehicle(GetPlayerPed(-1), false) then
- disableSeatShuffle(false)
- Citizen.Wait(5000)
- disableSeatShuffle(true)
- else
- CancelEvent()
- end
- end)
- RegisterCommand("shuff", function(source, args, raw) --change command here
- TriggerEvent("SeatShuffle")
- end, false) --False, allow everyone to run it
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement