Jump to content

[help]pilot_job


MoeezKhan

Recommended Posts

hi all I make pilot_job when i press take job but skin not change . please fix it and please make it to show in tab panel.Please read my all fourm i have lot of problem in my script please

----client side-----

local GUIEditor = { 
    memo = {}, 
    button = {}, 
    window = {}, 
} 
  
addEventHandler("onClientResourceStart", getResourceRootElement( getThisResource( )), 
    function() 
        local guiX,guiY = guiGetScreenSize() 
        GUIEditor.window[1] = guiCreateWindow((guiX-500)/2, (guiY-350)/2, 500, 350, "Pilot", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetVisible(GUIEditor.window[1], false) 
         
        bAccept = guiCreateButton(10, 300, 110, 36, "Take job", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[1], "sa-header") 
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") 
        addEventHandler("onClientGUIClick", bAccept, showGUIbf, false) 
        addEventHandler("onClientGUIClick", bAccept, joinTeam, false) 
         
        bClose = guiCreateButton(126, 300, 110, 36, "Cancel", false, GUIEditor.window[1]) 
        guiSetProperty(bClose, "NormalTextColour", "FFAAAAAA")  
        addEventHandler("onClientGUIClick", bClose, showGUIbf, false) 
         
        GUIEditor.memo[1] = guiCreateMemo(10, 30, 480, 264,  
            "Pilot\n".. 
            "Fly around San Andreas and get payed\n" 
            , false, GUIEditor.window[1]) 
        guiEditSetReadOnly(GUIEditor.memo[1],true)   
    end 
) 
local joinBD = createMarker(-1546, -442, 5, "cylinder", 1.5, 255, 200, 0, 50) 
local joinBD2 = createMarker(1958, -2182, 12.5, "cylinder", 1.5, 255, 200, 0, 50) 
local joinBD3 = createMarker(1717, 1615.6, 9, "cylinder", 1.5, 255, 200, 0, 50) 
  
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( )), 
    function ( startedRes ) 
        createBlipAttachedTo( joinBD, 56, 2, 0, 0, 0, 0, 0, 400); 
        createBlipAttachedTo( joinBD2, 56, 2, 0, 0, 0, 0, 0, 400); 
        createBlipAttachedTo( joinBD3, 56, 2, 0, 0, 0, 0, 0, 400); 
    end 
); 
  
function showGUIbt(hitElement) 
    if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
        guiSetVisible(GUIEditor.window[1], true) 
        showCursor( true ) 
    end 
end 
addEventHandler("onClientMarkerHit", joinBD, showGUIbt)  
addEventHandler("onClientMarkerHit", joinBD2, showGUIbt)  
addEventHandler("onClientMarkerHit", joinBD3, showGUIbt)  
function showGUIbf() 
    guiSetVisible (GUIEditor.window[1], false ) 
    showCursor ( false ) 
end 
  
function joinTeam() 
    triggerServerEvent("setTeam", localPlayer, "teamSet") 
end 
  
  
  

----server side---

