Help with command
#1

It shows only 1 player, how can i make it for all?

Код:
if (strcmp(cmdtext, "/richlist") == 0)
    {
            new sendername[MAX_PLAYER_NAME], cashstring[128], fstring[128];
            for(new i = 0; i<MAX_PLAYERS; i++)
            {
            if(GetPlayerMoney(i) >= 25000000)
            {
            GetPlayerName(i, sendername, sizeof(sendername));
            format(cashstring, sizeof(cashstring), "{ffffff}Name:{beea1a} %s {ffffff}Cash: {00e0e5}%s\n", sendername, DecimalPoint(GetPlayerMoney(i)));
            strcat(fstring, cashstring, sizeof(fstring));
			}
        	}
         ShowPlayerDialog(playerid, 3133, DIALOG_STYLE_LIST, "Rich Players", cashstring, "Close", "");
    return 1;
    }
Reply
#2

try that..
pawn Код:
if (strcmp(cmdtext, "/richlist") == 0)
    {
            new sendername[MAX_PLAYER_NAME], cashstring[128], fstring[128];
            for(new i = 0; i<MAX_PLAYERS; i++)
            {
            if(GetPlayerMoney(i) >= 25000000)
            {
            GetPlayerName(i, sendername, sizeof(sendername));
            format(cashstring, sizeof(cashstring), "{ffffff}Name:{beea1a} %s {ffffff}Cash: {00e0e5}%s\n", sendername, DecimalPoint(GetPlayerMoney(i)));
            strcat(fstring, cashstring, sizeof(fstring));
            }
            }
         ShowPlayerDialog(playerid, 3133, DIALOG_STYLE_LIST, "Rich Players", fstring, "Close", "");
    return 1;
    }
Reply
#3

It shows money only for the first player.
Reply
#4

if (strcmp(cmdtext, "/richlist") == 0)
{
new sendername[MAX_PLAYER_NAME], cashstring[128], fstring[128];
for(new i = 0; i<MAX_PLAYERS; i++)
{
if(GetPlayerMoney(i) >= 25000000)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(cashstring, sizeof(cashstring), "{ffffff}Name:{beea1a} %s {ffffff}Cash: {00e0e5}%s\n", sendername, DecimalPoint(GetPlayerMoney(i)));
strcat(fstring, cashstring, sizeof(fstring));
format(cashstring, sizeof(cashstring), "{ffffff}Cash: {00e0e5}%s\n", sendername, DecimalPoint(GetPlayerMoney(i)));
strcat(fstring, cashstring, sizeof(fstring));
}
}
ShowPlayerDialog(playerid, 3133, DIALOG_STYLE_LIST, "Rich Players", fstring, "Close", "");
return 1;
}
Reply
#5

Still doesn't work:
Reply
#6

pawn Код:
if (strcmp(cmdtext, "/richlist") == 0)
    {
            new sendername[MAX_PLAYER_NAME], cashstring[128];
            for(new i = 0; i<MAX_PLAYERS; i++)
            {
            if(GetPlayerMoney(i) >= 25000000)
            {
            GetPlayerName(i, sendername, sizeof(sendername));
            format(cashstring, sizeof(cashstring), "%s{ffffff}Name:{beea1a} %s {ffffff}Cash: {00e0e5}%s\n", cashstring, sendername, DecimalPoint(GetPlayerMoney(i)));
            }
            }
         ShowPlayerDialog(playerid, 3133, DIALOG_STYLE_LIST, "Rich Players", cashstring, "Close", "");
    return 1;
    }
Reply
#7

pawn Код:
if (strcmp(cmdtext, "/richlist") == 0)
    {
            new sendername[MAX_PLAYER_NAME], cashstring[1000];
            for(new i = 0; i<MAX_PLAYERS; i++)
            {
            if(GetPlayerMoney(i) >= 25000000)
            {
            GetPlayerName(i, sendername, sizeof(sendername));
            format(cashstring, sizeof(cashstring), "%s{ffffff}Name:{beea1a} %s {ffffff}Cash: {00e0e5}%s\n", cashstring, sendername, DecimalPoint(GetPlayerMoney(i)));
            }
            }
         ShowPlayerDialog(playerid, 3133, DIALOG_STYLE_LIST, "Rich Players", cashstring, "Close", "");
    return 1;
    }
Reply
#8

Thanks guys now its working.
Reply
#9

well, no one exactly explained what the problem was, you will probably create more of this kind of bugs later on, problem was definition of string "cashstring", it was set to maximum 128 characters, and that is ok if you will print that string with SendClientMessage, but in situations like this, you'll need more than 128 characters, as you can see Dziugsas changed string size to 1000 which means that it can hold 1000 characters maximum, and if you have string e.g 1024 characters, you won't be able to see last 24 characters
Reply
#10

Thanks for the explain
+1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)