Tiny Error
#1

I'm making an FPS list to where it displays all the FPS of all the players. I tested it and everytime i press the command "/fpslist" it displays the players. But once I close it and I type it again, it displays the same thing, twice.
Ex.
1 player typed /fpslist and it says
Player: 46
He closes and types it again and it says:
Player: 46
Player: 46
He then closes and types it a third time and it says:
Player: 46
Player: 46
Player: 46

It just continues to post it over and over.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/fpslist", cmdtext, true, 10) == 0)
    {
        for(new i = 0; i < MAX_PLAYERS; ++i)
        {
            if(IsPlayerConnected(i) && !IsPlayerNPC(i))
            {
                format(FPSList, sizeof(FPSList), "%s%s:    %d\n", FPSList, pName(i), FPS2[i]-1);
                ShowPlayerDialog(playerid, DIALOG_FPS_LIST, DIALOG_STYLE_MSGBOX, "Players FPS", FPSList, "Ok", "");
            }
        }
        return 1;
    }
    return 0;
}
Reply
#2

This is because FPSList is a global string. Create the string within the command OR strdel FPSList each time someone executes the command.
Reply
#3

Quote:
Originally Posted by Ensconce
Посмотреть сообщение
This is because FPSList is a global string. Create the string within the command OR strdel FPSList each time someone executes the command.
Mind showing me or helping me with the script? Or are you just trying to get post count?
Reply
#4

Add this on the top of your script
pawn Код:
new string [120];
I think this might work
Reply
#5

Quote:
Originally Posted by nilanjay
Посмотреть сообщение
Add this on the top of your script
pawn Код:
new string [120];
I think this might work
Can you explain to me how adding such a simple thing as:
pawn Код:
new string [120];
Is going to help?
Reply
#6

Because its saying that you are adding a new string in to the server.
Reply
#7

Quote:
Originally Posted by nilanjay
Посмотреть сообщение
Because its saying that you are adding a new string in to the server.
Adding what you said just gave me an errors saying I already had string defined.
Reply
#8

I meant that you need to create the FPSList string within the command.

Delete new FPSList from the top of your script and use the example below.

PS: Change the cell size to whatever suits your server.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/fpslist", cmdtext, true, 10) == 0)
    {
        new FPSList[128];
        for(new i = 0; i < MAX_PLAYERS; ++i)
        {
            if(IsPlayerConnected(i) && !IsPlayerNPC(i))
            {
                format(FPSList, sizeof(FPSList), "%s%s:    %d\n", FPSList, pName(i), FPS2[i]-1);
                ShowPlayerDialog(playerid, DIALOG_FPS_LIST, DIALOG_STYLE_MSGBOX, "Players FPS", FPSList, "Ok", "");
            }
        }
        return 1;
    }
    return 0;
}
Reply
#9

Tested, and it works great. Thank you very much Ensconce.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)