Jump to content

[HELPx10]PilotJob class


||BuLLeT||

Recommended Posts

hey, i got problem with pilot job, i want it be locked to pilot class, when player spawn "Pilot" on my spawn system it gets bind like "P" and then he get GUI with planes choose, i want when he choose plane he can go deliver(thats already in script) just need help with GUI binding and locking to Pilot class

plane.lua

rootElement = getRootElement() 
local lvairportblip = createBlip(1674, 1447.5, 11, 5) 
  
planemarkerlv = createMarker(1674, 1447.5, 9.5, "cylinder", 5, 255, 0, 0, 160) 
gate1LVmarker = createMarker(1576.5, 1495.30, 13, "cylinder", 18, 0, 155, 255, 30) 
gate2LVmarker = createMarker(1570.8, 1532.87, 13, "cylinder", 18, 0, 155, 255, 30) 
gate3LVmarker = createMarker(1602.5, 1546.54, 13, "cylinder", 18, 0, 155, 255, 30) 
gate4LVmarker = createMarker(1576.7, 1401.46, 13, "cylinder", 18, 0, 155, 255, 30) 
gate5LVmarker = createMarker(1570.8, 1363.94, 13, "cylinder", 18, 0, 155, 255, 30) 
gate6LVmarker = createMarker(1601.4, 1350.91, 13, "cylinder", 18, 0, 155, 255, 30) 
  
  
gate1SFmarker = createMarker(-1350.1, -235.77, 16, "cylinder", 18, 0, 155, 255, 30) 
gate2SFmarker = createMarker(-1298.6, -366.46, 16, "cylinder", 18, 0, 155, 255, 30) 
gate3SFmarker = createMarker(-1462.2, -157.35, 16, "cylinder", 18, 0, 155, 255, 30) 
gate4SFmarker = createMarker(-1362.5, -146.57, 16, "cylinder", 18, 0, 155, 255, 30) 
gate5SFmarker = createMarker(-1257.2, -252.85, 16, "cylinder", 18, 0, 155, 255, 30) 
  
gate1LSmarker = createMarker(1569.78, -2433.4, 15, "cylinder", 18, 0, 155, 255, 30) 
gate2LSmarker = createMarker(1654.20, -2440, 15, "cylinder", 18, 0, 155, 255, 30) 
gate3LSmarker = createMarker(1884.6, -2388.15, 15, "cylinder", 18, 0, 155, 255, 30) 
  
addEvent ("airLVviewGUI", true) 
function markerHit (hitPlayer, matchingDimension) 
  if (source == planemarkerlv) then 
    triggerClientEvent ("airLVviewGUI", hitPlayer) 
    outputChatBox ("Welcome to Las Venturas Airport!", hitPlayer, 255, 255, 255) 
  end 
end 
addEventHandler ("onMarkerHit", getRootElement(), markerHit) 
  
addEvent ("gateLVviewGUI", true) 
function markerHitLVgate (hitPlayer, matchingDimension) 
local theVehicle = getPedOccupiedVehicle (hitPlayer) 
local id = getElementModel(theVehicle) 
  if ((source == gate1LVmarker) or (source == gate2LVmarker) or (source == gate3LVmarker) or (source == gate4LVmarker) or (source == gate5LVmarker) or (source == gate6LVmarker)) and (id == 511 or id == 577 or id == 592) then 
    if ((getAccountData (getPlayerAccount (hitPlayer), "flightDestination")) == "LV") then 
    givePlayerMoney (hitPlayer, 3000) 
    outputChatBox ("Welcome to Las Venturas Int. wait while you're unloading", hitPlayer, 255, 255, 0) 
    end  
    triggerClientEvent ("gateLVviewGUI", hitPlayer) 
    setTimer(function() 
    outputChatBox ("You are loaded and ready for departure", hitPlayer, 255, 255, 0) end, 
    5000,1) 
        elseif ((source == gate1LVmarker) or (source == gate2LVmarker) or (source == gate3LVmarker) or (source == gate4LVmarker) or (source == gate5LVmarker) or (source == gate6LVmarker)) then 
    outputChatBox ("You can't pick up passegers without a plane", hitPlayer, 255, 0, 0) 
  end 
