Jump to content

Pls hlp me with rrtaxi job script


S3M

Recommended Posts

Hi,

About rrtaxi job script.

I use a rrtaxi script and i trying and trying to make the checkpoint invisible, but it is still not succeeded.

i try to use: setMarkerColor(marker,r,g,b, 0) and setElementAlpha(marker,0) etc, but it still visible yellow checkpoints.

i want set it invisible becouse it's so ugly and the blip on the radar is sufficient enough.

I do not get it, so many markers on my scripts i make invisible markers but in this script, I manage not.

Can any make me happy? :)

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), 
    function()
        chauffeurSkins = { [253]=true, [255]=true, [165]=true }
        taxis = { [420]=true, [438]=true }
        playerClients = { }
        playerCols = { }
        playerBlips = { }
        jobClients = { }
        playerJobLocation = {  };
        local XMLTaxiLocations = xmlLoadFile ( "XML\\taxi_locations.xml" )
        if ( not XMLTaxiLocations ) then
            local XMLTaxiLocations = xmlCreateFile ( "XML\\taxi_locations.xml", "taxi_locations" )
            xmlSaveFile ( XMLTaxiLocations )
        end
       
        local taxi_locations = xmlNodeGetChildren(XMLTaxiLocations)
        taxiLocations = {}
        for i,node in ipairs(taxi_locations) do
            taxiLocations[i] = {}
            taxiLocations[i]["x"] = xmlNodeGetAttribute ( node, "posX" )
            taxiLocations[i]["y"] = xmlNodeGetAttribute ( node, "posY" )
            taxiLocations[i]["z"] = xmlNodeGetAttribute ( node, "posZ" )
            taxiLocations[i]["r"] = xmlNodeGetAttribute ( node, "rot" )
        end
        xmlUnloadFile ( XMLTaxiLocations )
    end
)
 
function enterVehicle ( thePlayer, seat, jacked )
    if ( taxis[getElementModel ( source )] ) and ( not chauffeurSkins[getElementModel ( thePlayer )] ) and (seat == 0) then
        cancelEvent()
        outputChatBox ( "only taxi drivers can enter!", thePlayer )
    end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle )
 
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, 56, 2, 255, 0, 0, 255, 1, 99999.0, playerSource)
                playerBlips[ playerSource ] = {  };
                table.insert( playerBlips[ playerSource ], pedBlip );
               
                                pedMarker = createMarker ( pickupx, pickupy, 0, cylinder, 5.0, 255, 255, 0, 10, playerSource)
 
                playerCols[ playerSource ] = {  };
                table.insert( playerCols[ playerSource ], pedMarker );
                addEventHandler( "onMarkerHit", pedMarker, arrivePickup )
 
                outputChatBox ( "pickup the passenger located at the yellow blip.", 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);
 
function arrivePickup ( playerSource )
    if playerClients[ playerSource ] then
        for k, ped in pairs( playerClients[ playerSource ] ) do
            if ped then
            local x,y,z     = getElementPosition(ped);
                local tx,ty,tz  = getElementPosition(playerSource);
                setPedRotation(ped, findRotation(x,y,tx,ty) );
                local numLocations = #taxiLocations
                if ( numLocations > 0 ) then
                    local playerVehicle = getPedOccupiedVehicle ( playerSource );
                    if playerVehicle and taxis[getElementModel ( playerVehicle )] then
                        local speedx, speedy, speedz = getElementVelocity ( playerSource );
                        local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5);
                        if actualspeed < 0.25 then
                            local occupants = getVehicleOccupants(playerVehicle);
                            local seats = getVehicleMaxPassengers(playerVehicle);
                            local freeSeats = 0;
                            for seat = 0, seats do
                                local occupant = occupants[seat];
                                if not occupant and tonumber(freeSeats) == 0 then
                                    freeSeats = freeSeats + 1;
                                    warpPedIntoVehicle ( ped, playerVehicle, seat );
                                    if playerBlips[ playerSource ] then
                                        for k, blip in pairs( playerBlips[ playerSource ] ) do
                                            if blip then
                                                destroyElement( blip );
                                                playerBlips[ playerSource ] = nil;
                                            end
                                        end
                                    end
                                    if playerCols[ playerSource ] then
                                        for k, col in pairs( playerCols[ playerSource ] ) do
                                            if col then
                                                destroyElement( col );
                                            playerCols[ playerSource ] = nil;
                                            end
                                        end
                                    end
                                   
                                    playerJobLocation[ playerSource ] = {  };
                                    playerJobLocation[ playerSource ] = { ["x"]=x, ["y"]=y, ["z"]=z };
 
                                    repeat
                                        local dropOffPoint = math.random(numLocations)
                                        dropOffx = taxiLocations[dropOffPoint]["x"]
                                        dropOffy = taxiLocations[dropOffPoint]["y"]
                                        dropOffz = taxiLocations[dropOffPoint]["z"]
                                        local jobDistance = getDistanceBetweenPoints3D ( x, y, z, dropOffx, dropOffy, dropOffz );
                                    until jobDistance > 1000 and jobDistance < 35000
 
                                    local dropOffBlip = createBlip ( dropOffx, dropOffy, dropOffz, 56, 2, 255, 0, 0, 255, 1, 99999.0, playerSource)
                                    playerBlips[ playerSource ] = {  };
                                    table.insert( playerBlips[ playerSource ], dropOffBlip );
                                   
                                    pedMarker = createMarker ( dropOffx, dropOffy, 0, arrow, 3.5, 255, 255, 0, 1, playerSource)
 
                                    playerCols[ playerSource ] = {  };
                                    table.insert( playerCols[ playerSource ], pedMarker );
                                    addEventHandler( "onMarkerHit", pedMarker, arriveDropOff )
 
                                    outputChatBox ( "drive your passenger to the yellow destination blip.", playerSource );
                                end
                            end
                            if tonumber(freeSeats) == 0 then
                                outputChatBox ( "You don't have an empty seat for the passenger!", playerSource );
                            end
                        else
                            outputChatBox ( "slow down to pick up the passenger!", playerSource );
                        end
                    else
                        outputChatBox ( "you do not have a taxi vehicle!", playerSource );
                    end
                else
                    outputChatBox ( "no passenger pickup points specified, contact an admin!", playerSource );
                end
            end
        end
    end