local pickups = { 
    [1]={ 1985.55078125, -2252.1572265625, 13.722847938538, 103.69232177734 }, 
    [2]={ 1977.173828125, -2306.5771484375, 13.726548194885, 117.84616088867 }, 
    [3]={ 1978.21484375, -2375.298828125, 13.72612285614, 83.032989501953 }, 
    [4]={ 1881.8857421875, -2618.0634765625, 13.723665237427, 354.06594848633 }, 
    [5]={ 1822.025390625, -2616.158203125, 13.72287273407, 1.5384826660156 }, 
    [6]={ 1565.8037109375, -2444.390625, 13.732352256775, 347.20880126953 }, 
    [7]={ 1648.4814453125, -2442.1494140625, 13.746061325073, 311.34066772461 }, 
    [8]={ 1726.4033203125, -2432.03515625, 14.044448852539, 316.79119873047 }, 
    [9]={ 2065.685546875, 312.734375, 34.874977111816, 97.362640380859 }, 
    [10]={ 1317.638671875, 1342.4091796875, 11.03280544281, 6.8132019042969 }, 
    [11]={ 1332.490234375, 1596.5615234375, 10.997436523438, 119.69232177734 }, 
    [12]={ 1475.1220703125, 1813.1171875, 10.996809959412, 5.6703491210938 }, 
    [13]={ 1557.3193359375, 1500.7099609375, 11.015826225281, 30.637359619141 }, 
    [14]={ 1557.189453125, 1360.5888671875, 11.044065475464, 301.23077392578 }, 
    [15]={ 662.484375, 2152.4541015625, 20.68162727356, 355.03295898438 }, 
    [16]={ 401.177734375, 2501.7470703125, 16.6618309021, 84.791229248047 }, 
    [17]={ -40.1162109375, 2505.916015625, 16.770608901978, 89.098907470703 }, 
    [18]={ -1818.6318359375, 2208.9130859375, 17.039325714111, 55.9560546875 }, 
    [19]={ -1694.5498046875, -314.765625, 14.349038124084, 149.84616088867 }, 
    [20]={ -1607.03125, -496.0966796875, 22.264881134033, 229.40660095215 }, 
    [21]={ -1278.2822265625, -591.33984375, 14.32221031189, 14.901123046875 }, 
    [22]={ -1235.732421875, -364.64453125, 14.478247642517, 162.94506835938 }, 
    [23]={ -1312.7216796875, -202.8291015625, 14.327821731567, 135.07693481445 }, 
    [24]={ -1225.6865234375, -12.3369140625, 14.343338012695, 47.164855957031 }, 
    [25]={ -1286.9658203125, 95.5546875, 14.349571228027, 336.39559936523 }, 
} 
  
local dropoffss = { 
    [1]={ 1985.55078125, -2252.1572265625, 13.722847938538, 103.69232177734 }, 
    [2]={ 1977.173828125, -2306.5771484375, 13.726548194885, 117.84616088867 }, 
    [3]={ 1978.21484375, -2375.298828125, 13.72612285614, 83.032989501953 }, 
    [4]={ 1881.8857421875, -2618.0634765625, 13.723665237427, 354.06594848633 }, 
    [5]={ 1822.025390625, -2616.158203125, 13.72287273407, 1.5384826660156 }, 
    [6]={ 1565.8037109375, -2444.390625, 13.732352256775, 347.20880126953 }, 
    [7]={ 1648.4814453125, -2442.1494140625, 13.746061325073, 311.34066772461 }, 
    [8]={ 1726.4033203125, -2432.03515625, 14.044448852539, 316.79119873047 }, 
    [9]={ 2065.685546875, 312.734375, 34.874977111816, 97.362640380859 }, 
    [10]={ 1317.638671875, 1342.4091796875, 11.03280544281, 6.8132019042969 }, 
    [11]={ 1332.490234375, 1596.5615234375, 10.997436523438, 119.69232177734 }, 
    [12]={ 1475.1220703125, 1813.1171875, 10.996809959412, 5.6703491210938 }, 
    [13]={ 1557.3193359375, 1500.7099609375, 11.015826225281, 30.637359619141 }, 
    [14]={ 1557.189453125, 1360.5888671875, 11.044065475464, 301.23077392578 }, 
    [15]={ 662.484375, 2152.4541015625, 20.68162727356, 355.03295898438 }, 
    [16]={ 401.177734375, 2501.7470703125, 16.6618309021, 84.791229248047 }, 
    [17]={ -40.1162109375, 2505.916015625, 16.770608901978, 89.098907470703 }, 
    [18]={ -1818.6318359375, 2208.9130859375, 17.039325714111, 55.9560546875 }, 
    [19]={ -1694.5498046875, -314.765625, 14.349038124084, 149.84616088867 }, 
    [20]={ -1607.03125, -496.0966796875, 22.264881134033, 229.40660095215 }, 
    [21]={ -1278.2822265625, -591.33984375, 14.32221031189, 14.901123046875 }, 
    [22]={ -1235.732421875, -364.64453125, 14.478247642517, 162.94506835938 }, 
    [23]={ -1312.7216796875, -202.8291015625, 14.327821731567, 135.07693481445 }, 
    [24]={ -1225.6865234375, -12.3369140625, 14.343338012695, 47.164855957031 }, 
    [25]={ -1286.9658203125, 95.5546875, 14.349571228027, 336.39559936523 }, 
} 
  
