Jump to content

[help]taxi_job


MoeezKhan

Recommended Posts

hi all I make taxi_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, "Taxi Driver", 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,  
            "Taxi Driver\n".. 
            "Get a taxi or cabbie and start to transport people around the city, ".. 
            "players and peds that requested a taxi will be marked with a person ".. 
            "icon so you can find them easy. \nPayment is depending on distance ".. 
            "and remember to keep your car in good shape and don´t crash, otherwise ".. 
            "your payment will be reduced.\n" 
            , false, GUIEditor.window[1]) 
        guiEditSetReadOnly(GUIEditor.memo[1],true)   
    end 
) 
local joinBD = createMarker(-1395, -326, 13, "cylinder", 1.5, 255, 200, 0, 50) 
local joinBD2 = createMarker(1681, -2328, 12.5, "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); 
    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)  
function showGUIbf() 
    guiSetVisible (GUIEditor.window[1], false ) 
    showCursor ( false ) 
end 
  
function joinTeam() 
    triggerServerEvent("sTeame", localPlayer, "teamSet") 
end 
  

----server side-----

local pickups = { 
    -- Los santos
    [1]={ 2060.7685546875, -1941.1181640625, 13.14103603363, 0 },
    [2]={ 2114.5068359375, -1611.302734375, 13.167269706726, 0 },
    [3]={ 1932.9521484375, -1776.1259765625, 13.16081237793, 0 },
    [4]={ 1057.41796875, -1568.4853515625, 13.166387557983, 0 },
    [5]={ 1133.2607421875, -1286.6201171875, 13.245727539063, 0 },
    [6]={ 1197.380859375, -1576.9228515625, 13.2406873703, 0 },
    [7]={ 1275.6181640625, -1717.5087890625, 13.241578102112, 0 },
    [8]={ 1041.908203125, -1869.1728515625, 13.15417766571, 0 },
    [9]={ 680.9248046875, -1763.6552734375, 13.168544769287, 0 },
    [10]={ 597.5556640625, -1598.90234375, 16.215705871582, 0 },
    [11]={ 357.197265625, -1443.72265625, 34.185447692871, 0 },
   
    -- San fierro
    [12]={ -1994.7431640625, -791.5244140625, 32.171875, 271.03408813477 },
    [13]={ -1963.4423828125, -1011.4267578125, 32.171875, 358.5305480957 },
    [14]={ -1944.32421875, -999.3662109375, 32.171493530273, 179.97802734375 },
    [15]={ -2245.8623046875, -93.220703125, 35.3203125, 92.140991210938 },
    [16]={ -2266.119140625, -154.056640625, 35.3203125, 268.90270996094 },
    [17]={ -2245.78125, 132.865234375, 35.3203125, 146.93063354492 },
    [18]={ -2245.7216796875, 258.095703125, 35.3203125, 142.64041137695 },
    [19]={ -2418.998046875, 333.048828125, 35.178676605225, 282.47103881836 },
    [20]={ -2698.3173828125, 624.154296875, 14.453125, 266.00228881836 },
    [21]={ -2573.623046875, 802.3056640625, 49.984375, 67.119262695313 },
    [22]={ -2378.099609375, 910.8759765625, 45.4453125, 129.11056518555 },
    [23]={ -2133.0947265625, 989.701171875, 80, 130.75305175781 },
    [24]={ -1958.0361328125, 1186.9833984375, 45.4453125, 233.80087280273 },
    [25]={ -1641.814453125, 1266.8388671875, 7.1797361373901, 182.0325012207 },
    [26]={ -1638.9267578125, 1209.4814453125, 7.1796875, 15.438781738281 },
    [27]={ -1567.83203125, 680.7314453125, 7.1875, 324.58776855469 },
    [28]={ -1708.0625, 357.615234375, 7.1875, 272.58319091797 },
    [29]={ -1805.083984375, -139.1630859375, 6.320643901825, 318.3694152832 },
    [30]={ -1448.0556640625, -278.203125, 14.141115188599, 221.71571350098 }
}
 