end
 
function arriveDropOff ( playerSource )
    if playerClients[ playerSource ] then
        for k, ped in pairs( playerClients[ playerSource ] ) do
            if ped then
                local pedVehicle = getPedOccupiedVehicle ( ped );
                local playerVehicle = getPedOccupiedVehicle ( playerSource );
                if playerVehicle and taxis[getElementModel ( playerVehicle )] then
                    if pedVehicle == playerVehicle then
                        local speedx, speedy, speedz = getElementVelocity ( playerSource );
                        local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5);
                        if actualspeed < 0.15 then
                            removePedFromVehicle ( ped );
                            if playerClients[ playerSource ] then
                                for k, ped in pairs( playerClients[ playerSource ] ) do
                                    if ped then
                                        destroyElement( ped );
                                        playerClients[ playerSource ] = nil;
                                    end
                                end
                                for k, blip in pairs( playerBlips[ playerSource ] ) do
                                    if blip then
                                        destroyElement( blip );
                                        playerBlips[ playerSource ] = nil;
                                    end
                                end
                                for k, col in pairs( playerCols[ playerSource ] ) do
                                    if col then
                                        destroyElement( col );
                                        playerCols[ playerSource ] = nil;
                                    end
                                end
                                dx = tonumber(playerJobLocation[ playerSource ]["x"]);
                                dy = tonumber(playerJobLocation[ playerSource ]["y"]);
                                dz = tonumber(playerJobLocation[ playerSource ]["z"]);
                                local tx,ty,tz  = getElementPosition(playerSource);
                                local jobDistance = getDistanceBetweenPoints3D ( dx, dy, dz, tx, ty, tz );     
                                local jobDistanceKM = round(jobDistance/1000,2);
                                local jobReward = round(10+(jobDistanceKM^0.75)*30);
                                givePlayerMoney ( playerSource, jobReward );
                               
                                for k, jobLocation in pairs( playerJobLocation[ playerSource ] ) do
                                    if jobLocation then
                                    playerJobLocation[ playerSource ] = nil;
                                    end
                                end
                                outputChatBox ( "job succesful, you earned "..jobReward.." dollar.", playerSource );
                            end
                        else
                            outputChatBox ( "slow down to drop off the passenger!", playerSource );
                        end
                    else
                        outputChatBox ( "you have lost your passenger!", playerSource );
                    end
                else
                    outputChatBox ( "you do not have a taxi vehicle!", playerSource );
                end
            end
        end
    end
end
 
function quitJob ( playerSource )
    if playerClients[ playerSource ] then
        for k, ped in pairs( playerClients[ playerSource ] ) do
            if ped then
                destroyElement( ped );
                playerClients[ playerSource ] = nil;
            end
        end
        for k, blip in pairs( playerBlips[ playerSource ] ) do
            if blip then
                destroyElement( blip );
                playerBlips[ playerSource ] = nil;
            end
        end
        for k, col in pairs( playerCols[ playerSource ] ) do
            if col then
                destroyElement( col );
                playerCols[ playerSource ] = nil;
            end
        end
        if playerJobLocation[ playerSource ] then
            for k, jobLocation in pairs( playerJobLocation[ playerSource ] ) do
                if jobLocation then
                    destroyElement( jobLocation );
Link to comment
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), 
    function()
        chauffeurSkins = { [253]=true, [255]=true, [165]=true }
        taxis = { [420]=true, [438]=true }
        playerClients = { }
        playerCols = { }
        playerBlips = { }
        jobClients = { }
        playerJobLocation = {  };
        local XMLTaxiLocations = xmlLoadFile ( "XML\\taxi_locations.xml" )
        if ( not XMLTaxiLocations ) then
            local XMLTaxiLocations = xmlCreateFile ( "XML\\taxi_locations.xml", "taxi_locations" )
            xmlSaveFile ( XMLTaxiLocations )
        end
       
        local taxi_locations = xmlNodeGetChildren(XMLTaxiLocations)
        taxiLocations = {}
        for i,node in ipairs(taxi_locations) do
            taxiLocations[i] = {}
            taxiLocations[i]["x"] = xmlNodeGetAttribute ( node, "posX" )
            taxiLocations[i]["y"] = xmlNodeGetAttribute ( node, "posY" )
            taxiLocations[i]["z"] = xmlNodeGetAttribute ( node, "posZ" )
            taxiLocations[i]["r"] = xmlNodeGetAttribute ( node, "rot" )
        end
        xmlUnloadFile ( XMLTaxiLocations )
    end
)
 
function enterVehicle ( thePlayer, seat, jacked )
    if ( taxis[getElementModel ( source )] ) and ( not chauffeurSkins[getElementModel ( thePlayer )] ) and (seat == 0) then
        cancelEvent()
        outputChatBox ( "only taxi drivers can enter!", thePlayer )
    end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle )
 
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, 56, 2, 255, 0, 0, 255, 1, 99999.0, playerSource)
                playerBlips[ playerSource ] = {  };
                table.insert( playerBlips[ playerSource ], pedBlip );
               
                                pedMarker = createMarker ( pickupx, pickupy, 0, "cylinder", 5.0, 255, 255, 0, 10, playerSource)
 
                playerCols[ playerSource ] = {  };
                table.insert( playerCols[ playerSource ], pedMarker );
                addEventHandler( "onMarkerHit", pedMarker, arrivePickup )
 
                outputChatBox ( "pickup the passenger located at the yellow blip.", 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);
 
