RemoveBuildingForPlayer game freeze on restart
#1

Right, this is NOT a problem related to 0.3z, but I don't see that as a reason to reject this bug report, especially since Kalcor said he would fix some existing bugs. So please don't come here and tell me that, thanks.

Basically, if you use RemoveBuildingForPlayer in your script twice for the same object, the game will freeze. You might say something like 'then don't do it', but this really becomes an issue after a server restart. Like many others I use RemoveBuildingForPlayer in OnPlayerConnect. So if a player was connected before the restart, and stays connected during the restart, he will experience game freezing when OnPlayerConnect is called. This is because removed objects stay removed for the given player, even after a restart.

It's hard to find a good PAWN-scripted system that distinguishes the players who were already connected from the newly connected players, though it can be done. This however is far from ideal.

I really think this should be fixed. RemoveBuildingForPlayer shouldn't do anything when called if the object is already removed. It would be a real step forward to see this one fixed, I'm sure a lot of scripters feel the same.

Greetz,
Danny
Reply
#2

Simple solution:

pawn Код:
#define FILTERSCRIPT

#include <a_samp>

new
    bool:gAlreadyHandled[MAX_PLAYERS];

// Use this if you don't load the FS when you start your server.
public OnFilterScriptInit()
{
    for (new i = 0; i != MAX_PLAYERS; ++i)
    {
        if (IsPlayerConnected(i)) OnPlayerConnect(i);
    }
}

public OnGameModeInit()
{
    for (new i = 0; i != MAX_PLAYERS; ++i)
    {
        if (IsPlayerConnected(i)) gAlreadyHandled[i] = true;
    }
}

public OnPlayerConnect(playerid)
{
    if (gAlreadyHandled[playerid]) return 1;
    gAlreadyHandled[playerid] = true;
    // ================================
    //  Do your building removal here.
    // ================================
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    gAlreadyHandled[playerid] = false;
    return 1;
}
Reply
#3

Are you sure that the players are connected at the time that OnGameModeInit gets called? Secondly, I assume the players are getting connected one by one after a restart, so wouldn't that mean this causes problems when you have a lot of players?

Also, the players with a slower internet connection will probably still haves issues since there's a chance they won't be connected by the time this loop runs.
Reply
#4

Let me guess your using gmx ?
Reply
#5

There is no cure for this, same you could report that you tried to remove whole SA map and your game crashed, and to avoid from freeze while testing your script on a localhost, you can make a check, if player ip is 127.0.0.1 to not remove them
Reply
#6

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Let me guess your using gmx ?
Yes I am. Is something wrong with using gmx? It looks like the most practical way to restart to me, especially when you have players in your server. I never encountered any disturbing bugs after a gmx - except for this one.
Reply
#7

GMX is well known to cause client bugs always rcon exit and use a starter script.
Reply
#8

Client try to remove object thats already removed after restart!
it's client bug
Reply
#9

Quote:
Originally Posted by ColeMiner
Посмотреть сообщение
Simple solution:

pawn Код:
(...)
Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
I wrote a map parser recently that mitigates this issue by storing removed object data in temp binary files.

If the filterscript is reloaded or the server is gmx'd, it won't try to remove the same objects twice.
What if a player times-out? There's no way to know if his game crashed (= Objects need to be removed again) or he just lost connection (= No need to remove objects again)

This NEEDS to be fixed.

Also, looks like the game doesn't actually freeze, you can still see the chat going on, players moving, etc. It's like you only lose the keyboard/mouse control.


Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
GMX is well known to cause client bugs always rcon exit and use a starter script.
It's not actually caused by GMX, go ahead and put your RemoveBuildings in OnPlayerSpawn, you will find out that when you spawn again the same issue will happen.
Reply
#10

Huh? You can check if player crashed in OnPlayerDisconnect callback. Check it reason values at wiki.sa-mp.com
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)