SA-MP Forums Archive
Help with command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with command (/showthread.php?tid=545969)



Help with command - Stoyanov - 11.11.2014

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;
    }



Re: Help with command - Eth - 11.11.2014

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;
    }



Re: Help with command - Stoyanov - 12.11.2014

It shows money only for the first player.


Re: Help with command - RonnyCZ - 12.11.2014

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;
}


Re: Help with command - Stoyanov - 13.11.2014

Still doesn't work:


Re: Help with command - DavidBilla - 13.11.2014

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;
    }



Re: Help with command - Dziugsas - 13.11.2014

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;
    }



Re: Help with command - Stoyanov - 13.11.2014

Thanks guys now its working.


Re: Help with command - CoaPsyFactor - 13.11.2014

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


Re: Help with command - Stoyanov - 13.11.2014

Thanks for the explain
+1