function arrivePickup ( playerSource )
    if playerClients[ playerSource ] then
        for k, ped in pairs( playerClients[ playerSource ] ) do
            if ped then
            local x,y,z     = getElementPosition(ped);
                local tx,ty,tz  = getElementPosition(playerSource);
                setPedRotation(ped, findRotation(x,y,tx,ty) );
                local numLocations = #taxiLocations
                if ( numLocations > 0 ) then
                    local playerVehicle = getPedOccupiedVehicle ( playerSource );
                    if playerVehicle and taxis[getElementModel ( playerVehicle )] then
                        local speedx, speedy, speedz = getElementVelocity ( playerSource );
                        local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5);
                        if actualspeed < 0.25 then
                            local occupants = getVehicleOccupants(playerVehicle);
                            local seats = getVehicleMaxPassengers(playerVehicle);
                            local freeSeats = 0;
                            for seat = 0, seats do
                                local occupant = occupants[seat];
                                if not occupant and tonumber(freeSeats) == 0 then
                                    freeSeats = freeSeats + 1;
                                    warpPedIntoVehicle ( ped, playerVehicle, seat );
                                    if playerBlips[ playerSource ] then
                                        for k, blip in pairs( playerBlips[ playerSource ] ) do
                                            if blip then
                                                destroyElement( blip );
                                                playerBlips[ playerSource ] = nil;
                                            end
                                        end
                                    end
                                    if playerCols[ playerSource ] then
                                        for k, col in pairs( playerCols[ playerSource ] ) do
                                            if col then
                                                destroyElement( col );
                                            playerCols[ playerSource ] = nil;
                                            end
                                        end
                                    end
                                   
                                    playerJobLocation[ playerSource ] = {  };
                                    playerJobLocation[ playerSource ] = { ["x"]=x, ["y"]=y, ["z"]=z };
 
                                    repeat
                                        local dropOffPoint = math.random(numLocations)
                                        dropOffx = taxiLocations[dropOffPoint]["x"]
                                        dropOffy = taxiLocations[dropOffPoint]["y"]
                                        dropOffz = taxiLocations[dropOffPoint]["z"]
                                        local jobDistance = getDistanceBetweenPoints3D ( x, y, z, dropOffx, dropOffy, dropOffz );
                                    until jobDistance > 1000 and jobDistance < 35000
 
                                    local dropOffBlip = createBlip ( dropOffx, dropOffy, dropOffz, 56, 2, 255, 0, 0, 255, 1, 99999.0, playerSource)
                                    playerBlips[ playerSource ] = {  };
                                    table.insert( playerBlips[ playerSource ], dropOffBlip );
                                   
                                    pedMarker = createMarker ( dropOffx, dropOffy, 0, "arrow", 3.5, 255, 255, 0, 0, playerSource)
 
                                    playerCols[ playerSource ] = {  };
                                    table.insert( playerCols[ playerSource ], pedMarker );
                                    addEventHandler( "onMarkerHit", pedMarker, arriveDropOff )
 
                                    outputChatBox ( "drive your passenger to the yellow destination blip.", playerSource );
                                end
                            end
                            if tonumber(freeSeats) == 0 then
                                outputChatBox ( "You don't have an empty seat for the passenger!", playerSource );
                            end
                        else
                            outputChatBox ( "slow down to pick up the passenger!", playerSource );
                        end
                    else
                        outputChatBox ( "you do not have a taxi vehicle!", playerSource );
                    end
                else
                    outputChatBox ( "no passenger pickup points specified, contact an admin!", playerSource );
                end
            end
        end
    end
end
 
function arriveDropOff ( playerSource )
    if playerClients[ playerSource ] then
        for k, ped in pairs( playerClients[ playerSource ] ) do
            if ped then
                local pedVehicle = getPedOccupiedVehicle ( ped );
                local playerVehicle = getPedOccupiedVehicle ( playerSource );
                if playerVehicle and taxis[getElementModel ( playerVehicle )] then
                    if pedVehicle == playerVehicle then
                        local speedx, speedy, speedz = getElementVelocity ( playerSource );
                        local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5);
                        if actualspeed < 0.15 then
                            removePedFromVehicle ( ped );
                            if playerClients[ playerSource ] then
                                for k, ped in pairs( playerClients[ playerSource ] ) do
                                    if ped then
                                        destroyElement( ped );
                                        playerClients[ playerSource ] = nil;
                                    end
                                end
                                for k, blip in pairs( playerBlips[ playerSource ] ) do
                                    if blip then
                                        destroyElement( blip );
                                        playerBlips[ playerSource ] = nil;
                                    end
                                end
                                for k, col in pairs( playerCols[ playerSource ] ) do
                                    if col then
                                        destroyElement( col );
                                        playerCols[ playerSource ] = nil;
                                    end
                                end
                                dx = tonumber(playerJobLocation[ playerSource ]["x"]);
                                dy = tonumber(playerJobLocation[ playerSource ]["y"]);
                                dz = tonumber(playerJobLocation[ playerSource ]["z"]);
                                local tx,ty,tz  = getElementPosition(playerSource);
                                local jobDistance = getDistanceBetweenPoints3D ( dx, dy, dz, tx, ty, tz );    
                                local jobDistanceKM = round(jobDistance/1000,2);
                                local jobReward = round(10+(jobDistanceKM^0.75)*30);
                                givePlayerMoney ( playerSource, jobReward );
                               
                                for k, jobLocation in pairs( playerJobLocation[ playerSource ] ) do
                                    if jobLocation then
                                    playerJobLocation[ playerSource ] = nil;
                                    end
                                end
                                outputChatBox ( "job succesful, you earned "..jobReward.." dollar.", playerSource );
                            end
                        else
                            outputChatBox ( "slow down to drop off the passenger!", playerSource );
                        end
                    else
                        outputChatBox ( "you have lost your passenger!", playerSource );
                    end
                else
                    outputChatBox ( "you do not have a taxi vehicle!", playerSource );
                end
            end
        end
    end
