Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ESX = nil
- local PlayerData = {}
- Citizen.CreateThread(function()
- while ESX == nil do
- TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
- Citizen.Wait(0)
- end
- end)
- RegisterNetEvent('esx:playerLoaded')
- AddEventHandler('esx:playerLoaded', function(xPlayer)
- PlayerData = xPlayer
- end)
- RegisterNetEvent('esx:setJob')
- AddEventHandler('esx:setJob', function(job)
- PlayerData.job = job
- end)
- key_to_teleport = 38
- positions = {
- --[[
- {{Teleport1 X, Teleport1 Y, Teleport1 Z, Teleport1 Heading}, {Teleport2 X, Teleport 2Y, Teleport 2Z, Teleport2 Heading}, {Red, Green, Blue}, "Text for Teleport"}
- ]]
- {{-1507.59, -3017.18, -79.24-0.95, 266.11}, {456.8, -986.36, 26.67-0.95, 147.27},{0, 0, 95}, "Garaget"},
- {{-1518.6, -2978.41, -80.85-0.95, 266.11}, {463.23, -1019.46, 27.84-0.95, 92.27},{0, 0, 95}, "Garaget"},
- }
- -----------------------------------------------------------------------------
- -------------------------DO NOT EDIT BELOW THIS LINE-------------------------
- -----------------------------------------------------------------------------
- local player = GetPlayerPed(-1)
- Citizen.CreateThread(function ()
- while true do
- Citizen.Wait(5)
- local player = GetPlayerPed(-1)
- local playerLoc = GetEntityCoords(player)
- local KeyAmmount = 0
- local inventory = ESX.GetPlayerData()["inventory"]
- local message = "En person har fΓΆrsΓΆkt ta sig in i erat garage!"
- for i=1, #inventory, 1 do
- if inventory[i].name == 'policecard' then
- KeyAmmount = inventory[i].count
- end
- end
- for _,location in ipairs(positions) do
- teleport_text = location[4]
- loc1 = {
- x=location[1][1],
- y=location[1][2],
- z=location[1][3],
- heading=location[1][4]
- }
- loc2 = {
- x=location[2][1],
- y=location[2][2],
- z=location[2][3],
- heading=location[2][4]
- }
- Red = location[3][1]
- Green = location[3][2]
- Blue = location[3][3]
- DrawMarker(27, loc1.x, loc1.y, loc1.z, 0, 0, 0, 0, 0, 0, 1.501, 1.5001, 0.5001, Red, Green, Blue, 200, 0, 0, 0, 0)
- DrawMarker(27, loc2.x, loc2.y, loc2.z, 0, 0, 0, 0, 0, 0, 1.501, 1.5001, 0.5001, Red, Green, Blue, 200, 0, 0, 0, 0)
- if CheckPos(playerLoc.x, playerLoc.y, playerLoc.z, loc1.x, loc1.y, loc1.z, 2) then
- alert(teleport_text)
- if IsControlJustReleased(1, key_to_teleport) then
- if IsPedInAnyVehicle(player, true) then
- SetEntityCoords(GetVehiclePedIsUsing(player), loc2.x, loc2.y, loc2.z)
- SetEntityHeading(GetVehiclePedIsUsing(player), loc2.heading)
- else
- SetEntityCoords(player, loc2.x, loc2.y, loc2.z)
- SetEntityHeading(player, loc2.heading)
- end
- end
- elseif CheckPos(playerLoc.x, playerLoc.y, playerLoc.z, loc2.x, loc2.y, loc2.z, 2) then
- alert(teleport_text)
- if IsControlJustReleased(1, key_to_teleport) then
- if KeyAmmount > 0 then
- if IsPedInAnyVehicle(player, true) then
- SetEntityCoords(GetVehiclePedIsUsing(player), loc1.x, loc1.y, loc1.z)
- SetEntityHeading(GetVehiclePedIsUsing(player), loc1.heading)
- else
- SetEntityCoords(player, loc1.x, loc1.y, loc1.z)
- SetEntityHeading(player, loc1.heading)
- end
- else
- sendNotification('Du har ingen polisnyckel! Kriminella svin.', 'error', 1700)
- TriggerServerEvent('esx_phone:send', 'police', message, true, false)
- end
- end
- end
- end
- end
- end)
- function CheckPos(x, y, z, cx, cy, cz, radius)
- local t1 = x - cx
- local t12 = t1^2
- local t2 = y-cy
- local t21 = t2^2
- local t3 = z - cz
- local t31 = t3^2
- return (t12 + t21 + t31) <= radius^2
- end
- function alert(msg)
- SetTextComponentFormat("STRING")
- AddTextComponentString(msg)
- DisplayHelpTextFromStringLabel(0,0,1,-1)
- end
- function sendNotification(message, messageType, messageTimeout)
- TriggerEvent("pNotify:SendNotification", {
- text = message,
- type = messageType,
- queue = "chris",
- timeout = messageTimeout,
- layout = "bottomCenter"
- })
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement