This PR fixes an error I ran into with the new auto-sell restricted items feature.
L 12/20/2022 - 17:12:11: [SM] Exception reported: Client 2 is not in game
L 12/20/2022 - 17:12:11: [SM] Blaming: store.smx
L 12/20/2022 - 17:12:11: [SM] Call stack trace:
L 12/20/2022 - 17:12:11: [SM] [0] ThrowError
L 12/20/2022 - 17:12:11: [SM] [1] Line 71, colorvariables::CPrintToChat
L 12/20/2022 - 17:12:11: [SM] [2] Line 305, store\store_functions.sp::Store_SellItem
L 12/20/2022 - 17:12:11: [SM] [3] Line 309, store\sql.sp::SQLCallback_LoadClientInventory_Equipment
It happens if a map change occurs right after a player with expired items connect.
This should be fixed by preventing load queries from going through map changes. Shouldn't cause any more problems, since a new load query will be sent after the player fully loads again.
Why did they went through? Well, it's a pretty special case, but when a map change occurs, OnClientDisconnect() gets called, but the player's userid doesn't actually change! The client will quickly disconnect and reconnect, but will keep its old userid. It'll still resolve to a client index, but a different one.
TL;DR, when a map change occurs, a player's client index gets changed but not their userid. It is therefore needed to check IsClientInGame() if we're going to use permission-related functions or functions that require that a player is in game.
This PR fixes an error I ran into with the new auto-sell restricted items feature.
It happens if a map change occurs right after a player with expired items connect. This should be fixed by preventing load queries from going through map changes. Shouldn't cause any more problems, since a new load query will be sent after the player fully loads again.
Why did they went through? Well, it's a pretty special case, but when a map change occurs,
OnClientDisconnect()
gets called, but the player's userid doesn't actually change! The client will quickly disconnect and reconnect, but will keep its old userid. It'll still resolve to a client index, but a different one. TL;DR, when a map change occurs, a player's client index gets changed but not their userid. It is therefore needed to checkIsClientInGame()
if we're going to use permission-related functions or functions that require that a player is in game.❌ Didn't try to compile ❌ Not tested in game