end
 
function quitJob ( playerSource )
    if playerClients[ playerSource ] then
        for k, ped in pairs( playerClients[ playerSource ] ) do
            if ped then
                destroyElement( ped );
                playerClients[ playerSource ] = nil;
            end
        end
        for k, blip in pairs( playerBlips[ playerSource ] ) do
            if blip then
                destroyElement( blip );
                playerBlips[ playerSource ] = nil;
            end
        end
        for k, col in pairs( playerCols[ playerSource ] ) do
            if col then
                destroyElement( col );
                playerCols[ playerSource ] = nil;
            end
        end
        if playerJobLocation[ playerSource ] then
            for k, jobLocation in pairs( playerJobLocation[ playerSource ] ) do
                if jobLocation then
                   
Link to comment
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), 
    function()
        chauffeurSkins = { [253]=true, [255]=true, [165]=true }
        taxis = { [420]=true, [438]=true }
        playerClients = { }
        playerCols = { }
        playerBlips = { }
        jobClients = { }
        playerJobLocation = {  };
        local XMLTaxiLocations = xmlLoadFile ( "XML\\taxi_locations.xml" )
        if ( not XMLTaxiLocations ) then
            local XMLTaxiLocations = xmlCreateFile ( "XML\\taxi_locations.xml", "taxi_locations" )
            xmlSaveFile ( XMLTaxiLocations )
        end
       
        local taxi_locations = xmlNodeGetChildren(XMLTaxiLocations)
        taxiLocations = {}
        for i,node in ipairs(taxi_locations) do
            taxiLocations[i] = {}
            taxiLocations[i]["x"] = xmlNodeGetAttribute ( node, "posX" )
            taxiLocations[i]["y"] = xmlNodeGetAttribute ( node, "posY" )
            taxiLocations[i]["z"] = xmlNodeGetAttribute ( node, "posZ" )
            taxiLocations[i]["r"] = xmlNodeGetAttribute ( node, "rot" )
        end
        xmlUnloadFile ( XMLTaxiLocations )
    end
)
 
function enterVehicle ( thePlayer, seat, jacked )
    if ( taxis[getElementModel ( source )] ) and ( not chauffeurSkins[getElementModel ( thePlayer )] ) and (seat == 0) then
        cancelEvent()
        outputChatBox ( "only taxi drivers can enter!", thePlayer )
    end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle )
 
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, 56, 2, 255, 0, 0, 255, 1, 99999.0, playerSource)
                playerBlips[ playerSource ] = {  };
                table.insert( playerBlips[ playerSource ], pedBlip );
               
                                pedMarker = createMarker ( pickupx, pickupy, 0, "cylinder", 5.0, 255, 255, 0, 10, playerSource)
 
                playerCols[ playerSource ] = {  };
                table.insert( playerCols[ playerSource ], pedMarker );
                addEventHandler( "onMarkerHit", pedMarker, arrivePickup )
 
                outputChatBox ( "pickup the passenger located at the yellow blip.", 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);
 
function arrivePickup ( playerSource )
    if playerClients[ playerSource ] then
        for k, ped in pairs( playerClients[ playerSource ] ) do
            if ped then
            local x,y,z     = getElementPosition(ped);
                local tx,ty,tz  = getElementPosition(playerSource);
                setPedRotation(ped, findRotation(x,y,tx,ty) );
                local numLocations = #taxiLocations
                if ( numLocations > 0 ) then
                    local playerVehicle = getPedOccupiedVehicle ( playerSource );
                    if playerVehicle and taxis[getElementModel ( playerVehicle )] then
                        local speedx, speedy, speedz = getElementVelocity ( playerSource );
                        local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5);
                        if actualspeed < 0.25 then
                            local occupants = getVehicleOccupants(playerVehicle);
                            local seats = getVehicleMaxPassengers(playerVehicle);
                            local freeSeats = 0;
                            for seat = 0, seats do
                                local occupant = occupants[seat];
                                if not occupant and tonumber(freeSeats) == 0 then
                                    freeSeats = freeSeats + 1;
                                    warpPedIntoVehicle ( ped, playerVehicle, seat );
                                    if playerBlips[ playerSource ] then
                                        for k, blip in pairs( playerBlips[ playerSource ] ) do
                                            if blip then
                                                destroyElement( blip );
                                                playerBlips[ playerSource ] = nil;
                                            end
                                        end
                                    end
                                    if playerCols[ playerSource ] then
                                        for k, col in pairs( playerCols[ playerSource ] ) do
                                            if col then
                                                destroyElement( col );
                                            playerCols[ playerSource ] = nil;
                                            end
                                        end
                                    end
                                   
                                    playerJobLocation[ playerSource ] = {  };
                                    playerJobLocation[ playerSource ] = { ["x"]=x, ["y"]=y, ["z"]=z };
 
                                    repeat
                                        local dropOffPoint = math.random(numLocations)
                                        dropOffx = taxiLocations[dropOffPoint]["x"]
                                        dropOffy = taxiLocations[dropOffPoint]["y"]
                                        dropOffz = taxiLocations[dropOffPoint]["z"]
                                        local jobDistance = getDistanceBetweenPoints3D ( x, y, z, dropOffx, dropOffy, dropOffz );
                                    until jobDistance > 1000 and jobDistance < 35000
 
                                    local dropOffBlip = createBlip ( dropOffx, dropOffy, dropOffz, 56, 2, 255, 0, 0, 255, 1, 99999.0, playerSource)
                                    playerBlips[ playerSource ] = {  };
                                    table.insert( playerBlips[ playerSource ], dropOffBlip );
                                   
                                    pedMarker = createMarker ( dropOffx, dropOffy, 0, "arrow", 3.5, 255, 255, 0, 0, playerSource)
 
                                    playerCols[ playerSource ] = {  };
                                    table.insert( playerCols[ playerSource ], pedMarker );
                                    addEventHandler( "onMarkerHit", pedMarker, arriveDropOff )
 
                                    outputChatBox ( "drive your passenger to the yellow destination blip.", playerSource );
                                end
                            end
                            if tonumber(freeSeats) == 0 then
                                outputChatBox ( "You don't have an empty seat for the passenger!", playerSource );
                            end
                        else
                            outputChatBox ( "slow down to pick up the passenger!", playerSource );
                        end
                    else
                        outputChatBox ( "you do not have a taxi vehicle!", playerSource );
                    end
                else
                    outputChatBox ( "no passenger pickup points specified, contact an admin!", playerSource );
                end
            end
        end
    end
