Author Topic: [WONTFIX] Player instance isn't pointing to the same thing when player leaves  (Read 2169 times)

0 Members and 1 Guest are viewing this topic.

Offline S.L.C

  • Street Thug
  • *
  • Posts: 42
  • Sorry if you weren't impressed!
    • View Profile
Description
I'm trying to use the player instance as the key inside a table, but when the player leaves the server the player instance isn't pointing to the same thing it was previously pointing in the table.

Reproducible
Always

What you were doing when the bug happened
N/A

What you think caused the bug
I'm not sure if this is a feature of the module and not a bug. If this is not expected behavior then I'll look for a bug.

Code that can reproduce the issue that I'm having:
Code: [Select]
local t_Players = {}

function onPlayerJoin(i_player)
{     
t_Players[i_player] <- null;

print("OnJoin slot search result: " + t_Players.rawin(i_player).tostring());
}

function onPlayerPart(i_player, reason)
{
print("OnPart slot search result: " + t_Players.rawin(i_player).tostring());
}

Screenshot of the console output:

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
While this is not expected behavior per se, it is also not expected that the Squirrel VM will give you the exact instance every time you request it. It's for this reason that you absolutely must do player comparisons and indexing by player ID, and not an object instance verbatim.

Won't fix.
Do not PM me for support.




Offline S.L.C

  • Street Thug
  • *
  • Posts: 42
  • Sorry if you weren't impressed!
    • View Profile
Ok. Thanks for the confirmation. I will review my code to comply with this limitation.