end 
addEventHandler ("onMarkerHit", getRootElement(), markerHitLVgate) 
  
  
addEvent ("gateSFviewGUI", true) 
function markerHitSFgate (hitPlayer, matchingDimension) 
local theVehicle = getPedOccupiedVehicle (hitPlayer) 
local id = getElementModel(theVehicle) 
  if ((source == gate1SFmarker) or (source == gate2SFmarker) or (source == gate3SFmarker) or (source == gate4SFmarker) or (source == gate5SFmarker)) and (id == 511 or id == 577 or id == 592) then 
    if ((getAccountData (getPlayerAccount (hitPlayer), "flightDestination")) == "SF")  then 
    givePlayerMoney (hitPlayer, 3000) 
    outputChatBox ("Welcome to San Fierro Int. wait while you're unloading", hitPlayer, 255, 255, 0) 
    end 
    triggerClientEvent ("gateSFviewGUI", hitPlayer) 
    setTimer(function() 
    outputChatBox ("You are loaded and ready for departure", hitPlayer, 255, 255, 0) end, 
    5000,1) 
    elseif ((source == gate1SFmarker) or (source == gate2SFmarker) or (source == gate3SFmarker)) then 
    outputChatBox ("You can't pick up passegers without a plane", hitPlayer, 255, 0, 0) 
  end 
end 
addEventHandler ("onMarkerHit", getRootElement(), markerHitSFgate) 
  
addEvent ("gateLSviewGUI", true) 
function markerHitLSgate (hitPlayer, matchingDimension) 
local theVehicle = getPedOccupiedVehicle (hitPlayer) 
local id = getElementModel(theVehicle) 
  if ((source == gate1LSmarker) or (source == gate2LSmarker) or (source == gate3LSmarker)) and (id == 511 or id == 577 or id == 592) then 
    if ((getAccountData (getPlayerAccount (hitPlayer), "flightDestination")) == "LS")  then 
    outputChatBox ("Welcome to Los Santos Int. wait while you're unloading", hitPlayer, 255, 255, 0) 
    givePlayerMoney(hitPlayer, 3000)     
    end 
    triggerClientEvent ("gateLSviewGUI", hitPlayer) 
    setTimer(function() 
    outputChatBox ("You are loaded and ready for departure", hitPlayer, 0, 255, 0) end, 
    5000,1) 
    elseif ((source == gate1LSmarker) or (source == gate2LSmarker) or (source == gate3LSmarker)) then 
    outputChatBox ("You can't pick up passegers without a plane", hitPlayer, 255, 0, 0) 
  end 
end 
addEventHandler ("onMarkerHit", getRootElement(), markerHitLSgate) 
  
addEvent ("planeSpawn", true) 
addEventHandler ("planeSpawn", getRootElement(), 
    function (aircraft) 
    Plane = createVehicle(tonumber(aircraft), 1477.4, 1270.9, 11) 
    setCameraMatrix(1502, 1292, 11, 1475, 1288, 13.8, 90, 90) 
    warpPedIntoVehicle ( source, Plane ) 
    outputChatBox ("Pickup passengers at the terminal.", source, 0, 255, 0) 
     
end) 
  
addEvent ("setFlightPlan", true) 
addEventHandler ("setFlightPlan", getRootElement(), 
    function (departure, destination) 
     
    outputChatBox (departure.." Airport: You have clearance to taxi to runway 69", source, 255, 255, 255)  
    setTimer(function()  
    outputChatBox (departure.." Airport: You have clearance for take-off", source, 0, 255, 0)  
    outputChatBox (departure.." Airport: Have a nice flight to "..destination, source, 0, 255, 0) end, 12000,1) 
     
    setAccountData (getPlayerAccount (source), "flightDeparture", (tostring(departure))) 
    setAccountData (getPlayerAccount (source), "flightDestination", (tostring(destination))) 
    setElementData(source, "flightDeparture", departure) 
    setElementData(source, "flightDestination", destination) 
     
end) 
  
addEvent ("destroyPlane", true) 
function destroyplane() 
local theVehicle = getPedOccupiedVehicle (source) 
local id = getElementModel(theVehicle) 
if (id == 511 or id == 577 or id == 592) then 
destroyElement(Plane) 
else 
end 
end 
  
  
addEvent ("visiblePlaneMarkers", true) 
function visiblePlaneMarkers(thePlayer) 
local theVehicle = getPedOccupiedVehicle (thePlayer) 
local id = getElementModel(theVehicle) 
if (id == 511 or id == 577 or id == 592) then 
  
else  
end 
end 
  
addEventHandler("onVehicleEnter", rootElement, visiblePlaneMarkers) 
addEventHandler("onVehicleExit", rootElement, destroyplane) 
addEventHandler("onPlayerQuit", rootElement, destroyplane) 