end
 
function arriveDropOff ( playerSource )
    if playerClients[ playerSource ] then
        for k, ped in pairs( playerClients[ playerSource ] ) do
            if ped then
                local pedVehicle = getPedOccupiedVehicle ( ped );
                local playerVehicle = getPedOccupiedVehicle ( playerSource );
                if playerVehicle and taxis[getElementModel ( playerVehicle )] then
                    if pedVehicle == playerVehicle then
                        local speedx, speedy, speedz = getElementVelocity ( playerSource );
                        local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5);
                        if actualspeed < 0.15 then
                            removePedFromVehicle ( ped );
                            if playerClients[ playerSource ] then
                                for k, ped in pairs( playerClients[ playerSource ] ) do
                                    if ped then
                                        destroyElement( ped );
                                        playerClients[ playerSource ] = nil;
                                    end
                                end
                                for k, blip in pairs( playerBlips[ playerSource ] ) do
                                    if blip then
                                        destroyElement( blip );
                                        playerBlips[ playerSource ] = nil;
                                    end
                                end
                                for k, col in pairs( playerCols[ playerSource ] ) do
                                    if col then
                                        destroyElement( col );
                                        playerCols[ playerSource ] = nil;
                                    end
                                end
                                dx = tonumber(playerJobLocation[ playerSource ]["x"]);
                                dy = tonumber(playerJobLocation[ playerSource ]["y"]);
                                dz = tonumber(playerJobLocation[ playerSource ]["z"]);
                                local tx,ty,tz  = getElementPosition(playerSource);
                                local jobDistance = getDistanceBetweenPoints3D ( dx, dy, dz, tx, ty, tz );    
                                local jobDistanceKM = round(jobDistance/1000,2);
                                local jobReward = round(10+(jobDistanceKM^0.75)*30);
                                givePlayerMoney ( playerSource, jobReward );
                               
                                for k, jobLocation in pairs( playerJobLocation[ playerSource ] ) do
                                    if jobLocation then
                                    playerJobLocation[ playerSource ] = nil;
                                    end
                                end
                                outputChatBox ( "job succesful, you earned "..jobReward.." dollar.", playerSource );
                            end
                        else
                            outputChatBox ( "slow down to drop off the passenger!", playerSource );
                        end
                    else
                        outputChatBox ( "you have lost your passenger!", playerSource );
                    end
                else
                    outputChatBox ( "you do not have a taxi vehicle!", playerSource );
                end
            end
        end
    end
end
 
function quitJob ( playerSource )
    if playerClients[ playerSource ] then
        for k, ped in pairs( playerClients[ playerSource ] ) do
            if ped then
                destroyElement( ped );
                playerClients[ playerSource ] = nil;
            end
        end
        for k, blip in pairs( playerBlips[ playerSource ] ) do
            if blip then
                destroyElement( blip );
                playerBlips[ playerSource ] = nil;
            end
        end
        for k, col in pairs( playerCols[ playerSource ] ) do
            if col then
                destroyElement( col );
                playerCols[ playerSource ] = nil;
            end
        end
        if playerJobLocation[ playerSource ] then
           
Link to comment
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), 
    function()
        chauffeurSkins = { [253]=true, [255]=true, [165]=true }
        taxis = { [420]=true, [438]=true }
        playerClients = { }
        playerCols = { }
        playerBlips = { }
        jobClients = { }
        playerJobLocation = {  };
        local XMLTaxiLocations = xmlLoadFile ( "XML\\taxi_locations.xml" )
        if ( not XMLTaxiLocations ) then
            local XMLTaxiLocations = xmlCreateFile ( "XML\\taxi_locations.xml", "taxi_locations" )
            xmlSaveFile ( XMLTaxiLocations )
        end
       
        local taxi_locations = xmlNodeGetChildren(XMLTaxiLocations)
        taxiLocations = {}
        for i,node in ipairs(taxi_locations) do
            taxiLocations[i] = {}
            taxiLocations[i]["x"] = xmlNodeGetAttribute ( node, "posX" )
            taxiLocations[i]["y"] = xmlNodeGetAttribute ( node, "posY" )
            taxiLocations[i]["z"] = xmlNodeGetAttribute ( node, "posZ" )
            taxiLocations[i]["r"] = xmlNodeGetAttribute ( node, "rot" )
        end
        xmlUnloadFile ( XMLTaxiLocations )
    end
)
 