local team = getTeamFromName ( "Civilians" ) 
local planeVeh = { [592] = true, [577] = true, [511] = true, [548] = true, [593] = true, [487] = true, [519] = true, [513] = true, [553] = true, [488] = true, [469] = true } 
  
function teamSet ( ) 
    local team = getTeamFromName ( "Civilians" ) 
    if team and getElementData( client, "Occupation" ) ~= "Pilot" then 
        setPlayerTeam ( client, team ) 
        setPlayerNametagColor ( client, 255, 200, 0 ) 
        setElementData( client, "Occupation", "Pilot", true ) 
        local skinID = 61 
        setElementModel(client, skinID) 
        createBlipAttachedTo ( client, 0, 2, 255, 200, 0, 255, 1 ) 
        exports["AC_message"]:outputTopBar( "You are now a pilot!", client, 0, 255, 0 ) 
    else 
        exports["AC_message"]:outputTopBar( "You are already a pilot!", client, 255, 0, 0 ) 
    end 
end 
addEvent ( "setTeam", true) 
addEventHandler ( "setTeam", root, teamSet ) 
  
local markers = { } 
local blips = { } 
mposi = { } 
mposii = {} 
  
function startJob ( thePlayer ) 
    local x,y,z,r = 0,0,0,0 
    local px,py,pz = getElementPosition( thePlayer ) 
    repeat 
          x,y,z,r = unpack( pickups[math.random ( #pickups )]) 
    until getDistanceBetweenPoints3D( px,py,pz, x,y,z ) > 800 
    markers[thePlayer] = createMarker( x, y, z, "cylinder", 5.0, 255, 255, 255, 30 ) 
    mposi = { getElementPosition( markers[thePlayer] ) }  
    blips[thePlayer] = createBlipAttachedTo( markers [ thePlayer ], 41, 2, 0, 0, 0, 255, 3, 9999999, thePlayer )  
    addEventHandler( "onMarkerHit", markers[thePlayer], warpit ) 
    exports["AC_message"]:outputTopBar("Fly to the next location at: "..getZoneName(x,y,z), thePlayer, 0, 255, 0) 
end 
local taximeter = {} 
function inVEH ( thePlayer, seat, jacked ) 
    if ( getElementType( thePlayer ) == "player" and isPedInVehicle( thePlayer ) ) and  
        seat == 0 and getElementData( thePlayer, "Occupation" ) == "Pilot" then 
        if ( planeVeh[getElementModel( source )] ) then 
            startJob ( thePlayer ) 
        end 
    end 
    -- Enable the taximeter 
    if getElementType ( thePlayer ) == "player" then 
        if ( planeVeh[getElementModel( source )] ) and seat > 0 then 
            drivers = getVehicleOccupants ( source )  
            payForTaxi( drivers[0], thePlayer )  
            if isTimer( taximeter[thePlayer] ) then 
                killTimer( taximeter[thePlayer] ) 
            end          
            taximeter[thePlayer] = setTimer( payForTaxi, 60000, 0, drivers[0], thePlayer ) 
        end 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), inVEH ) 
  
function payForTaxi( driver, passenger ) 
    if isElement( passenger ) then 
        if getPlayerMoney( passenger ) > 55 then 
            local theVehicle = getPedOccupiedVehicle( driver ) 
            if isElement( driver ) and isElement( passenger ) and isElement( theVehicle ) and 
                getVehicleOccupant ( theVehicle, 0 ) == driver and getElementData( driver, "Occupation" ) == "Pilot" then 
                takePlayerMoney( passenger, 55 ) 
                givePlayerMoney( driver, 55 ) 
            end 
        else 
            removePedFromVehicle( passenger ) 
            if isElement( taximeter[thePlayer] ) then 
                destroyElement( taximeter[thePlayer] ) 
            end 
            exports["AC_message"]:outputTopBar( "You can't afford this flight anymore, GET OUT!", passenger, 255, 0, 0 ) 
        end 
    end 
end 
  
function stopPaymentTaxi ( thePlayer, seat, jacked ) 
    if isTimer( taximeter[thePlayer] ) then 
        killTimer( taximeter[thePlayer] ) 
    end 
end 
addEventHandler ( "onVehicleExit", getRootElement(), stopPaymentTaxi ) 
  
function warpit( thePlayer ) 
    if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then 
        local vehicle = getPedOccupiedVehicle ( thePlayer ) 
        if ( planeVeh[getElementModel( vehicle )] ) then 
            destroyJob ( thePlayer ) 
            local x, y, z, r = unpack( dropoffss[math.random( #dropoffss )]) 
            markers[thePlayer] = createMarker( x, y, z - 1, "cylinder", 5.0, 255, 255, 255, 30 ) 
            mposii = { getElementPosition( markers[thePlayer]) } 
            blips[thePlayer] = createBlipAttachedTo( markers [thePlayer], 41, 2, 0, 0, 0, 255, 3, 9999999, thePlayer ) 
            addEventHandler( "onMarkerHit", markers[thePlayer], pickmeup ) 
            exports["AC_message"]:outputTopBar("Loading passengers...", thePlayer, 0, 255, 0) 
            setTimer( setElementFrozen, 1000, 1, getPedOccupiedVehicle(thePlayer), true ) 
            setTimer( setElementFrozen, 10000, 1, getPedOccupiedVehicle(thePlayer), false ) 
            setTimer( flyTo, 10000, 1, thePlayer, x,y,z) 
        end 
    end 
end 
  
function pickmeup ( thePlayer ) 
    if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then 
        destroyJob ( thePlayer ) 
        local mx, my, mz = unpack ( mposi ) 
        local mmx, mmy, mmz = unpack ( mposii ) 
        local money = getDistanceBetweenPoints2D ( mx, my, mmx, mmy ) 
        finalmoney = math.floor ( money/5 ) 
        fine = math.floor(finalmoney - (finalmoney*(1-( getElementHealth( getPedOccupiedVehicle( thePlayer ))/1000)))) 
        if finalmoney then 
            givePlayerMoney( thePlayer, fine ) 
            exports["AC_message"]:outputTopBar("You have earned ".. tostring(fine) .."$!", thePlayer, 0, 255, 0) 
            if (finalmoney - fine) > 0 then 
                exports["AC_message"]:outputTopBar("Removed ".. tostring(finalmoney - fine) .."$ due to damaged plane!", thePlayer, 255, 0, 0) 
            end 
            setTimer( function( ) 
            startJob ( thePlayer ) end , 1000, 1 ) 
            setTimer( setElementFrozen, 1000, 1, getPedOccupiedVehicle(thePlayer), true ) 
            setTimer( setElementFrozen, 10000, 1, getPedOccupiedVehicle(thePlayer), false ) 
        end 
    end 
end 
  
function deleteOnExit ( thePlayer ) 
    if ( isElement ( markers [ thePlayer ] ) ) then 
        destroyElement ( markers [ thePlayer ] ) 
    end 
    if ( isElement ( blips [ thePlayer ] ) ) then 
        destroyElement ( blips [ thePlayer ] ) 
    end 
    if isElement( taximeter[thePlayer] ) then 
        killTimer( taximeter[thePlayer] ) 
    end 
end 
addEventHandler ( "onVehicleExit", getRootElement(), deleteOnExit ) 
  
function destroyJob ( thePlayer ) 
    if ( isElement ( markers [ thePlayer ] ) ) then 
        destroyElement ( markers [ thePlayer ] ) 
    end 
    if ( isElement ( blips [ thePlayer ] ) ) then 
        destroyElement( blips [ thePlayer ] ) 
    end 
end 
  
function flyTo(thePlayer,x,y,z) 
    exports["AC_message"]:outputTopBar("Take the passengers to: "..getZoneName(x,y,z), thePlayer, 0, 255, 0) 
end 
  
  

Link to comment

SERVER:

  
local pickups = { 
    [1]={ 1985.55078125, -2252.1572265625, 13.722847938538, 103.69232177734 }, 
    [2]={ 1977.173828125, -2306.5771484375, 13.726548194885, 117.84616088867 }, 
    [3]={ 1978.21484375, -2375.298828125, 13.72612285614, 83.032989501953 }, 
    [4]={ 1881.8857421875, -2618.0634765625, 13.723665237427, 354.06594848633 }, 
    [5]={ 1822.025390625, -2616.158203125, 13.72287273407, 1.5384826660156 }, 
    [6]={ 1565.8037109375, -2444.390625, 13.732352256775, 347.20880126953 }, 
    [7]={ 1648.4814453125, -2442.1494140625, 13.746061325073, 311.34066772461 }, 
    [8]={ 1726.4033203125, -2432.03515625, 14.044448852539, 316.79119873047 }, 
    [9]={ 2065.685546875, 312.734375, 34.874977111816, 97.362640380859 }, 
    [10]={ 1317.638671875, 1342.4091796875, 11.03280544281, 6.8132019042969 }, 
    [11]={ 1332.490234375, 1596.5615234375, 10.997436523438, 119.69232177734 }, 
    [12]={ 1475.1220703125, 1813.1171875, 10.996809959412, 5.6703491210938 }, 
    [13]={ 1557.3193359375, 1500.7099609375, 11.015826225281, 30.637359619141 }, 
    [14]={ 1557.189453125, 1360.5888671875, 11.044065475464, 301.23077392578 }, 
    [15]={ 662.484375, 2152.4541015625, 20.68162727356, 355.03295898438 }, 
    [16]={ 401.177734375, 2501.7470703125, 16.6618309021, 84.791229248047 }, 
    [17]={ -40.1162109375, 2505.916015625, 16.770608901978, 89.098907470703 }, 
    [18]={ -1818.6318359375, 2208.9130859375, 17.039325714111, 55.9560546875 }, 
    [19]={ -1694.5498046875, -314.765625, 14.349038124084, 149.84616088867 }, 
    [20]={ -1607.03125, -496.0966796875, 22.264881134033, 229.40660095215 }, 
    [21]={ -1278.2822265625, -591.33984375, 14.32221031189, 14.901123046875 }, 
    [22]={ -1235.732421875, -364.64453125, 14.478247642517, 162.94506835938 }, 
    [23]={ -1312.7216796875, -202.8291015625, 14.327821731567, 135.07693481445 }, 
    [24]={ -1225.6865234375, -12.3369140625, 14.343338012695, 47.164855957031 }, 
    [25]={ -1286.9658203125, 95.5546875, 14.349571228027, 336.39559936523 }, 
} 
  
local dropoffss = { 
    [1]={ 1985.55078125, -2252.1572265625, 13.722847938538, 103.69232177734 }, 
    [2]={ 1977.173828125, -2306.5771484375, 13.726548194885, 117.84616088867 }, 
    [3]={ 1978.21484375, -2375.298828125, 13.72612285614, 83.032989501953 }, 
    [4]={ 1881.8857421875, -2618.0634765625, 13.723665237427, 354.06594848633 }, 
    [5]={ 1822.025390625, -2616.158203125, 13.72287273407, 1.5384826660156 }, 
    [6]={ 1565.8037109375, -2444.390625, 13.732352256775, 347.20880126953 }, 
    [7]={ 1648.4814453125, -2442.1494140625, 13.746061325073, 311.34066772461 }, 
    [8]={ 1726.4033203125, -2432.03515625, 14.044448852539, 316.79119873047 }, 
    [9]={ 2065.685546875, 312.734375, 34.874977111816, 97.362640380859 }, 
    [10]={ 1317.638671875, 1342.4091796875, 11.03280544281, 6.8132019042969 }, 
    [11]={ 1332.490234375, 1596.5615234375, 10.997436523438, 119.69232177734 }, 
    [12]={ 1475.1220703125, 1813.1171875, 10.996809959412, 5.6703491210938 }, 
    [13]={ 1557.3193359375, 1500.7099609375, 11.015826225281, 30.637359619141 }, 
    [14]={ 1557.189453125, 1360.5888671875, 11.044065475464, 301.23077392578 }, 
    [15]={ 662.484375, 2152.4541015625, 20.68162727356, 355.03295898438 }, 
    [16]={ 401.177734375, 2501.7470703125, 16.6618309021, 84.791229248047 }, 
    [17]={ -40.1162109375, 2505.916015625, 16.770608901978, 89.098907470703 }, 
    [18]={ -1818.6318359375, 2208.9130859375, 17.039325714111, 55.9560546875 }, 
    [19]={ -1694.5498046875, -314.765625, 14.349038124084, 149.84616088867 }, 
    [20]={ -1607.03125, -496.0966796875, 22.264881134033, 229.40660095215 }, 
    [21]={ -1278.2822265625, -591.33984375, 14.32221031189, 14.901123046875 }, 
    [22]={ -1235.732421875, -364.64453125, 14.478247642517, 162.94506835938 }, 
    [23]={ -1312.7216796875, -202.8291015625, 14.327821731567, 135.07693481445 }, 
    [24]={ -1225.6865234375, -12.3369140625, 14.343338012695, 47.164855957031 }, 
    [25]={ -1286.9658203125, 95.5546875, 14.349571228027, 336.39559936523 }, 
} 
  
local team = getTeamFromName ( "Civilians" ) 
local planeVeh = { [592] = true, [577] = true, [511] = true, [548] = true, [593] = true, [487] = true, [519] = true, [513] = true, [553] = true, [488] = true, [469] = true } 
  
function teamSet ( ) 
    local team = getTeamFromName ( "Civilians" ) 
    if team and getElementData( client, "Occupation" ) ~= "Pilot" then 
    setPlayerTeam ( thePlayer, Civilians ) 
        setPlayerNametagColor ( client, 255, 200, 0 ) 
        setElementData( client, "Occupation", "Pilot", true ) 
        local skinID = 61 
        setElementModel(client, skinID) 
        createBlipAttachedTo ( client, 0, 2, 255, 200, 0, 255, 1 ) 
        exports["AC_message"]:outputTopBar( "You are now a pilot!", client, 0, 255, 0 ) 
    else 
        exports["AC_message"]:outputTopBar( "You are already a pilot!", client, 255, 0, 0 ) 
    end 
end 
addEvent ( "setTeam", true) 
addEventHandler ( "setTeam", root, teamSet ) 
  
local markers = { } 
local blips = { } 
mposi = { } 
mposii = {} 
  
function startJob ( thePlayer ) 
    local x,y,z,r = 0,0,0,0 
    local px,py,pz = getElementPosition( thePlayer ) 
    repeat 
          x,y,z,r = unpack( pickups[math.random ( #pickups )]) 
    until getDistanceBetweenPoints3D( px,py,pz, x,y,z ) > 800 
    markers[thePlayer] = createMarker( x, y, z, "cylinder", 5.0, 255, 255, 255, 30 ) 
    mposi = { getElementPosition( markers[thePlayer] ) } 
    blips[thePlayer] = createBlipAttachedTo( markers [ thePlayer ], 41, 2, 0, 0, 0, 255, 3, 9999999, thePlayer ) 
    addEventHandler( "onMarkerHit", markers[thePlayer], warpit ) 
    exports["AC_message"]:outputTopBar("Fly to the next location at: "..getZoneName(x,y,z), thePlayer, 0, 255, 0) 
end 
local taximeter = {} 
function inVEH ( thePlayer, seat, jacked ) 
    if ( getElementType( thePlayer ) == "player" and isPedInVehicle( thePlayer ) ) and 
        seat == 0 and getElementData( thePlayer, "Occupation" ) == "Pilot" then 
        if ( planeVeh[getElementModel( source )] ) then 
            startJob ( thePlayer ) 
        end 
    end 
    -- Enable the taximeter 
    if getElementType ( thePlayer ) == "player" then 
        if ( planeVeh[getElementModel( source )] ) and seat > 0 then 
            drivers = getVehicleOccupants ( source ) 
            payForTaxi( drivers[0], thePlayer )  
            if isTimer( taximeter[thePlayer] ) then 
                killTimer( taximeter[thePlayer] ) 
            end         
            taximeter[thePlayer] = setTimer( payForTaxi, 60000, 0, drivers[0], thePlayer ) 
        end 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), inVEH ) 
  
function payForTaxi( driver, passenger ) 
    if isElement( passenger ) then 
        if getPlayerMoney( passenger ) > 55 then 
            local theVehicle = getPedOccupiedVehicle( driver ) 
            if isElement( driver ) and isElement( passenger ) and isElement( theVehicle ) and 
                getVehicleOccupant ( theVehicle, 0 ) == driver and getElementData( driver, "Occupation" ) == "Pilot" then 
                takePlayerMoney( passenger, 55 ) 
                givePlayerMoney( driver, 55 ) 
            end 
        else 
            removePedFromVehicle( passenger ) 
            if isElement( taximeter[thePlayer] ) then 
                destroyElement( taximeter[thePlayer] ) 
            end 
            exports["AC_message"]:outputTopBar( "You can't afford this flight anymore, GET OUT!", passenger, 255, 0, 0 ) 
        end 
    end 
end 
  
function stopPaymentTaxi ( thePlayer, seat, jacked ) 
    if isTimer( taximeter[thePlayer] ) then 
        killTimer( taximeter[thePlayer] ) 
    end 
end 
addEventHandler ( "onVehicleExit", getRootElement(), stopPaymentTaxi ) 
  
function warpit( thePlayer ) 
    if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then 
        local vehicle = getPedOccupiedVehicle ( thePlayer ) 
        if ( planeVeh[getElementModel( vehicle )] ) then 
            destroyJob ( thePlayer ) 
            local x, y, z, r = unpack( dropoffss[math.random( #dropoffss )]) 
            markers[thePlayer] = createMarker( x, y, z - 1, "cylinder", 5.0, 255, 255, 255, 30 ) 
            mposii = { getElementPosition( markers[thePlayer]) } 
            blips[thePlayer] = createBlipAttachedTo( markers [thePlayer], 41, 2, 0, 0, 0, 255, 3, 9999999, thePlayer ) 
            addEventHandler( "onMarkerHit", markers[thePlayer], pickmeup ) 
            exports["AC_message"]:outputTopBar("Loading passengers...", thePlayer, 0, 255, 0) 
            setTimer( setElementFrozen, 1000, 1, getPedOccupiedVehicle(thePlayer), true ) 
            setTimer( setElementFrozen, 10000, 1, getPedOccupiedVehicle(thePlayer), false ) 
            setTimer( flyTo, 10000, 1, thePlayer, x,y,z) 
        end 
    end 
end 
  
function pickmeup ( thePlayer ) 
    if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then 
        destroyJob ( thePlayer ) 
        local mx, my, mz = unpack ( mposi ) 
        local mmx, mmy, mmz = unpack ( mposii ) 
        local money = getDistanceBetweenPoints2D ( mx, my, mmx, mmy ) 
        finalmoney = math.floor ( money/5 ) 
        fine = math.floor(finalmoney - (finalmoney*(1-( getElementHealth( getPedOccupiedVehicle( thePlayer ))/1000)))) 
        if finalmoney then 
            givePlayerMoney( thePlayer, fine ) 
            exports["AC_message"]:outputTopBar("You have earned ".. tostring(fine) .."$!", thePlayer, 0, 255, 0) 
            if (finalmoney - fine) > 0 then 
                exports["AC_message"]:outputTopBar("Removed ".. tostring(finalmoney - fine) .."$ due to damaged plane!", thePlayer, 255, 0, 0) 
            end 
            setTimer( function( ) 
            startJob ( thePlayer ) end , 1000, 1 ) 
            setTimer( setElementFrozen, 1000, 1, getPedOccupiedVehicle(thePlayer), true ) 
            setTimer( setElementFrozen, 10000, 1, getPedOccupiedVehicle(thePlayer), false ) 
        end 
    end 
end 
  
function deleteOnExit ( thePlayer ) 
    if ( isElement ( markers [ thePlayer ] ) ) then 
        destroyElement ( markers [ thePlayer ] ) 
    end 
    if ( isElement ( blips [ thePlayer ] ) ) then 
        destroyElement ( blips [ thePlayer ] ) 
    end 
    if isElement( taximeter[thePlayer] ) then 
        killTimer( taximeter[thePlayer] ) 
    end 
end 
addEventHandler ( "onVehicleExit", getRootElement(), deleteOnExit ) 
  
function destroyJob ( thePlayer ) 
    if ( isElement ( markers [ thePlayer ] ) ) then 
        destroyElement ( markers [ thePlayer ] ) 
    end 
    if ( isElement ( blips [ thePlayer ] ) ) then 
        destroyElement( blips [ thePlayer ] ) 
    end 
end 
  
function flyTo(thePlayer,x,y,z) 
    exports["AC_message"]:outputTopBar("Take the passengers to: "..getZoneName(x,y,z), thePlayer, 0, 255, 0) 
end 
  
  
  
function destroyJob ( thePlayer ) 
    if ( isElement ( markers [ thePlayer ] ) ) then 
        destroyElement ( markers [ thePlayer ] ) 
    end 
    if ( isElement ( blips [ thePlayer ] ) ) then 
        destroyElement( blips [ thePlayer ] ) 
    end 
end 
  
function flyTo(thePlayer,x,y,z) 
    exports["AC_message"]:outputTopBar("Take the passengers to: "..getZoneName(x,y,z), thePlayer, 0, 255, 0) 
end 
  
  
  

CLIENT

  
local GUIEditor = { 
    memo = {}, 
    button = {}, 
    window = {}, 
} 
  
addEventHandler("onClientResourceStart", getResourceRootElement( getThisResource( )), 
    function() 
        local guiX,guiY = guiGetScreenSize() 
        GUIEditor.window[1] = guiCreateWindow((guiX-500)/2, (guiY-350)/2, 500, 350, "Pilot", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetVisible(GUIEditor.window[1], false) 
        
        bAccept = guiCreateButton(10, 300, 110, 36, "Take job", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[1], "sa-header") 
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") 
        addEventHandler("onClientGUIClick", bAccept, showGUIbf, false) 
        addEventHandler("onClientGUIClick", bAccept, joinTeam, false) 
        
        bClose = guiCreateButton(126, 300, 110, 36, "Cancel", false, GUIEditor.window[1]) 
        guiSetProperty(bClose, "NormalTextColour", "FFAAAAAA") 
        addEventHandler("onClientGUIClick", bClose, showGUIbf, false) 
        
        GUIEditor.memo[1] = guiCreateMemo(10, 30, 480, 264, 
            "Pilot\n".. 
            "Fly around San Andreas and get payed\n" 
            , false, GUIEditor.window[1]) 
        guiEditSetReadOnly(GUIEditor.memo[1],true)  
    end 
) 
local joinBD = createMarker(-1546, -442, 5, "cylinder", 1.5, 255, 200, 0, 50) 
local joinBD2 = createMarker(1958, -2182, 12.5, "cylinder", 1.5, 255, 200, 0, 50) 
local joinBD3 = createMarker(1717, 1615.6, 9, "cylinder", 1.5, 255, 200, 0, 50) 
  
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( )), 
    function ( startedRes ) 
        createBlipAttachedTo( joinBD, 56, 2, 0, 0, 0, 0, 0, 400); 
        createBlipAttachedTo( joinBD2, 56, 2, 0, 0, 0, 0, 0, 400); 
        createBlipAttachedTo( joinBD3, 56, 2, 0, 0, 0, 0, 0, 400); 
    end 
); 
  
function showGUIbt(hitElement) 
    if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
        guiSetVisible(GUIEditor.window[1], true) 
        showCursor( true ) 
    end 
end 
addEventHandler("onClientMarkerHit", joinBD, showGUIbt) 
addEventHandler("onClientMarkerHit", joinBD2, showGUIbt) 
addEventHandler("onClientMarkerHit", joinBD3, showGUIbt) 
function showGUIbf() 
    guiSetVisible (GUIEditor.window[1], false ) 
    showCursor ( false ) 
end 
  
function joinTeam() 
    triggerServerEvent("setTeam", localPlayer) 
end 
  
  
  
  

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...