Input Line Too Long
#1

Tried bumping that 2056 higher, no effect.

Edit: Altering everything I possibly can, recounting everything, etc. Updated code below.

pawn Код:
CMD:game(playerid, params[])
{
    OnBoard[playerid] = true;
    new str[2056], str2[2056], GameStatusStr[48], JoinedPlayerStr[24][48];
    switch(GameStatus)
    {
        case 0: GameStatusStr = "{33CC33}Ready for play! (/ready)";
        case 1: GameStatusStr = "{FF0000}Starting...";
        case 2: GameStatusStr = "{FFFFFF}In Progress...";
        case 3: GameStatusStr = "{DDDD00}Finished! Resetting...";
        case 4: GameStatusStr = "{FF0000}! LOCKED !";
    }
    for(new i=0; i<24; i++)
    {
        if(JoinedPlayer[i] == -1) format(JoinedPlayerStr[i], 48, "{AAAAAA}===", GetName(JoinedPlayer[i]));
        else
        {
            new Float:Health;
            GetPlayerHealth(JoinedPlayer[i], Health);
            switch(Health)
            {
                case 90..100: format(JoinedPlayerStr[i], 48, "{33CC33}%s", GetName(JoinedPlayer[i]));
                case 70..89: format(JoinedPlayerStr[i], 48, "{99CC00}%s", GetName(JoinedPlayer[i]));
                case 50..69: format(JoinedPlayerStr[i], 48, "{DDDD00}%s", GetName(JoinedPlayer[i]));
                case 20..49: format(JoinedPlayerStr[i], 48, "{FF6600}%s", GetName(JoinedPlayer[i]));
                case 1..19: format(JoinedPlayerStr[i], 48, "{FF0000}%s", GetName(JoinedPlayer[i]));
                case 0: format(JoinedPlayerStr[i], 48, "{AAAAAA}%s", GetName(JoinedPlayer[i]));
            }
        }
    }
    strcat(str, "Game Status: %s\n---------------------------------------------------\n");
    strcat(str, "%s\t%s\t%s\t%s\n");
    strcat(str, "%s\t%s\t%s\t%s\n");
    strcat(str, "%s\t%s\t%s\t%s\n");
    strcat(str, "%s\t%s\t%s\t%s\n");
    strcat(str, "%s\t%s\t%s\t%s\n");
    strcat(str, "%s\t%s\t%s\t%s");
    format(str2, sizeof(str2), str, GameStatusStr, JoinedPlayerStr[0], JoinedPlayerStr[1], JoinedPlayerStr[2], JoinedPlayerStr[3], JoinedPlayerStr[4], JoinedPlayerStr[5], JoinedPlayerStr[6], JoinedPlayerStr[7], JoinedPlayerStr[8], JoinedPlayerStr[9], JoinedPlayerStr[10], JoinedPlayerStr[11], JoinedPlayerStr[12], JoinedPlayerStr[13], JoinedPlayerStr[14], JoinedPlayerStr[15], JoinedPlayerStr[16], JoinedPlayerStr[17], JoinedPlayerStr[18], JoinedPlayerStr[19], JoinedPlayerStr[20], JoinedPlayerStr[21], JoinedPlayerStr[22], JoinedPlayerStr[23]);
    return ShowPlayerDialog(playerid, GAME_DIALOG, DIALOG_STYLE_TABLIST, "The Hunger Games 2015", str2, "Close", "");
}
Reply
#2

Why don't you use strcat. Its way more faster than format.

You need to use format only when you require to input numbers or floating values into a array/string.

So you can directly do something like this:
pawn Код:
strcat(str, GameStatusStr);
strcat(str, "\t");
strcat(str, JoinedPlayerStr[0]);
...
Reply
#3

That ^, and here:
pawn Код:
CMD:game(playerid, params[])
{
    OnBoard[playerid] = true;
    new JoinedPlayerStr[35], str[950] = "Game Status: ";
    switch(GameStatus)
    {
        case 0: strcat(str, "{33CC33}Ready for play! (/ready)");
        case 1: strcat(str, "{FF0000}Starting...");
        case 2: strcat(str, "{FFFFFF}In Progress...");
        case 3: strcat(str, "{DDDD00}Finished! Resetting...");
        case 4: strcat(str, "{FF0000}! LOCKED !");
    }
    strcat(str, "\n---------------------------------------------------\n");
    for(new i = 0; i < 24; i++)
    {
        if(!IsPlayerConnected(JoinedPlayer[i])) continue;
        new colorstring[7] = "AAAAAA";
        if(JoinedPlayer[i] != -1)
        {
            new Float:Health;
            GetPlayerHealth(JoinedPlayer[i], Health);
            if(90.0 <= Health <= 100.0) colorstring = "33CC33";
            else if(70.0 <= Health < 90.0) colorstring = "99CC00";
            else if(50.0 <= Health < 70.0) colorstring = "DDDD00";
            else if(20.0 <= Health < 50.0) colorstring = "FF6600";
            else if(0.0 < Health < 20.0) colorstring = "FF0000";
        }
        format(JoinedPlayerStr, sizeof(JoinedPlayerStr), (!((i + 1) % 4) && i != 23) ? ("{%s}%s\n") : ("{%s}%s\t"), colorstring, GetName(JoinedPlayer[i]));
        strcat(str, JoinedPlayerStr);
    }
    return ShowPlayerDialog(playerid, GAME_DIALOG, DIALOG_STYLE_TABLIST, "The Hunger Games 2015", str, "Close", "");
}
Reply
#4