function enterVehicle ( thePlayer, seat, jacked )
    if ( taxis[getElementModel ( source )] ) and ( not chauffeurSkins[getElementModel ( thePlayer )] ) and (seat == 0) then
        cancelEvent()
        outputChatBox ( "only taxi drivers can enter!", thePlayer )
    end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle )
 
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, 56, 2, 255, 0, 0, 255, 1, 99999.0, playerSource)
                playerBlips[ playerSource ] = {  };
                table.insert( playerBlips[ playerSource ], pedBlip );
               
                                pedMarker = createMarker ( pickupx, pickupy, pickupz, "cylinder", 5.0, 255, 255, 0, 10, playerSource)
 
                playerCols[ playerSource ] = {  };
                table.insert( playerCols[ playerSource ], pedMarker );
                addEventHandler( "onMarkerHit", pedMarker, arrivePickup )
 
                outputChatBox ( "pickup the passenger located at the yellow blip.", 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);
 
function arrivePickup ( playerSource )
    if playerClients[ playerSource ] then
        for k, ped in pairs( playerClients[ playerSource ] ) do
            if ped then
            local x,y,z     = getElementPosition(ped);
                local tx,ty,tz  = getElementPosition(playerSource);
                setPedRotation(ped, findRotation(x,y,tx,ty) );
                local numLocations = #taxiLocations
                if ( numLocations > 0 ) then
                    local playerVehicle = getPedOccupiedVehicle ( playerSource );
                    if playerVehicle and taxis[getElementModel ( playerVehicle )] then
                        local speedx, speedy, speedz = getElementVelocity ( playerSource );
                        local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5);
                        if actualspeed < 0.25 then
                            local occupants = getVehicleOccupants(playerVehicle);
                            local seats = getVehicleMaxPassengers(playerVehicle);
                            local freeSeats = 0;
                            for seat = 0, seats do
                                local occupant = occupants[seat];
                                if not occupant and tonumber(freeSeats) == 0 then
                                    freeSeats = freeSeats + 1;
                                    warpPedIntoVehicle ( ped, playerVehicle, seat );
                                    if playerBlips[ playerSource ] then
                                        for k, blip in pairs( playerBlips[ playerSource ] ) do
                                            if blip then
                                                destroyElement( blip );
                                                playerBlips[ playerSource ] = nil;
                                            end
                                        end
                                    end
                                    if playerCols[ playerSource ] then
                                        for k, col in pairs( playerCols[ playerSource ] ) do
                                            if col then
                                                destroyElement( col );
                                            playerCols[ playerSource ] = nil;
                                            end
                                        end
                                    end
                                   
                                    playerJobLocation[ playerSource ] = {  };
                                    playerJobLocation[ playerSource ] = { ["x"]=x, ["y"]=y, ["z"]=z };
 
                                    repeat
                                        local dropOffPoint = math.random(numLocations)
                                        dropOffx = taxiLocations[dropOffPoint]["x"]
                                        dropOffy = taxiLocations[dropOffPoint]["y"]
                                        dropOffz = taxiLocations[dropOffPoint]["z"]
                                        local jobDistance = getDistanceBetweenPoints3D ( x, y, z, dropOffx, dropOffy, dropOffz );
                                    until jobDistance > 1000 and jobDistance < 35000
 
                                    local dropOffBlip = createBlip ( dropOffx, dropOffy, dropOffz, 56, 2, 255, 0, 0, 255, 1, 99999.0, playerSource)
                                    playerBlips[ playerSource ] = {  };
                                    table.insert( playerBlips[ playerSource ], dropOffBlip );
                                   
                                    pedMarker = createMarker ( dropOffx, dropOffy, dropOffz, "cylinder", 3.5, 255, 255, 0, 0, playerSource)
 
                                    playerCols[ playerSource ] = {  };
                                    table.insert( playerCols[ playerSource ], pedMarker );
                                    addEventHandler( "onMarkerHit", pedMarker, arriveDropOff )
 
                                    outputChatBox ( "drive your passenger to the yellow destination blip.", playerSource );
                                end
                            end
                            if tonumber(freeSeats) == 0 then
                                outputChatBox ( "You don't have an empty seat for the passenger!", playerSource );
                            end
                        else
                            outputChatBox ( "slow down to pick up the passenger!", playerSource );
                        end
                    else
                        outputChatBox ( "you do not have a taxi vehicle!", playerSource );
                    end
                else
                    outputChatBox ( "no passenger pickup points specified, contact an admin!", playerSource );
                end
            end
        end
    end
end
 