planeC.lua

--- PLANE SPAWN WINDOW --- 
planeWindow = guiCreateWindow(0.35, 0.35, 0.3, 0.3,"NSH planes",true) 
guiSetVisible (planeWindow, false) 
guiSetAlpha(planeWindow,1) 
guiWindowSetSizable(planeWindow,false) 
selectLabel = guiCreateLabel(0.0423,0.1009,0.8889,0.078,"Select your plane",true,planeWindow) 
guiSetAlpha(selectLabel,1) 
guiLabelSetColor(selectLabel,255,255,255) 
guiLabelSetVerticalAlign(selectLabel,"top") 
guiLabelSetHorizontalAlign(selectLabel,"left",false) 
guiSetFont(selectLabel,"default-bold-small") 
planeGridList = guiCreateGridList(0.0476,0.1789,0.9048,0.6789,true,planeWindow) 
guiGridListSetSelectionMode(planeGridList,0) 
planeColumn = guiGridListAddColumn(planeGridList,"ID",0.2) 
planeColumn = guiGridListAddColumn(planeGridList,"Aircraft",0.7) 
planes = {[511] = true, [592] = true, [577] = true} 
local planelist = { 
{511, "KLM  Fokker 50 Cityhopper"}, 
{577, "KLM  Boeing 737-800"}, 
{592, "KLM  Boeing 747-400"}} 
for i,v in ipairs (planelist) do   
    local row = guiGridListAddRow (planeGridList) 
    guiGridListSetItemText (planeGridList, row, 1, (v[1]), false, true) 
    guiGridListSetItemText (planeGridList, row, 2, tostring(v[2]), false, true) 
end 
flyButton = guiCreateButton(0.0476,0.8624,0.905,0.0963,"Get in a plane",true,planeWindow) 
guiSetAlpha(flyButton,1) 
  
  
--- LAS VENTURAS GATE WINDOW --- 
gateLVWindow = guiCreateWindow(0.35, 0.35, 0.3, 0.2,"Las Venturas Airport",true) 
guiSetVisible (gateLVWindow, false) 
guiSetAlpha(gateLVWindow,1) 
guiWindowSetSizable(gateLVWindow,false) 
selectDestLabel = guiCreateLabel(0.0423,0.2009,0.8889,0.10,"Select your destination:",true,gateLVWindow) 
guiSetAlpha(selectDestLabel,1) 
guiLabelSetColor(selectLabel,255,255,150) 
guiLabelSetVerticalAlign(selectLabel,"top") 
guiLabelSetHorizontalAlign(selectLabel,"left",false) 
guiSetFont(selectLabel,"default-bold-small") 
LVtoSFbutton = guiCreateButton(0.0476,0.6624,0.45,0.2963,"San Fierro",true,gateLVWindow) 
guiSetAlpha(LVtoSFbutton,1) 
LVtoLSbutton = guiCreateButton(0.5476,0.6624,0.45,0.2963,"Los Santos",true,gateLVWindow) 
guiSetAlpha(LVtoLSbutton,1) 
  
--- SAN FIERRO GATE WINDOW --- 
gateSFWindow = guiCreateWindow(0.35, 0.35, 0.3, 0.2,"San Fierro Airport",true) 
guiSetVisible (gateSFWindow, false) 
guiSetAlpha(gateSFWindow,1) 
guiWindowSetSizable(gateSFWindow,false) 
selectDestLabel = guiCreateLabel(0.0423,0.2009,0.8889,0.10,"Select your destination:",true,gateSFWindow) 
guiSetAlpha(selectDestLabel,1) 
guiLabelSetColor(selectLabel,255,255,150) 
guiLabelSetVerticalAlign(selectLabel,"top") 
guiLabelSetHorizontalAlign(selectLabel,"left",false) 
guiSetFont(selectLabel,"default-bold-small") 
SFtoLVbutton = guiCreateButton(0.0476,0.6624,0.45,0.2963,"Las Venturas",true,gateSFWindow) 
guiSetAlpha(SFtoLVbutton,1) 
SFtoLSbutton = guiCreateButton(0.5476,0.6624,0.45,0.2963,"Los Santos",true,gateSFWindow) 
guiSetAlpha(SFtoLSbutton,1) 
  
