how to set a default array value to a var with 2 agruments? (when creating it globally)
#2

You cant in pawn, you could use a 1d array with a little trick
pawn Code:
new Text: PlayerFadeText[MAX_PLAYERS * MAX_FADES] = {INVALID_TEXT_DRAW, ...};
#define PlayerFadeText[%0][%1] PlayerFadeText[(%0) + (MAX_PLAYERS * (%1))]
//could be [(MAX_FADES * (%0)) + (%1)] but %0 wont be an constant => no preprocess
This can be used like every 2d array, it is some nanoseconds slower through the calculation (also not worth to mention)

Or you set them in OnGameModeInit to their default value
pawn Code:
//OnGameModeInit
    for(new i, j; i != sizeof PlayerFadeText; ++i) {
        for(j = 0; j != sizeof PlayerFadeText[]; ++j) {
            PlayerFadeText[i][j] = INVALID_TEXT_DRAW;
        }
    }
Or in your example with a player based array in OnPlayerConnect
pawn Code:
//OnPlayerConnect
    for(new i; i != sizeof PlayerFadeText[]; ++i) {
        PlayerFadeText[playerid][i] = INVALID_TEXT_DRAW;
    }
Reply


Messages In This Thread
how to set a default array value to a var with 2 agruments? (when creating it globally) - by Donya - 04.06.2011, 15:30
AW: how to set a default array value to a var with 2 agruments? (when creating it globally) - by Nero_3D - 04.06.2011, 16:49
Re: how to set a default array value to a var with 2 agruments? (when creating it globally) - by Donya - 04.06.2011, 17:15

Forum Jump:


Users browsing this thread: 1 Guest(s)