function arriveDropOff ( playerSource )
    if playerClients[ playerSource ] then
        for k, ped in pairs( playerClients[ playerSource ] ) do
            if ped then
                local pedVehicle = getPedOccupiedVehicle ( ped );
                local playerVehicle = getPedOccupiedVehicle ( playerSource );
                if playerVehicle and taxis[getElementModel ( playerVehicle )] then
                    if pedVehicle == playerVehicle then
                        local speedx, speedy, speedz = getElementVelocity ( playerSource );
                        local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5);
                        if actualspeed < 0.15 then
                            removePedFromVehicle ( ped );
                            if playerClients[ playerSource ] then
                                for k, ped in pairs( playerClients[ playerSource ] ) do
                                    if ped then
                                        destroyElement( ped );
                                        playerClients[ playerSource ] = nil;
                                    end
                                end
                                for k, blip in pairs( playerBlips[ playerSource ] ) do
                                    if blip then
                                        destroyElement( blip );
                                        playerBlips[ playerSource ] = nil;
                                    end
                                end
                                for k, col in pairs( playerCols[ playerSource ] ) do
                                    if col then
                                        destroyElement( col );
                                        playerCols[ playerSource ] = nil;
                                    end
                                end
                                dx = tonumber(playerJobLocation[ playerSource ]["x"]);
                                dy = tonumber(playerJobLocation[ playerSource ]["y"]);
                                dz = tonumber(playerJobLocation[ playerSource ]["z"]);
                                local tx,ty,tz  = getElementPosition(playerSource);
                                local jobDistance = getDistanceBetweenPoints3D ( dx, dy, dz, tx, ty, tz );    
                                local jobDistanceKM = round(jobDistance/1000,2);
                                local jobReward = round(10+(jobDistanceKM^0.75)*30);
                                givePlayerMoney ( playerSource, jobReward );
                               
                                for k, jobLocation in pairs( playerJobLocation[ playerSource ] ) do
                                    if jobLocation then
                                    playerJobLocation[ playerSource ] = nil;
                                    end
                                end
                                outputChatBox ( "job succesful, you earned "..jobReward.." dollar.", playerSource );
                            end
                        else
                            outputChatBox ( "slow down to drop off the passenger!", playerSource );
                        end
                    else
                        outputChatBox ( "you have lost your passenger!", playerSource );
                    end
                else
                    outputChatBox ( "you do not have a taxi vehicle!", playerSource );
                end
            end
        end
    end
end
 
function quitJob ( playerSource )
    if playerClients[ playerSource ] then
        for k, ped in pairs( playerClients[ playerSource ] ) do
            if ped then
                destroyElement( ped );
                playerClients[ playerSource ] = nil;
            end
        end
        for k, blip in pairs( playerBlips[ playerSource ] ) do
            if blip then
                destroyElement( blip );
                playerBlips[ playerSource ] = nil;
            end
        end
        for k, col in pairs( playerCols[ playerSource ] ) do
            if col then
                destroyElement( col );
                playerCols[ playerSource ] = nil;
            end
        end
        if playerJobLocation[ playerSource ] then
            for k, jobLocation in pairs( playerJobLocation[ playerSource ] ) do
                if jobLocation then
                   
Link to comment
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), 
    function()
        chauffeurSkins = { [253]=true, [255]=true, [165]=true }
        taxis = { [420]=true, [438]=true }
        playerClients = { }
        playerCols = { }
        playerBlips = { }
        jobClients = { }
        playerJobLocation = {  };
        local XMLTaxiLocations = xmlLoadFile ( "XML\\taxi_locations.xml" )
        if ( not XMLTaxiLocations ) then
            local XMLTaxiLocations = xmlCreateFile ( "XML\\taxi_locations.xml", "taxi_locations" )
            xmlSaveFile ( XMLTaxiLocations )
        end
       
        local taxi_locations = xmlNodeGetChildren(XMLTaxiLocations)
        taxiLocations = {}
        for i,node in ipairs(taxi_locations) do
            taxiLocations[i] = {}
            taxiLocations[i]["x"] = xmlNodeGetAttribute ( node, "posX" )
            taxiLocations[i]["y"] = xmlNodeGetAttribute ( node, "posY" )
            taxiLocations[i]["z"] = xmlNodeGetAttribute ( node, "posZ" )
            taxiLocations[i]["r"] = xmlNodeGetAttribute ( node, "rot" )
        end
        xmlUnloadFile ( XMLTaxiLocations )
    end
)
 
function enterVehicle ( thePlayer, seat, jacked )
    if ( taxis[getElementModel ( source )] ) and ( not chauffeurSkins[getElementModel ( thePlayer )] ) and (seat == 0) then
        cancelEvent()
        outputChatBox ( "only taxi drivers can enter!", thePlayer )
    end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle )
 
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, 56, 2, 255, 0, 0, 255, 1, 99999.0, playerSource)
                playerBlips[ playerSource ] = {  };
                table.insert( playerBlips[ playerSource ], pedBlip );
               
                                pedMarker = createMarker ( pickupx, pickupy, pickupz, "cylinder", 5.0, 255, 255, 0, 10, playerSource)
 
                playerCols[ playerSource ] = {  };
                table.insert( playerCols[ playerSource ], pedMarker );
                addEventHandler( "onMarkerHit", pedMarker, arrivePickup )
 
                outputChatBox ( "pickup the passenger located at the yellow blip.", 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);
 