--- LOS SANTOS GATE WINDOW --- 
gateLSWindow = guiCreateWindow(0.35, 0.35, 0.3, 0.2,"Los Santos Airport",true) 
guiSetVisible (gateLSWindow, false) 
guiSetAlpha(gateLSWindow,1) 
guiWindowSetSizable(gateLSWindow,false) 
selectDestLabel = guiCreateLabel(0.0423,0.2009,0.8889,0.10,"Select your destination:",true,gateLSWindow) 
guiSetAlpha(selectDestLabel,1) 
guiLabelSetColor(selectLabel,255,255,150) 
guiLabelSetVerticalAlign(selectLabel,"top") 
guiLabelSetHorizontalAlign(selectLabel,"left",false) 
guiSetFont(selectLabel,"default-bold-small") 
LStoLVbutton = guiCreateButton(0.0476,0.6624,0.45,0.2963,"Las Venturas",true,gateLSWindow) 
guiSetAlpha(SFtoLVbutton,1) 
LStoSFbutton = guiCreateButton(0.5476,0.6624,0.45,0.2963,"San Fierro",true,gateLSWindow) 
guiSetAlpha(SFtoLSbutton,1) 
  
  
addEvent ("airLVviewGUI", true) 
function airLVviewGUI () 
  if (getLocalPlayer() == source) then 
    guiSetVisible (planeWindow, true) 
    showCursor (true) 
  end 
end 
addEventHandler ("airLVviewGUI", getRootElement(), airLVviewGUI) 
  
addEvent ("gateLVviewGUI", true) 
function gateLVviewGUI () 
  if (getLocalPlayer() == source) then 
    guiSetVisible (gateLVWindow, true) 
    showCursor (true) 
  end 
end 
addEventHandler ("gateLVviewGUI", getRootElement(), gateLVviewGUI) 
  
addEvent ("gateSFviewGUI", true) 
function gateSFviewGUI () 
  if (getLocalPlayer() == source) then 
    guiSetVisible (gateSFWindow, true) 
    showCursor (true) 
  end 
end 
addEventHandler ("gateSFviewGUI", getRootElement(), gateSFviewGUI) 
  
addEvent ("gateLSviewGUI", true) 
function gateLSviewGUI () 
  if (getLocalPlayer() == source) then 
    guiSetVisible (gateLSWindow, true) 
    showCursor (true) 
  end 
end 
addEventHandler ("gateLSviewGUI", getRootElement(), gateLSviewGUI) 
  
addEvent ("onClientGUIClick", true) 
function onClientGUIClick (button, state, absoluteX, absoluteY) 
if (source == flyButton) then guiSetVisible (planeWindow, false) showCursor (false) 
    if (guiGridListGetSelectedItem (planeGridList)) then 
      local planeID = guiGridListGetItemText (planeGridList, guiGridListGetSelectedItem (planeGridList), 1) 
      triggerServerEvent ("planeSpawn", getLocalPlayer(), planeID) 
    end 
elseif (source == LVtoSFbutton) then guiSetVisible (gateLVWindow, false) showCursor (false) 
    departure = tostring("LV") 
    destination = tostring("SF") 
      triggerServerEvent ("setFlightPlan", getLocalPlayer(), departure, destination) 
elseif (source == LVtoLSbutton) then guiSetVisible (gateLVWindow, false) showCursor (false) 
    departure = tostring("LV") 
    destination = tostring("LS") 
      triggerServerEvent ("setFlightPlan", getLocalPlayer(), departure, destination) 
elseif (source == SFtoLVbutton) then guiSetVisible (gateSFWindow, false) showCursor (false) 
    departure = tostring("SF") 
    destination = tostring("LV") 
      triggerServerEvent ("setFlightPlan", getLocalPlayer(), departure, destination) 
elseif (source == SFtoLSbutton) then guiSetVisible (gateSFWindow, false) showCursor (false) 
    departure = tostring("SF") 
    destination = tostring("LS") 
      triggerServerEvent ("setFlightPlan", getLocalPlayer(), departure, destination) 
elseif (source == LStoLVbutton) then guiSetVisible (gateLSWindow, false) showCursor (false) 
    departure = tostring("LS") 
    destination = tostring("LV") 
      triggerServerEvent ("setFlightPlan", getLocalPlayer(), departure, destination) 
elseif (source == LStoSFbutton) then guiSetVisible (gateLSWindow, false) showCursor (false) 
    departure = tostring("LS") 
    destination = tostring("SF") 
      triggerServerEvent ("setFlightPlan", getLocalPlayer(), departure, destination) 
  end 
  end 
  addEventHandler ("onClientGUIClick", getRootElement(), onClientGUIClick) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...