21.12.2019, 11:37
I wrote a simulation to test it and then I saw your edit. In case you are interested: https://pastebin.com/raw/fbgDDGTi
it prints correctly:
I will give another example, I'll use format instead of a better method to copy string just for the purpose of re-formatting:
`string` will be overwritten and display only the last text we formatted which is "Banshee\n". Every time you use format, it resets the previous text and writes from the beginning. Two ways to keep the previous text and join the current:
now `string` is "Infernus\n" and then we put in string the text we just formatted + the new one "Banshee\n". Now it displays "Infernus\nBanshee\n".
The second method I mentioned in your other thread is format+strcat. `strcat` joins the text without resetting.
The overwriting happens with `admrank` variable too. Every time a player is RCON or admin in general, it keeps resetting and sets the new rank. You can try to play around with static const from the example of your other thread and I have a suggestion too.
Players loop until MAX_PLAYERS should not be used, especially if you have not re-defined MAX_PLAYERS so it loops 1000 times by default.
- y_iterate (also known as foreach) is the first alternative and most recommended.
- `GetPlayerPoolSize` is the other one.
it prints correctly:
pawn Code:
{FFFFFF}Server staff currently online:
{FFFFFF}Christopher (ID: 2) | Level: 2 | Rank: {008000}Administrator
{FFFFFF}George (ID: 3) {FF0000}RCON Admin
{FFFFFF}John (ID: 5) | Level: 1 | Rank: {FFFF00}Moderator
{FFFFFF}Robert (ID: 9) | Level: 3 | Rank: {3366FF}Manager
pawn Code:
format(string, sizeof (string), "Infernus\n");
format(string, sizeof (string), "Banshee\n");
print(string);
pawn Code:
// First method:
format(string, sizeof (string), "Infernus\n");
format(string, sizeof (string), "%sBanshee\n", string);
print(string);
The second method I mentioned in your other thread is format+strcat. `strcat` joins the text without resetting.
pawn Code:
// Second method:
format(tmp, sizeof (tmp), "Infernus\n");
strcat(string, tmp); // string now is "Infernus\n"
format(tmp, sizeof (tmp), "Banshee\n");
strcat(string, tmp); // string now is "Infernus\nBanshee\n"
print(string);
Players loop until MAX_PLAYERS should not be used, especially if you have not re-defined MAX_PLAYERS so it loops 1000 times by default.
- y_iterate (also known as foreach) is the first alternative and most recommended.
- `GetPlayerPoolSize` is the other one.