function arrivePickup ( playerSource )
    if playerClients[ playerSource ] then
        for k, ped in pairs( playerClients[ playerSource ] ) do
            if ped then
            local x,y,z     = getElementPosition(ped);
                local tx,ty,tz  = getElementPosition(playerSource);
                setPedRotation(ped, findRotation(x,y,tx,ty) );
                local numLocations = #taxiLocations
                if ( numLocations > 0 ) then
                    local playerVehicle = getPedOccupiedVehicle ( playerSource );
                    if playerVehicle and taxis[getElementModel ( playerVehicle )] then
                        local speedx, speedy, speedz = getElementVelocity ( playerSource );
                        local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5);
                        if actualspeed < 0.25 then
                            local occupants = getVehicleOccupants(playerVehicle);
                            local seats = getVehicleMaxPassengers(playerVehicle);
                            local freeSeats = 0;
                            for seat = 0, seats do
                                local occupant = occupants[seat];
                                if not occupant and tonumber(freeSeats) == 0 then
                                    freeSeats = freeSeats + 1;
                                    warpPedIntoVehicle ( ped, playerVehicle, seat );
                                    if playerBlips[ playerSource ] then
                                        for k, blip in pairs( playerBlips[ playerSource ] ) do
                                            if blip then
                                                destroyElement( blip );
                                                playerBlips[ playerSource ] = nil;
                                            end
                                        end
                                    end
                                    if playerCols[ playerSource ] then
                                        for k, col in pairs( playerCols[ playerSource ] ) do
                                            if col then
                                                destroyElement( col );
                                            playerCols[ playerSource ] = nil;
                                            end
                                        end
                                    end
                                   
                                    playerJobLocation[ playerSource ] = {  };
                                    playerJobLocation[ playerSource ] = { ["x"]=x, ["y"]=y, ["z"]=z };
 
                                    repeat
                                        local dropOffPoint = math.random(numLocations)
                                        dropOffx = taxiLocations[dropOffPoint]["x"]
                                        dropOffy = taxiLocations[dropOffPoint]["y"]
                                        dropOffz = taxiLocations[dropOffPoint]["z"]
                                        local jobDistance = getDistanceBetweenPoints3D ( x, y, z, dropOffx, dropOffy, dropOffz );
                                    until jobDistance > 1000 and jobDistance < 35000
 
                                    local dropOffBlip = createBlip ( dropOffx, dropOffy, dropOffz, 56, 2, 255, 0, 0, 255, 1, 99999.0, playerSource)
                                    playerBlips[ playerSource ] = {  };
                                    table.insert( playerBlips[ playerSource ], dropOffBlip );
                                   
                                    pedMarker = createMarker ( dropOffx, dropOffy, dropOffz, "cylinder", 3.5, 255, 255, 0, 0, playerSource)
 
                                    playerCols[ playerSource ] = {  };
                                    table.insert( playerCols[ playerSource ], pedMarker );
                                    addEventHandler( "onMarkerHit", pedMarker, arriveDropOff )
 
                                    outputChatBox ( "drive your passenger to the yellow destination blip.", playerSource );
                                end
                            end
                            if tonumber(freeSeats) == 0 then
                                outputChatBox ( "You don't have an empty seat for the passenger!", playerSource );
                            end
                        else
                            outputChatBox ( "slow down to pick up the passenger!", playerSource );
                        end
                    else
                        outputChatBox ( "you do not have a taxi vehicle!", playerSource );
                    end
                else
                    outputChatBox ( "no passenger pickup points specified, contact an admin!", playerSource );
                end
            end
        end
    end
end
 
function arriveDropOff ( playerSource )
    if playerClients[ playerSource ] then
        for k, ped in pairs( playerClients[ playerSource ] ) do
            if ped then
                local pedVehicle = getPedOccupiedVehicle ( ped );
                local playerVehicle = getPedOccupiedVehicle ( playerSource );
                if playerVehicle and taxis[getElementModel ( playerVehicle )] then
                    if pedVehicle == playerVehicle then
                        local speedx, speedy, speedz = getElementVelocity ( playerSource );
                        local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5);
                        if actualspeed < 0.15 then
                            removePedFromVehicle ( ped );
                            if playerClients[ playerSource ] then
                                for k, ped in pairs( playerClients[ playerSource ] ) do
                                    if ped then
                                        destroyElement( ped );
                                        playerClients[ playerSource ] = nil;
                                    end
                                end
                                for k, blip in pairs( playerBlips[ playerSource ] ) do
                                    if blip then
                                        destroyElement( blip );
                                        playerBlips[ playerSource ] = nil;
                                    end
                                end
                                for k, col in pairs( playerCols[ playerSource ] ) do
                                    if col then
                                        destroyElement( col );
                                        playerCols[ playerSource ] = nil;
                                    end
                                end
                                dx = tonumber(playerJobLocation[ playerSource ]["x"]);
                                dy = tonumber(playerJobLocation[ playerSource ]["y"]);
                                dz = tonumber(playerJobLocation[ playerSource ]["z"]);
                                local tx,ty,tz  = getElementPosition(playerSource);
                                local jobDistance = getDistanceBetweenPoints3D ( dx, dy, dz, tx, ty, tz );    
                                local jobDistanceKM = round(jobDistance/1000,2);
                                local jobReward = round(10+(jobDistanceKM^0.75)*30);
                                givePlayerMoney ( playerSource, jobReward );
                               
                                for k, jobLocation in pairs( playerJobLocation[ playerSource ] ) do
                                    if jobLocation then
                                    playerJobLocation[ playerSource ] = nil;
                                    end
                                end
                                outputChatBox ( "job succesful, you earned "..jobReward.." dollar.", playerSource );
                            end
                        else
                            outputChatBox ( "slow down to drop off the passenger!", playerSource );
                        end
                    else
                        outputChatBox ( "you have lost your passenger!", playerSource );
                    end
                else
                    outputChatBox ( "you do not have a taxi vehicle!", playerSource );
                end
            end
        end
    end
end
 
function quitJob ( playerSource )
    if playerClients[ playerSource ] then
        for k, ped in pairs( playerClients[ playerSource ] ) do
            if ped then
                destroyElement( ped );
                playerClients[ playerSource ] = nil;
            end
        end
        for k, blip in pairs( playerBlips[ playerSource ] ) do
            if blip then
                destroyElement( blip );
                playerBlips[ playerSource ] = nil;
            end
        end
        for k, col in pairs( playerCols[ playerSource ] ) do
            if col then
                destroyElement( col );
                playerCols[ playerSource ] = nil;
            end
        end
        if playerJobLocation[ playerSource ] then
           
Edited by Guest
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...