local dropoffss = {
    -- Los santos
    [1]={ 1965.54296875 , -1883.013671875, 13.160305023193, 0 },
    [2]={ 1467.3916015625, -1736.419921875, 13.242918014526, 0 },
    [3]={ 2376.1064453125, -1728.4091796875, 13.162055015564, 0 },
    [4]={ 1066.5029296875, -1200.86328125, 18.405519485474, 0 },
    [5]={ 584.8916015625, -1328.7021484375, 13.25985622406, 0 },
    [6]={ 989.75, -1372.083984375, 13.244333267212, 0 },
    [7]={ 1116.333984375, -1410.7666015625, 13.267498970032, 0 },
    [8]={ 1437.5244140625, -1039.8212890625, 23.564819335938, 0 },
    [9]={ 2124.4521484375, -1116.4931640625, 25.031726837158, 0 },
    [10]={ 2700.8857421875, -1091.896484375, 69.064071655273, 0 },
    [11]={ 2769.2744140625, -1494.0517578125, 27.58003616333, 0 },
   
    -- San fierro   
    [12]={ -1994.7431640625, -791.5244140625, 32.171875, 271.03408813477 },
    [13]={ -1963.4423828125, -1011.4267578125, 32.171875, 358.5305480957 },
    [14]={ -1944.32421875, -999.3662109375, 32.171493530273, 179.97802734375 },
    [15]={ -2245.8623046875, -93.220703125, 35.3203125, 92.140991210938 },
    [16]={ -2266.119140625, -154.056640625, 35.3203125, 268.90270996094 },
    [17]={ -2245.78125, 132.865234375, 35.3203125, 146.93063354492 },
    [18]={ -2245.7216796875, 258.095703125, 35.3203125, 142.64041137695 },
    [19]={ -2418.998046875, 333.048828125, 35.178676605225, 282.47103881836 },
    [20]={ -2698.3173828125, 624.154296875, 14.453125, 266.00228881836 },
    [21]={ -2573.623046875, 802.3056640625, 49.984375, 67.119262695313 },
    [22]={ -2378.099609375, 910.8759765625, 45.4453125, 129.11056518555 },
    [23]={ -2133.0947265625, 989.701171875, 80, 130.75305175781 },
    [24]={ -1958.0361328125, 1186.9833984375, 45.4453125, 233.80087280273 },
    [25]={ -1641.814453125, 1266.8388671875, 7.1797361373901, 182.0325012207 },
    [26]={ -1638.9267578125, 1209.4814453125, 7.1796875, 15.438781738281 },
    [27]={ -1567.83203125, 680.7314453125, 7.1875, 324.58776855469 },
    [28]={ -1708.0625, 357.615234375, 7.1875, 272.58319091797 },
    [29]={ -1805.083984375, -139.1630859375, 6.320643901825, 318.3694152832 },
    [30]={ -1448.0556640625, -278.203125, 14.141115188599, 221.71571350098 }
}
 
local pedCus = {
    [1]={ 9 },
    [2]={ 10 },
    [3]={ 14 },
    [4]={ 15 },
    [5]={ 37 },
    [6]={ 29 },
    [7]={ 31 },
    [8]={ 22 },
    [9]={ 23 },
    [10]={ 44 },
    [11]={ 43 },
    [12]={ 47 },
    [13]={ 54 },
    [14]={ 56 }
}
local team = getTeamFromName ( "Civilians" )
local taxiVehs = { [420] = true, [438] = true }
 
function teamSet ( )
    setElementData( client, "Occupation", "Taxi Driver", true )
    local team = getTeamFromName ( "Civilians" )
    if team then
        setPlayerTeam( client, team )
        setPlayerNametagColor ( client, 255, 200, 0 )
        local skinID = exports["AC_clothes"]:getBoughtSkin ( client ) or getElementModel( client ) or 0
        setElementModel(client, skinID)
        createBlipAttachedTo ( client, 0, 2, 255, 200, 0, 255, 1 )
        exports["AC_message"]:outputTopBar( "You are now employed as a Taxi Driver!", client, 0, 255, 0 )
    else
        local teamw = getTeamFromName ( "Civilians" )
        if teamw then
            cancelEvent()
            exports["AC_message"]:outputTopBar( "You are already a Taxi driver!", client, 255, 255, 0 )
        end
    end
end
addEvent ( "sTeame", true)
addEventHandler ( "sTeame", root, teamSet )
 
-- Vehicle enter
passengerBlips = { }
driversBlips = { }
function enterVehicle( thePlayer, seat, jacked )
    if getElementType( thePlayer ) == "player" then
        -- Is this really needed? - Nope
        --if ( taxiVehs[getElementModel ( source )] ) and getElementData( thePlayer, "Occupation" ) ~= "Taxi Driver" and seat == 0 then
        --    exports["AC_message"]:outputTopBar( "Only Taxi Drivers can drive this vehicle!", thePlayer, 255, 0, 0)
        --    cancelEvent()
        --end
        -- Public transportation
        if seat > 0 then
            if isElement( driversBlips[getVehicleOccupants( source )[0]] ) then
                destroyElement( driversBlips[getVehicleOccupants( source )[0]] )
            end
            if isElement( passengerBlips[thePlayer] ) then
                destroyElement( passengerBlips[thePlayer] )
            end
        end
    end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle )
 
