Jump to content

key binding?


Recommended Posts

Here is the script:

  
function startJob ( playerSource ) 
    local x, y, z = getElementPosition ( playerSource ) 
    if ( chauffeurSkins[getElementModel ( playerSource )] ) then 
        if not playerClients[ playerSource ] then 
            local numLocations = #taxiLocations 
            if ( numLocations > 0 ) then 
                repeatCount = 0; 
                repeat 
                    local pickupPoint = math.random(numLocations) 
                    pickupx = taxiLocations[pickupPoint]["x"] 
                    pickupy = taxiLocations[pickupPoint]["y"] 
                    pickupz = taxiLocations[pickupPoint]["z"] 
                    pickupr = taxiLocations[pickupPoint]["r"] 
                    local jobDistance = getDistanceBetweenPoints3D ( x, y, z, pickupx, pickupy, pickupz ); 
                    repeatCount = repeatCount+1 
                until jobDistance > 100 and jobDistance < 800 + repeatCount*100 
                 
                repeat  
                    local id = math.random( 10, 270 )  
                    ped = createPed( tonumber( id ), pickupx, pickupy, pickupz )  
                    setPedRotation ( ped, pickupr ) 
                until ped 
                 
                playerClients[ playerSource ] = {  }; 
                table.insert( playerClients[ playerSource ], ped ); 
                table.insert( jobClients, ped ); 
                 
                local pedBlip = createBlipAttachedTo ( ped, 41, 2, 255, 0, 0, 255, 1, 99999.0, playerSource) 
                playerBlips[ playerSource ] = {  }; 
                table.insert( playerBlips[ playerSource ], pedBlip ); 
                 
                pedMarker = createMarker ( pickupx, pickupy, 0, cylinder, 6.5, 255, 255, 0, 150, playerSource) 
                playerCols[ playerSource ] = {  }; 
                table.insert( playerCols[ playerSource ], pedMarker ); 
                addEventHandler( "onMarkerHit", pedMarker, arrivePickup ) 
                outputChatBox ( "Pickup the passenger located at the marker.", playerSource ); 
            else 
                outputChatBox ( "No passenger pickup points specified, contact an admin!", playerSource ); 
            end 
        else 
            outputChatBox ( "You allready have an assignment!", source ); 
        end 
         
    else 
        outputChatBox ( "You don't have a job!", source ); 
    end 
end 
addCommandHandler ("startjob", startJob); 

how to make binding if i plress f1 to startJob

PS. I tried bindKey ("down","f1",startJob) and it is not working for me

Link to comment
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
function () 
for index,player in pairs(getElementsByType("player")) do 
bindKey(player,"F1","down",startJob) 
  end 
end) 
  
addEventHandler("onPlayerJoin",getRootElement(), 
function () 
bindKey(source,"F1","down",startJob) 
end) 
  
function startJob ( playerSource ) 
    local x, y, z = getElementPosition ( playerSource ) 
    if ( chauffeurSkins[getElementModel ( playerSource )] ) then 
        if not playerClients[ playerSource ] then 
            local numLocations = #taxiLocations 
            if ( numLocations > 0 ) then 
                repeatCount = 0; 
                repeat 
                    local pickupPoint = math.random(numLocations) 
                    pickupx = taxiLocations[pickupPoint]["x"] 
                    pickupy = taxiLocations[pickupPoint]["y"] 
                    pickupz = taxiLocations[pickupPoint]["z"] 
                    pickupr = taxiLocations[pickupPoint]["r"] 
                    local jobDistance = getDistanceBetweenPoints3D ( x, y, z, pickupx, pickupy, pickupz ); 
                    repeatCount = repeatCount+1 
                until jobDistance > 100 and jobDistance < 800 + repeatCount*100 
                
                repeat 
                    local id = math.random( 10, 270 ) 
                    ped = createPed( tonumber( id ), pickupx, pickupy, pickupz ) 
                    setPedRotation ( ped, pickupr ) 
                until ped 
                
                playerClients[ playerSource ] = {  }; 
                table.insert( playerClients[ playerSource ], ped ); 
                table.insert( jobClients, ped ); 
                
                local pedBlip = createBlipAttachedTo ( ped, 41, 2, 255, 0, 0, 255, 1, 99999.0, playerSource) 
                playerBlips[ playerSource ] = {  }; 
                table.insert( playerBlips[ playerSource ], pedBlip ); 
                
                pedMarker = createMarker ( pickupx, pickupy, 0, cylinder, 6.5, 255, 255, 0, 150, playerSource) 
                playerCols[ playerSource ] = {  }; 
                table.insert( playerCols[ playerSource ], pedMarker ); 
                addEventHandler( "onMarkerHit", pedMarker, arrivePickup ) 
                outputChatBox ( "Pickup the passenger located at the marker.", playerSource ); 
            else 
                outputChatBox ( "No passenger pickup points specified, contact an admin!", playerSource ); 
            end 
        else 
            outputChatBox ( "You allready have an assignment!", source ); 
        end 
        
    else 
        outputChatBox ( "You don't have a job!", source ); 
    end 
end 
addCommandHandler ("startjob", startJob) 

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