Tiny Error - 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: Tiny Error (
/showthread.php?tid=291025)
Tiny Error -
ToPhrESH - 18.10.2011
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;
}
Re: Tiny Error -
Ensconce - 18.10.2011
This is because FPSList is a global string. Create the string within the command OR strdel FPSList each time someone executes the command.
Re: Tiny Error -
ToPhrESH - 18.10.2011
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?
Re: Tiny Error -
nilanjay - 18.10.2011
Add this on the top of your script
I think this might work
Re: Tiny Error -
ToPhrESH - 18.10.2011
Quote:
Originally Posted by nilanjay
Add this on the top of your script
I think this might work
|
Can you explain to me how adding such a simple thing as:
Is going to help?
Re: Tiny Error -
nilanjay - 18.10.2011
Because its saying that you are adding a new string in to the server.
Re: Tiny Error -
ToPhrESH - 18.10.2011
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.
Re: Tiny Error -
Ensconce - 18.10.2011
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;
}
Re: Tiny Error -
ToPhrESH - 18.10.2011
Tested, and it works great. Thank you very much Ensconce.