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] Clients disappears and being selected the same one as before #33

Closed
iSentrie opened this issue Jul 22, 2024 · 10 comments · Fixed by #35
Closed

[bug] Clients disappears and being selected the same one as before #33

iSentrie opened this issue Jul 22, 2024 · 10 comments · Fixed by #35

Comments

@iSentrie
Copy link
Contributor

iSentrie commented Jul 22, 2024

There is a bug in the script when after dropping off the client, he's selected again as new customer and very soon after he gets in, he vanishes. Causing this to bug out.
image

Same problem was here: #32

@github-project-automation github-project-automation bot moved this to 🆕 New in ESX Roadmap Jul 22, 2024
@iSentrie iSentrie changed the title #32 [bug] Clients disappears and being selected the same one as before Jul 22, 2024
@Gellipapa Gellipapa moved this from 🆕 New to 🔧need test in ESX Roadmap Jul 26, 2024
@Gellipapa Gellipapa moved this from 🔧need test to 📋 Awaiting feedback in ESX Roadmap Sep 28, 2024
@Gellipapa
Copy link
Contributor

@iSentrie I tested it now and it does not select the same NPC, so it never goes into the unconscious if branch. It always selects another one nearby. How can we reproduce this?

@iSentrie
Copy link
Contributor Author

iSentrie commented Sep 28, 2024

Not always, but most often it will just select the same one, especially if there are not so many other peds nearby, without any efforts or specific repro. Script has to select the same one just question of time, because it doesn't track if the ped was your customer or not.

@Gellipapa
Copy link
Contributor

I think things are mixed up here, so when you write this the specific ped is corrupted so by default the ped being set twice the same wouldn't be a problem, not pretty of course but it's not bugg.

This message appears when you find an NPC that is damaged. It's probably because if it's damaged it wouldn't be controllable, although you could "revieve" it and it would work.

However, for me, out of 10/10 cases, it always found something else, never the same, so I could not reproduce it.

@iSentrie
Copy link
Contributor Author

iSentrie commented Sep 30, 2024

You're super lucky if you haven't got this bug from 10 attempts.

This happens:
image
Because of this:

esx_taxijob/client/main.lua

Lines 581 to 585 in 1958dcb

local function scope(customer)
ESX.SetTimeout(60000, function()
DeletePed(customer)
end)
end

And that happens because it's never checked if the ped was your customer or not:

function GetRandomWalkingNPC()
local search = {}
local peds = GetGamePool("CPed")
for i = 1, #peds, 1 do
if IsPedHuman(peds[i]) and IsPedWalking(peds[i]) and not IsPedAPlayer(peds[i]) then
search[#search+1] = peds[i]
end
end
if #search > 0 then
return search[math.random(#search)]
end
end

Step towards solution could be something like this:

-- check current customer vs new customer, however this has to be improved and CurrentCustomer saved so it wouldn't reset
if CurrentCustomer ~= peds[i] and IsPedHuman(peds[i]) and IsPedWalking(peds[i]) and not IsPedAPlayer(peds[i]) then
    search[#search+1] = peds[i]
end

I haven't looked in to it much, but pretty sure CurrentCustomer will reset when aborting the mission, so it still can be bugged out this way, so probably should declare this NPC ped id's at a different name and check this against ped that gonna be found by script as new customer.

@Gellipapa
Copy link
Contributor

@iSentrie Yes I believe this happens, but it hasn't been reproduced yet and as you say it resets the whole mission that will be the problem. With a couple of checks we can fix this as soon as I can reproduce the basic problem.

@iSentrie
Copy link
Contributor Author

@iSentrie Yes I believe this happens, but it hasn't been reproduced yet and as you say it resets the whole mission that will be the problem. With a couple of checks we can fix this as soon as I can reproduce the basic problem.

Pick up in Los Santos, deliver to Sandy Shores, it's basically over 50% that this will happen, at least for me.

@Gellipapa
Copy link
Contributor

@iSentrie I checked and now there was a case where it found that NPC but I only managed to trigger it when I interrupted the job and asked for a new job, but I still didn't get the unconcius notifiy.

I have two questions:
Did you manage to reproduce it by stopping in F6 and then searching for the NPC again?

My other question is that the PED was not damaged because as I look at the code there is an IsPedFatallyInjured native call that checks if the NPC is not damaged, otherwise it doesn't go into the condition.

Thanks for the replies, I might be able to reproduce it in the end (I hope :))

@Gellipapa
Copy link
Contributor

@iSentrie Now I see that you use the GTA notification while I use the ESX ShowNotification and this script uses it too, of course you may have rewritten your own but I only managed to display this notification if I kill the NPC in the taxi because then the thread detects that it is damaged and stops the transport logic and starts searching again.

Is it possible that you are using some other script?

It's quite weird because I've done it about 20 times now and it always finds something else and since the ped is not damaged it never goes into the IF.

@Gellipapa
Copy link
Contributor

image

@iSentrie
Copy link
Contributor Author

I have modified the framework for my needs, but taxi script was 1:1 when I tested.

If you get same ped it will be deleted by script and it will count as unconscious.

 local function scope(customer) 
     ESX.SetTimeout(60000, function() 
         DeletePed(customer) 
     end) 
 end 

I don't really remember how I was doing it exactly through F6 or not, probably not, since script doesn't really check for that, so it doesn't really matter you cancel it or not.

@github-project-automation github-project-automation bot moved this from 📋 Awaiting feedback to ✅ Done in ESX Roadmap Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants