Jump to content

PEDS


#Ivan7

Recommended Posts

Ok I finished the script only problem is the Peds wont warp in vechile when I hit H, I did bindkey but it wont work :/

ServerSide:

  local pickups = { 
    { -2514.2985839844, -19.26721572876, 25.6171875 }, 
    { -2413.8093261719, 314.66299438477, 35.171875 }, 
    { -1980.0808105469, 884.00354003906, 45.203125 }, 
    { -1584.2047119141, 812.43743896484, 6.8203125 }, 
    { -1817.1701660516, 1286.7491455078, 15.492509841919 }, 
    { -2343.4348144531, 983.23840322031, 50.6953125 }, 
    { -2554.942629531,  193.716659548, 6.2031769752502 } 
    } 
      
    local dropoffss = { 
    { -2275.2744140625, 612.84197998047, 43.402828216553 }, 
    { -2566.2153320313, 578.38897705078, 14.453125 }, 
    { -2128.4689941406, 310.44934082031, 35.254566192627 }, 
    { -1702.652941016, 717.54370117188, 24.890625 }, 
    { -1912.1589355469, 883.3916015625, 35.215755462646 }, 
    { -1977.3975830078, 1118.9444580078, 53.23331451416 }, 
    { -1703.1501464844, 1340.6345214844, 7.1796875 } 
    } 
      
      
    local pedCus = { 
    { 7 }, 
    { 21 }, 
    { 29 }, 
    { 137 }, 
    { 27 }, 
    { 240 }, 
    { 264 } 
    } 
      
    
      
    function SetVisiteFor (mark,player) 
                   setElementVisibleTo ( mark, root, false ) 
                   setElementVisibleTo ( mark, player, true ) 
    end 
      
      
      
      
      
    taxiVehs = { [420] = true } 
    Cars = {} 
    function teamSet ( ) 
            if (isElement(Cars[source])) then 
                destroyElement(Cars[source]) 
            end 
            setElementData(source,"markertax",4) 
            setElementModel(source, 255) 
                Cars[source] = createVehicle(420, -2485.3188476563, -169.93522644043, 25.6171875) 
                addEventHandler ( "onVehicleExit", Cars[source], deleteOnExit ) 
                addEventHandler ( "onVehicleEnter", Cars[source], inVEH ) 
                addEventHandler ( "onVehicleStartEnter", Cars[source], enterVehicle ) 
                warpPedIntoVehicle ( source, Cars[source] ) 
                startJob() 
                outputChatBox("You are now employed as a Taxi Driver!", source) 
    end 
    addEvent ( "sTeame", true) 
    addEventHandler ( "sTeame", root, teamSet ) 
      
    addEventHandler('onPlayerQuit', root, 
    function() 
            if isElement( Cars[source] ) then 
                    destroyElement(Cars[source] ) 
            end 
    end 
    ) 
      
      
    function enterVehicle ( seat, jacked ) 
        if getElementData(source,"JobNew") ~= 4 then 
                removePedFromVehicle( source ) 
                outputChatBox("Only Taxi Drivers can drive this vehicle!", source) 
        end 
    end 
    
    markers = { } 
    blips = { } 
    peds = { } 
    mposi = { } 
    mposii = {} 
      
      
      
      
    function startJob ( ) 
        local x, y, z = unpack ( pickups [ math.random ( #pickups ) ] ) 
        markers [ source ] = createMarker ( x, y, z, "cylinder", 5.0, 255, 0, 0, 0 ) 
        SetVisiteFor (markers [ source ],source) 
        mposi = { getElementPosition( markers [ source ] ) } 
        local skins = unpack ( pedCus [ math.random ( #pedCus ) ] ) 
        peds [ source ] = createPed( skins, x, y, z )   
        SetVisiteFor (peds [ source ],source) 
        blips [ source ] = createBlipAttachedTo ( markers [ source ], 58 ) 
        SetVisiteFor (blips [ source ],source) 
        addEventHandler ( "onMarkerHit", markers [ source ], warpit ) 
        end 
     
    function inVEH () 
        if isPedInVehicle ( source ) and getElementData(source,"JobNew") == 4 then 
                startJob () 
       end 
     end 
      
    function warpit ( ) 
        if isPedInVehicle ( source )  then 
           local vehiclee = getPedOccupiedVehicle ( source ) 
           if ( getElementModel ( vehiclee ) == 420 ) then  
                 bindKey(source,"H","down",warpit) 
                end 
           end 
      end 
             
    function warpit2 () 
    warpPedIntoVehicle(peds [ source ], getPedOccupiedVehicle ( source ), 2 ) 
                local x, y, z = unpack ( dropoffss [ math.random ( #dropoffss ) ] ) 
                markers [ source ] = createMarker ( x, y, z - 1, "cylinder", 5.0, 195, 197, 9, 255 )  
                SetVisiteFor (markers [ source ],source) 
                mposii = { getElementPosition( markers [ source ] ) } 
                blips [ source ] = createBlipAttachedTo ( markers [ source ], 41 ) 
                SetVisiteFor (blips [ source ],source) 
                addEventHandler ( "onMarkerHit", markers [ source ], pickmeup ) 
                unbindKey(source,"H","down",warpit2) 
    end 
  
       
    function pickmeup () 
        if isPedInVehicle ( source ) then 
            destroyJob () 
            local mx, my, mz = unpack ( mposi ) 
            local mmx, mmy, mmz = unpack ( mposii ) 
            local money = getDistanceBetweenPoints2D ( mx, my, mmx, mmy ) 
            finalmoney = math.floor ( money ) 
            if finalmoney then 
            setTimer( function () 
            finalmoney = finalmoney + 1000 
            setElementData(source,"Money", (getElementData(source,"Money" or 0 ) ) ) 
            outputChatBox( "You have earned "..finalmoney.."!",source,0, 144, 0) 
            setElementData(source,"Money", getElementData(source,"Money" or 0 ) ) 
            end, 3000, 1 ) 
            setTimer ( 
                function () 
                if ( isElement ( peds [ source ] ) ) then  
                        destroyElement ( peds [ source ] ) 
                        end 
                    startJob () 
                end 
                ,3000, 1 
            ) 
                end 
          end 
      end 
  
    function deleteOnExit ( ) 
        if ( isElement ( markers [ source ] ) ) then 
            destroyElement ( markers [ source ] ) 
        end 
        if ( isElement ( blips [ source ] ) ) then 
            destroyElement ( blips [ source ] ) 
        end 
        if ( isElement ( peds [ source ] ) ) then 
            destroyElement ( peds [ source ] ) 
        end 
    end 
      
    -- lol ok 
    function destroyJob () 
        if ( isElement ( markers [ source ] ) ) then 
            destroyElement ( markers [ source ] ) 
        end 
        if ( isElement ( blips [ source ] ) ) then 
            destroyElement( blips [ source ] ) 
        end 
    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...