Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local polhelicoshop = {
- opened = false,
- title = "Heliport Police",
- currentmenu = "mainpolice",
- lastmenu = nil,
- currentpos = nil,
- selectedbutton = 0,
- marker = { r = 0, g = 155, b = 255, a = 200, type = 1 },
- menu = {
- x = 0.9,
- y = 0.20,
- width = 0.2,
- height = 0.04,
- buttons = 10,
- from = 1,
- to = 10,
- scale = 0.4,
- font = 0,
- ["mainpolice"] = {
- title = "Los Santos Police Department",
- name = "mainpolice",
- buttons = {
- }
- },
- }
- }
- RegisterNetEvent('PoliceHeli1')
- AddEventHandler('PoliceHeli1', function()
- polhelicoshop.menu["mainpolice"].buttons = {}
- if (clientrankid == 27) then --Cadet
- table.insert(polhelicoshop.menu["mainpolice"].buttons, {name = "Aucun hélicoptère disponible", description = {}, model = ""})
- elseif (clientrankid == 28) then --Sergent
- table.insert(polhelicoshop.menu["mainpolice"].buttons, {name = "Aucun hélicoptère disponible", description = {}, model = ""})
- elseif (clientrankid == 29) then --SergentChef
- table.insert(polhelicoshop.menu["mainpolice"].buttons, {name = "Helicoptère Police", description = {}, model = "polmav"})
- elseif (clientrankid == 30) then --Lieutenant
- table.insert(polhelicoshop.menu["mainpolice"].buttons, {name = "Helicoptère Police", description = {}, model = "polmav"})
- elseif (clientrankid == 3) then --Capitaine
- table.insert(polhelicoshop.menu["mainpolice"].buttons, {name = "Helicoptère Police", description = {}, model = "polmav"})
- else
- table.insert(polhelicoshop.menu["mainpolice"].buttons, {name = "Helicoptère Police", description = {}, model = "polmav"})
- end
- end)
- RegisterNetEvent('PoliceHeli2')
- AddEventHandler('PoliceHeli2', function()
- polhelicoshop.currentmenu = "mainpolice"
- polhelicoshop.opened = true
- polhelicoshop.selectedbutton = 0
- end)
- local HeliportPolice_locations = {
- {polheli = {448.8877,-981.2548,43.09166}, armurerie = {449.3099,-9982779,24.44535}, outside = {448.8877,-981.2548,43.09166}},
- }
- local HeliportPolice_blips ={}
- local inrangeofHeliportPolice = false
- local currentlocation = nil
- local boughtweapon = false
- local function LocalPed()
- return GetPlayerPed(-1)
- end
- function drawTxt(text,font,centre,x,y,scale,r,g,b,a)
- SetTextFont(font)
- SetTextProportional(0)
- SetTextScale(scale, scale)
- SetTextColour(r, g, b, a)
- SetTextDropShadow(0, 0, 0, 0,255)
- SetTextEdge(1, 0, 0, 0, 255)
- SetTextDropShadow()
- SetTextOutline()
- SetTextCentre(centre)
- SetTextEntry("STRING")
- AddTextComponentString(text)
- DrawText(x , y)
- end
- function IsPlayerinrangeofHeliportPolice()
- return inrangeofHeliportPolice
- end
- function ShowHeliPoliceBlips(bool)
- if bool and #HeliportPolice_blips == 0 then
- for station,pos in pairs(HeliportPolice_locations) do
- local loc = pos
- pos = pos.outside
- table.insert(HeliportPolice_blips, {blip = blip, pos = loc})
- end
- Citizen.CreateThread(function()
- while #HeliportPolice_blips > 0 do
- Citizen.Wait(0)
- local inrange = false
- for i,b in ipairs(HeliportPolice_blips) do
- if (clientjobID == 10) and GetDistanceBetweenCoords(b.pos.polheli[1],b.pos.polheli[2],b.pos.polheli[3],GetEntityCoords(LocalPed()),true) > 0 then
- DrawMarker(0,b.pos.polheli[1],b.pos.polheli[2],b.pos.polheli[3],0,0,0,0,0,0,2.001,2.0001,0.5001,0,155,255,200,0,0,0,0)
- currentlocation = b
- if GetDistanceBetweenCoords(b.pos.polheli[1],b.pos.polheli[2],b.pos.polheli[3],GetEntityCoords(LocalPed()),true) < 4 then
- ShowInfoComico("Appuyez sur ~INPUT_CONTEXT~ pour choisir votre ~b~Hélicoptère.", 0)
- inrange = true
- end
- end
- end
- inrangeofHeliportPolice = inrange
- end
- end)
- elseif bool == false and #HeliportPolice_blips > 0 then
- for i,b in ipairs(HeliportPolice_blips) do
- if DoesBlipExist(b.blip) then
- SetBlipAsMissionCreatorBlip(b.blip,false)
- Citizen.InvokeNative(0x86A652570E5F25DD, Citizen.PointerValueIntInitialized(b.blip))
- end
- end
- HeliportPolice_blips = {}
- end
- end
- --Creator Weapon
- function OpenCreatorpolheli()
- boughtweapon = false
- local ped = LocalPed()
- local pos = currentlocation.pos.polheli
- FreezeEntityPosition(ped,true)
- local g = Citizen.InvokeNative(0xC906A7DAB05C8D2B,pos[1],pos[2],pos[3],Citizen.PointerValueFloat(),0)
- -- SetEntityCoords(ped,pos[1],pos[2],g)
- polhelicoshop.currentmenu = "mainpolice"
- polhelicoshop.opened = true
- polhelicoshop.selectedbutton = 0
- end
- function CloseCreatorpolheli()
- Citizen.CreateThread(function()
- local ped = LocalPed()
- if not boughtweapon then
- local pos = currentlocation.pos.polheli
- -- SetEntityCoords(ped,pos[1],pos[2],pos[3])
- FreezeEntityPosition(ped,false)
- else
- FreezeEntityPosition(ped,false)
- SetEntityVisible(ped,true)
- end
- polhelicoshop.opened = false
- polhelicoshop.menu.from = 1
- polhelicoshop.menu.to = 10
- end)
- end
- --Menu polheli
- function drawMenuButton(button,x,y,selected)
- local menu = polhelicoshop.menu
- SetTextFont(menu.font)
- SetTextProportional(0)
- SetTextScale(menu.scale, menu.scale)
- if selected then
- SetTextColour(0, 0, 0, 255)
- else
- SetTextColour(255, 255, 255, 255)
- end
- SetTextCentre(0)
- SetTextEntry("STRING")
- AddTextComponentString(button.name)
- if selected then
- DrawRect(x,y,menu.width,menu.height,255,255,255,255)
- else
- DrawRect(x,y,menu.width,menu.height,0,0,0,150)
- end
- DrawText(x - menu.width/2 + 0.005, y - menu.height/2 + 0.0028)
- end
- function drawMenuInfo(text)
- local menu = polhelicoshop.menu
- SetTextFont(menu.font)
- SetTextProportional(0)
- SetTextScale(0.45, 0.45)
- SetTextColour(255, 255, 255, 255)
- SetTextCentre(0)
- SetTextEntry("STRING")
- AddTextComponentString(text)
- DrawRect(0.675, 0.95,0.65,0.050,0,0,0,150)
- DrawText(0.365, 0.934)
- end
- function drawMenuRight(txt,x,y,selected)
- local menu = polhelicoshop.menu
- SetTextFont(menu.font)
- SetTextProportional(0)
- SetTextScale(menu.scale, menu.scale)
- SetTextRightJustify(1)
- if selected then
- SetTextColour(0, 0, 0, 255)
- else
- SetTextColour(255, 255, 255, 255)
- end
- SetTextCentre(0)
- SetTextEntry("STRING")
- AddTextComponentString(txt)
- DrawText(x + menu.width/2 - 0.03, y - menu.height/2 + 0.0028)
- end
- function drawMenuTitle(txt,x,y)
- local menu = polhelicoshop.menu
- SetTextFont(2)
- SetTextProportional(0)
- SetTextScale(0.5, 0.5)
- SetTextColour(255, 255, 255, 255)
- SetTextEntry("STRING")
- AddTextComponentString(txt)
- DrawRect(x,y,menu.width,menu.height,0,0,0,150)
- DrawText(x - menu.width/2 + 0.005, y - menu.height/2 + 0.0028)
- end
- function tablelength(T)
- local count = 0
- for _ in pairs(T) do count = count + 1 end
- return count
- end
- function Notify5(text)
- SetNotificationTextEntry('STRING')
- AddTextComponentString(text)
- DrawNotification(false, false)
- end
- local backlock = false
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- if IsControlJustPressed(1,38) and IsPlayerinrangeofHeliportPolice() then
- if polhelicoshop.opened then
- else
- TriggerServerEvent('OpenHeliShopPol')
- end
- end
- if polhelicoshop.opened then
- local ped = LocalPed()
- local menu = polhelicoshop.menu[polhelicoshop.currentmenu]
- drawTxt(polhelicoshop.title,1,1,polhelicoshop.menu.x,polhelicoshop.menu.y,1.0, 255,255,255,255)
- drawMenuTitle(menu.title, polhelicoshop.menu.x,polhelicoshop.menu.y + 0.08)
- drawTxt(polhelicoshop.selectedbutton.."/"..tablelength(menu.buttons),0,0,polhelicoshop.menu.x + polhelicoshop.menu.width/2 - 0.0385,polhelicoshop.menu.y + 0.067,0.4, 255,255,255,255)
- local y = polhelicoshop.menu.y + 0.12
- buttoncount = tablelength(menu.buttons)
- local selected = false
- for i,button in pairs(menu.buttons) do
- if i >= polhelicoshop.menu.from and i <= polhelicoshop.menu.to then
- if i == polhelicoshop.selectedbutton then
- selected = true
- else
- selected = false
- end
- drawMenuButton(button,polhelicoshop.menu.x,y,selected)
- y = y + 0.04
- if selected and IsControlJustPressed(1,201) then
- ButtonSelected5(button)
- end
- end
- end
- end
- if polhelicoshop.opened then
- if IsControlJustPressed(1,202) then
- Back5()
- end
- if IsControlJustReleased(1,202) then
- backlock = false
- end
- if IsControlJustPressed(1,188) then
- if polhelicoshop.selectedbutton > 1 then
- polhelicoshop.selectedbutton = polhelicoshop.selectedbutton -1
- if buttoncount > 10 and polhelicoshop.selectedbutton < polhelicoshop.menu.from then
- polhelicoshop.menu.from = polhelicoshop.menu.from -1
- polhelicoshop.menu.to = polhelicoshop.menu.to - 1
- end
- end
- end
- if IsControlJustPressed(1,187)then
- if polhelicoshop.selectedbutton < buttoncount then
- polhelicoshop.selectedbutton = polhelicoshop.selectedbutton +1
- if buttoncount > 10 and polhelicoshop.selectedbutton > polhelicoshop.menu.to then
- polhelicoshop.menu.to = polhelicoshop.menu.to + 1
- polhelicoshop.menu.from = polhelicoshop.menu.from + 1
- end
- end
- end
- end
- end
- end)
- function ButtonSelected5(button)
- local ped = GetPlayerPed(-1)
- local this = polhelicoshop.currentmenu
- local btn = button.name
- if this == "mainpolice" then
- if btn == "Aucun hélicoptère disponible" then
- else
- TriggerServerEvent('CheckpolheliForGaragePolice',button.model)
- CloseCreatorpolheli()
- polhelicoshop.opened = false
- polhelicoshop.menu.from = 1
- polhelicoshop.menu.to = 10
- end
- else
- end
- end
- RegisterNetEvent('FinishpolheliCheckForGaragePolice')
- AddEventHandler('FinishpolheliCheckForGaragePolice', function()
- boughtweapon = true
- CloseCreatorpolheli()
- polhelicoshop.opened = false
- polhelicoshop.menu.from = 1
- polhelicoshop.menu.to = 10
- end)
- function OpenMenu5(menu)
- polhelicoshop.lastmenu = polhelicoshop.currentmenu
- if menu == "mainpolice" then
- polhelicoshop.lastmenu = "main"
- elseif menu == "mainintervention" then
- polhelicoshop.lastmenu = "main"
- elseif menu == 'race_create_objects' then
- polhelicoshop.lastmenu = "main"
- elseif menu == "race_create_objects_spawn" then
- polhelicoshop.lastmenu = "race_create_objects"
- end
- polhelicoshop.menu.from = 1
- polhelicoshop.menu.to = 10
- polhelicoshop.selectedbutton = 0
- polhelicoshop.currentmenu = menu
- end
- function Back5()
- if backlock then
- return
- end
- backlock = true
- if polhelicoshop.currentmenu == "mainpolice" then
- CloseCreatorpolheli()
- elseif polhelicoshop.currentmenu == "police1" or polhelicoshop.currentmenu == "police2" or polhelicoshop.currentmenu == "police3" or polhelicoshop.currentmenu == "police4" or polhelicoshop.currentmenu == "police5" or polhelicoshop.currentmenu == "police6" then
- OpenMenu5(polhelicoshop.lastmenu)
- else
- OpenMenu5(polhelicoshop.lastmenu)
- end
- end
- function stringstarts5(String,Start)
- return string.sub(String,1,string.len(Start))==Start
- end
- local firstspawn = 0
- AddEventHandler('playerSpawned', function(spawn)
- if firstspawn == 0 then
- ShowHeliPoliceBlips(true)
- firstspawn = 1
- end
- end)
Add Comment
Please, Sign In to add comment