Removebuildingforplayer error
#1

how to fix it I just add a map to my gamemode in ongamemodeinit and i have error on lines where writet removebuildingforplayer
Reply
#2

RemoveBuildingForPlayer needs do have a playerid defined. Put in OnPlayerConnect.
Reply
#3

aaww.... oh ok thx
Reply
#4

Removing a building FOR A PLAYER will not work under the OnGameModeInit callback since there are no players connected when initializing the gamemode.

There are a few exceptions where RemoveBuildingForPlayer can be used upon initializing a script and that is in filterscripts and when restarting the gamemode through gmx (I don't recommend doing so, though). You can load filterscripts at run-time and not necessarily when the server starts. In such a case (*) (which I don't think is very common), you can loop through all the connected players:

PHP код:
public OnFilterScriptInit() {
    for(new 
0GetPlayerPoolSize(); <= j++) {
        
RemoveBuildingForPlayer(i, ...); // Fill in the rest of the arguments
    
}
    return 
true;

A downside of doing it like this is that players who join the server after the filterscript has been initialized still see the removed buildings. To fix that, you can add the OnPlayerConnect callback to the filterscript and remove the buildings in there:

PHP код:
public OnPlayerConnect(playerid) {
    
RemoveBuildingForPlayer(playerid, ...); // Fill in the rest of the arguments
    
return true;

(*) I don't mean loading filterscripts at run-time but removing buildings for a player at run-time.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)