Qbox-project / qbx_core

http://qbox-project.github.io
Other
67 stars 152 forks source link

Character spawning inside multicharacter preview rooms #347

Open mafewtm opened 8 months ago

mafewtm commented 8 months ago

Summary

Sometimes if you leave your server after you see the character selection screen, once you rejoin and spawn in at last location, itll spawn you inside the room

Reproduction

  1. Load into your server
  2. (Not sure if you need to select your character first or if you just load in and touch nothing...or both might cause it maybe)
  3. Log out of your server
  4. Load back into your server
  5. Select a character
  6. Select a spawn or if you arent using qbx_spawn, do nothing
  7. You'll load into the multicharacter character selection room instead of previous last location

Expected behavior

Your characters last location shouldnt be saved while in character selection

Actual behavior

It saves

Additional context

Might be something in the multicharacter or just how the last location is saved. Not too sure

Current Version

v1.6.1

Custom Resources

N/A

rasm945i commented 8 months ago

I'm pretty confident this is where the issue lies. A check if the user is "logged in" should probably be performed before getting the users location: https://github.com/Qbox-project/qbx_core/blob/main/server/player.lua#L492

rasm945i commented 8 months ago

I managed to replicate it.

  1. Introduce error that causes a crash pretty much as soon as the user picks a character (in example theres a delay, see step 5) I used this code on a client-side script:
    AddEventHandler('populationPedCreating', function(x, y, z)
    Wait(500)   -- Give the entity some time to be created
        local handle = GetClosestPed(vec3(x,y,z)) -- This is an invalid native call, not enough arguments passed
    SetPedDropsWeaponsWhenDead(handle, false)
    end)
  2. Join server
  3. Pick character
  4. Hit play
  5. At this point you are among pedestrians and will crash due to them spawning (because thats how i implemented my crash)
  6. Disable the resource causing the crash
  7. Log in
  8. Spawn in the previous "Spawn Preview" location when selecting "Last Location" rather than the intended actual "Last Location"
SKITTLE6969 commented 8 months ago

Summary

Sometimes if you leave your server after you see the character selection screen, once you rejoin and spawn in at last location, itll spawn you inside the room

Reproduction

  1. Load into your server
  2. (Not sure if you need to select your character first or if you just load in and touch nothing...or both might cause it maybe)
  3. Log out of your server
  4. Load back into your server
  5. Select a character
  6. Select a spawn or if you arent using qbx_spawn, do nothing
  7. You'll load into the multicharacter character selection room instead of previous last location

Expected behavior

Your characters last location shouldnt be saved while in character selection

Actual behavior

It saves

Additional context

Might be something in the multicharacter or just how the last location is saved. Not too sure

Current Version

v1.6.1

Custom Resources

N/A

can confirm this, i though it was my multichar issue but apparently its not @_@

0Programmer commented 1 month ago

So when selecting a character SetMetaData gets triggert 3 times because of: https://github.com/Qbox-project/qbx_medical/blob/main/server/main.lua#L35 and https://github.com/Qbox-project/qbx_police/blob/main/server/main.lua#L325 qbx_medical wil trigger the Save() function because: https://github.com/Qbox-project/qbx_core/blob/main/server/player.lua#L1004

Here we store the last location: https://github.com/Qbox-project/qbx_core/blob/main/server/player.lua#L1006 Now it is possible that before you load in fully that sometimes https://github.com/Qbox-project/qbx_core/blob/main/server/loops.lua#L3 will run and save the pos from the multicharacter location and state inApartment or inProperty is true and therefore will not update the last location?

After you select a character it will save the multicharacter location 2 times because of isdead and inlaststand from qbx_medical server/main.lua#L35 but whatever i try i cannot reproduce this issue because the last location will update correctly.

Does anyone has this issue with the latest version?