function notePublicTransport( source, cmd )
    local counter = 0
    local players = getElementsByType ( "player" )
    for k,player in ipairs(players) do
        local ptTeam = getTeamFromName( "Civilians" )
        if ( ptTeam == getPlayerTeam( player ) and ( getElementData( player, "Occupation" ) == "Taxi Driver" or
            getElementData( player, "Occupation" ) == "Pilot" or getElementData( player, "Occupation" ) == "Bus Driver" )) then
            if isElement( getPedOccupiedVehicle( player )) then
                counter = (counter + 1)
                local x,y,z = getElementPosition( source )
                exports["AC_message"]:outputTopBar( getPlayerName( source ).." has called for transportation at: "..getZoneName(x,y,z), player, 0, 255, 0)
                outputChatBox( getPlayerName( source ).." has called for transportation at: "..getZoneName(x,y,z), player, 0, 150, 0)
                if isElement( driversBlips[player] ) then
                    destroyElement( driversBlips[player] )
                end
                if isElement( passengerBlips[source] ) then
                    destroyElement( passengerBlips[source] )
                end
                driversBlips[player] = createBlipAttachedTo( player, 59, 2, 0, 0, 0, 255, 10, 999999, source )
                passengerBlips[source] = createBlipAttachedTo( source, 59, 2, 0, 0, 0, 255, 10, 999999, player )
            end
        end
    end
    if counter > 0 then
        exports["AC_message"]:outputTopBar( "Your message has been sent to "..tostring(counter).." drivers", source, 0, 255, 0)
        outputChatBox( "Your message has been sent to "..tostring(counter).." drivers", source, 0, 150, 0)
    else
        exports["AC_message"]:outputTopBar( "There is no drivers available now, please try again later", source, 255, 0, 0)
    end
end
addCommandHandler( "taxi", notePublicTransport )
addCommandHandler( "pilot", notePublicTransport )
addCommandHandler( "bus", notePublicTransport )
 
local markers = { }
local blips = { }
local peds = { }
mposi = { }
mposii = {}
 
function startJob ( thePlayer )
    local limU, limL = 0, 0
    if getElementData( thePlayer, "Location") == "SF" then
        limL = 12
        limU = 30
    elseif getElementData( thePlayer, "Location") == "LS" then
        limL = 1
        limU = 11
    else
        limL = 12
        limU = 30
    end
   
    local x, y, z, r = unpack ( pickups [ math.random ( limL, limU ) ] )
    markers [ thePlayer ] = createMarker ( x, y, z, "cylinder", 5.0, 255, 0, 0, 0 )
    mposi = { getElementPosition( markers [ thePlayer ] ) }
    local skins = unpack ( pedCus [ math.random ( #pedCus ) ] )
    -- Clean up old peds and blips
    if isElement( peds[thePlayer] ) then destroyElement( peds[thePlayer] ) end
    if isElement( blips[thePlayer] ) then destroyElement( blips[thePlayer] ) end
    peds[thePlayer] = createPed( skins, x, y, z, r, false )  
    blips[thePlayer] = createBlipAttachedTo ( markers [ thePlayer ], 62, 2, 0, 0, 0, 255, 3, 99999, thePlayer )
    addEventHandler ( "onMarkerHit", markers [ thePlayer ], warpit )
end
local taximeter = {}
function inVEH ( thePlayer, seat, jacked )
    if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) and seat == 0 then
        if ( getElementModel ( source ) == 420 or getElementModel ( source ) == 438 ) then
            startJob ( thePlayer )
        end
    end
    -- Enable the taximeter
    if getElementType ( thePlayer ) == "player" then
        if ( taxiVehs[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( driver ) and isElement( passenger ) then
        if getPlayerMoney( passenger ) > 30 and getElementData( driver, "Occupation" ) == "Taxi Driver" then
            local theVehicle = getPedOccupiedVehicle( driver )
            if isElement( theVehicle ) and
                getVehicleOccupant ( theVehicle, 0 ) == driver then
                takePlayerMoney( passenger, 30 )
                givePlayerMoney( driver, 30 )
            end
        else
            removePedFromVehicle ( passenger )
            if isElement( taximeter[thePlayer] ) then
                destroyElement( taximeter[thePlayer] )
            end
            exports["AC_message"]:outputTopBar( "You can't afford this taxi ride anymore!", passenger, 255, 0, 0 )
        end
    end
end
 
function warpit ( thePlayer )
    if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then
        local vehiclee = getPedOccupiedVehicle ( thePlayer )
        if ( getElementModel ( vehiclee ) == 420 or getElementModel ( vehiclee ) == 438 ) then
            setTimer ( warpPedIntoVehicle, 2000, 1, peds [ thePlayer ], vehiclee, 2 )
            destroyJob ( thePlayer )
           
            local limU,limL = 12,30
            if getElementData( thePlayer, "Location") == "SF" then
                limL = 12
                limU = 30
            elseif
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...