MTDOJRP / docs

KCDOJRP Documentation | https://kcdojrp.com
https://docs.KCDOJRP.com
1 stars 3 forks source link

[BUG] Can still drive when dead #52

Closed Desoroxxx closed 4 days ago

Desoroxxx commented 4 days ago

In-Game Bug Report

Description

Silly zombie driving

Steps to Reproduce

  1. Click to spawn vehicle
  2. Get ran over by Skyy
  3. Wasted screen shows up
  4. Vehicle spawn
  5. You alive again, silly I know
  6. Drive?

Expected Behavior

I pulled out a vehicle and died while doing so, and when it finally spawned, I was on the wasted screen, but looked alive, and was able to drive.

Screenshots

image

Additional Context

You silly?

Your Environment


Paneedah commented 4 days ago

Issue Status Update

Moved the issue to in-progress and confirmed, was able to successfully replicate this weird "zombie driving" mechanic.

Question

After testing, I wasn't able to replicate turning, slowing down, or anything else. It seems the vehicle gets stuck accelerating and just goes forward. Is this the same as what you experienced?

In addition, you specified in your reproduction steps 4. Vehicle spawn. How were you able to spawn a vehicle once dead? I have tried to replicate this, however the menu closes itself upon death.

Desoroxxx commented 4 days ago

No I could fully drive normally. I clicked the button and got killed right after, and then it spawned it happened really fast, the crucial element is getting run over by a wild Skyy driving

Desoroxxx commented 4 days ago

Like, there is a small delay between clicking to spawn a car and it spawning, I died in that small delay

Paneedah commented 4 days ago

Ah okay, so you got past my dead check since you weren't dead (at the time). Then died while your client was trying to request and process the vehicle model.

Solution: Part 1

The first change to fix the problem is now manually requesting the model first & awaiting for it to be ready before doing another isAlive check.

    try(function()
        -- Fix to issue: start
        while not HasModelLoaded(returnedHash) do
            RequestModel(returnedHash)
            Citizen.Wait(0)
        end

        if KellyPlayer.isDead() then
            Logger.debug('Player is dead, cannot spawn vehicle.')
            KellyPlayer.notify('You cannot spawn a vehicle while dead.')
            return
        end
        -- Fix to issue: end

        local vehicle = Vehicle.performVehicleSpawn(spawnCode)

Solution: Part 2

The following keybinds are now disabled while dead (while in vehicle)

if KellyPlayer.isDead() then
    DisableControlAction(0, 59, true) -- INPUT_VEH_MOVE_LR (D / LEFT STICK)
    DisableControlAction(0, 61, true) -- INPUT_VEH_MOVE_UP_ONLY (LEFT SHIFT / LEFT STICK)
    DisableControlAction(0, 62, true) -- INPUT_VEH_MOVE_DOWN_ONLY (LEFT CTRL / LEFT STICK)
    DisableControlAction(0, 63, true) -- INPUT_VEH_MOVE_LEFT_ONLY (A / LEFT STICK)
    DisableControlAction(0, 64, true) -- INPUT_VEH_MOVE_RIGHT_ONLY (D / LEFT STICK)
    DisableControlAction(0, 66, true) -- INPUT_VEH_GUN_LR (MOUSE RIGHT / RIGHT STICK)
    DisableControlAction(0, 71, true) -- INPUT_VEH_ACCELERATE (W / RT)
    DisableControlAction(0, 72, true) -- INPUT_VEH_BRAKE (S / LT)
    DisableControlAction(0, 73, true) -- INPUT_VEH_DUCK (F / Y)
    DisableControlAction(0, 75, true) -- INPUT_VEH_EXIT (F / Y)
    DisableControlAction(0, 76, true) -- INPUT_VEH_HANDBRAKE (SPACE / RB)
    DisableControlAction(0, 77, true) -- INPUT_VEH_HOTWIRE_LEFT (W / LT)
    DisableControlAction(0, 78, true) -- INPUT_VEH_HOTWIRE_RIGHT (S / RT)
    DisableControlAction(0, 79, true) -- INPUT_VEH_LOOK_BEHIND (C / R3)
end

After basic testing, this seems to have solved the entire problem.