Quote:
Originally Posted by Threshold
Посмотреть сообщение
That ^, and here:
pawn Код:
CMD:game(playerid, params[])
{
    OnBoard[playerid] = true;
    new JoinedPlayerStr[35], str[950] = "Game Status: ";
    switch(GameStatus)
    {
        case 0: strcat(str, "{33CC33}Ready for play! (/ready)");
        case 1: strcat(str, "{FF0000}Starting...");
        case 2: strcat(str, "{FFFFFF}In Progress...");
        case 3: strcat(str, "{DDDD00}Finished! Resetting...");
        case 4: strcat(str, "{FF0000}! LOCKED !");
    }
    strcat(str, "\n---------------------------------------------------\n");
    for(new i = 0; i < 24; i++)
    {
        if(!IsPlayerConnected(JoinedPlayer[i])) continue;
        new colorstring[7] = "AAAAAA";
        if(JoinedPlayer[i] != -1)
        {
            new Float:Health;
            GetPlayerHealth(JoinedPlayer[i], Health);
            if(90.0 <= Health <= 100.0) colorstring = "33CC33";
            else if(70.0 <= Health < 90.0) colorstring = "99CC00";
            else if(50.0 <= Health < 70.0) colorstring = "DDDD00";
            else if(20.0 <= Health < 50.0) colorstring = "FF6600";
            else if(0.0 < Health < 20.0) colorstring = "FF0000";
        }
        format(JoinedPlayerStr, sizeof(JoinedPlayerStr), (!((i + 1) % 4) && i != 23) ? ("{%s}%s\n") : ("{%s}%s\t"), colorstring, GetName(JoinedPlayer[i]));
        strcat(str, JoinedPlayerStr);
    }
    return ShowPlayerDialog(playerid, GAME_DIALOG, DIALOG_STYLE_TABLIST, "The Hunger Games 2015", str, "Close", "");
}
Ah I see. Can I get a better explanation of the format string? Why is it set up that way?
Reply
#5

Basically, you are putting a "\n" instead of a "\t" for every 4th JoinedPlayer line. So this part:
pawn Код:
!((i + 1) % 4)
Checks if "i + 1" is divisible by 4. We exclude '23', because we don't want to add a "\n" to the last JoinedPlayer line.

This line:
pawn Код:
format(JoinedPlayerStr, sizeof(JoinedPlayerStr), (!((i + 1) % 4) && i != 23) ? ("{%s}%s\n") : ("{%s}%s\t"), colorstring, GetName(JoinedPlayer[i]));
is the same as doing this:
pawn Код:
if(!((i + 1) % 4) && i != 23) format(JoinedPlayerStr, sizeof(JoinedPlayerStr), "{%s}%s\n", colorstring, GetName(JoinedPlayer[i]));
else format(JoinedPlayerStr, sizeof(JoinedPlayerStr), "{%s}%s\t", colorstring, GetName(JoinedPlayer[i]));
Reply
#6

You could have also just done this.

Код:
	format(str2, sizeof(str2), str, GameStatusStr, JoinedPlayerStr[0], JoinedPlayerStr[1], JoinedPlayerStr[2], JoinedPlayerStr[3], JoinedPlayerStr[4], JoinedPlayerStr[5], JoinedPlayerStr[6], JoinedPlayerStr[7], JoinedPlayerStr[8], JoinedPlayerStr[9],
		JoinedPlayerStr[10], JoinedPlayerStr[11], JoinedPlayerStr[12], JoinedPlayerStr[13], JoinedPlayerStr[14], JoinedPlayerStr[15], JoinedPlayerStr[16], JoinedPlayerStr[17], JoinedPlayerStr[18], JoinedPlayerStr[19], JoinedPlayerStr[20], JoinedPlayerStr[21], JoinedPlayerStr[22], JoinedPlayerStr[23]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)