Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Taxijob distance calculation exploitation #5

Open
adweex opened this issue Feb 20, 2023 · 2 comments
Open

[BUG] Taxijob distance calculation exploitation #5

adweex opened this issue Feb 20, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@adweex
Copy link

adweex commented Feb 20, 2023

Describe the bug
Taxijob calculates distance well, however during npc missions the calculation is exploitable. You don't really have to do the jobs because you can take the npc anywhere you would like while getting money for it.

To Reproduce
Steps to reproduce the behavior:

  1. Start an npc mission and don't go to the objective just drive around freely

Expected behavior
NPC should react if its not getting closer to the destination or we should stop the meter if player goes the wrong direction.

As far as i know there is no possible way to calculate distance just like the GPS do, or use that value.
One solution could be drawing an " airline " between the pickup point and destination point and use that value. (not the best option but solves the exploitation).

**Screenshots $$$ **
He will never return home
image

@adweex adweex added the bug Something isn't working label Feb 20, 2023
@D4isDAVID D4isDAVID added this to Issues Jul 19, 2023
@github-project-automation github-project-automation bot moved this to Todo in Issues Jul 19, 2023
@ChatDisabled ChatDisabled moved this from Todo to Confirmed in Issues Aug 1, 2023
@artur-michalak
Copy link
Contributor

I have two ideas:

  • specifying the maximum distance of the route in the config
  • multiplier of the distance in the config as maximum distance. Example distance = 4 miles, with multiplier 1.5, npc will discontinue the service when you exceed 4 * 1.5 miles (default multiplier 1.5)
    all options with some randomization.

@4nn0nym05
Copy link

4nn0nym05 commented Jan 21, 2025

I fixed it by modifying calculateFareAmount() function .. it only adds to fare if you are moving closer to destrination

local function calculateFareAmount()
    if meterIsOpen and meterActive and NpcData.NpcTaken then -- Only calculate if NPC is in vehicle
        local startPos = lastLocation
        local newPos = GetEntityCoords(cache.ped)
        if startPos ~= newPos then
            -- Get destination coordinates
            local destCoords
            if NpcData.CurrentDeliver then
                destCoords = vec3(
                    sharedConfig.npcLocations.deliverLocations[NpcData.CurrentDeliver].x,
                    sharedConfig.npcLocations.deliverLocations[NpcData.CurrentDeliver].y,
                    sharedConfig.npcLocations.deliverLocations[NpcData.CurrentDeliver].z
                )
            end
            if destCoords then
                local newDistance = #(startPos - newPos)
                local oldDistToDest = #(startPos - destCoords)
                local newDistToDest = #(newPos - destCoords)
                -- Only count distance if moving towards destination
                if newDistToDest < oldDistToDest then
                    lastLocation = newPos
                    meterData['distanceTraveled'] += (newDistance / 1609)
                    local fareAmount = ((meterData['distanceTraveled']) * config.meter.defaultPrice) + config.meter.startingPrice
                    meterData['currentFare'] = math.floor(fareAmount)
                    SendNUIMessage({
                        action = 'updateMeter',
                        meterData = meterData
                    })
                end
            end
        end
    end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Confirmed
Development

No branches or pull requests

3 participants