pawn-lang / sa-mp-fixes

Includes and plugins to fix various issues in the SA:MP server that can be fixed externally, leaving the devs time for other things.
135 stars 57 forks source link

GetPlayerInterior #166

Open r4sheed opened 2 years ago

r4sheed commented 2 years ago

GetPlayerInterior returns 0 when a script is reloaded, even if a player is inside an interior

You can see this on the video: https://streamable.com/8ax9gj

Y-Less commented 2 years ago

By "script" I assume you mean filterscript here? Their interior will be reset to 0 if the script is a gamemode.

r4sheed commented 2 years ago

By "script" I assume you mean filterscript here? Their interior will be reset to 0 if the script is a gamemode.

The server run with a bare game mode which is included with the SA-MP server files and I’m used this filterscript with fixes.inc on this video. So yeah, it’s a filterscript.

Y-Less commented 10 months ago

OK, am I right that you're running a gamemode without fixes.inc, going in to an interior, then loading the FS with it on. If so, that's quite a tricky thing to solve and will probably affect quite a few fixes. The code is written somewhat assuming that it is always running and knows the current state of the server at all times. Many things are initialised when fixes.inc is first started (it does try to account for reloads, but only if it was there earlier) because some of the bugs are that some data is not correctly initialised, so relying on that to begin with defeats the object.

Does it work correctly if you have fixes.inc in the gamemode?

Y-Less commented 10 months ago

As an example - take checkpoints. IsPlayerInCheckpoint is not correctly set when the server starts, so may return true before they've entered one. Thus fixes.inc sets a variable to false and monitors OnPlayerEnterCheckpoint, assuming that the initialisation is done before any player has a chance to enter a checkpoint. However, if you start a mode without fixes.inc, allow a player to enter a checkpoint, then load fixes.inc this initialisation will be wrong. Obviously we can't change fixes.inc to call IsPlayerInCheckpoint when it first starts, because that was the problem we were trying to solve in the first place.

I don't know of a solution to this, it might be impossible without loading the include earlier.

r4sheed commented 10 months ago

I'm using open.mp now and I did not tested this again since I've created this issue. But I've noticed fixes.inc sets the player interior variable to 0 under OnPlayerConnect which is a problem. You should use GetPlayerInterior instead and it will work perfectly.