SA-MP Forums Archive
2 errors - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: 2 errors (/showthread.php?tid=275555)



2 errors - ToPhrESH - 10.08.2011

Код:
C:\Users\Owner\Desktop\Pawno\filterscripts\Test.pwn(4822) : error 017: undefined symbol "foreach"
C:\Users\Owner\Desktop\Pawno\filterscripts\Test.pwn(4824) : error 032: array index out of bounds (variable "pName")
Here are the lines for the unidentified symbol, and tag mismatch:

pawn Код:
for(new i; i < MAX_PLAYERS; i ++)
    {
        if(IsPlayerConnected(i))
        {
            new FPSList[512];
            foreach(i)
            {
                format(FPSList, sizeof(FPSList), "%s:   %i\n", pName[MAX_PLAYER_NAME], GetPlayerFPS(i));
                ShowPlayerDialog(playerid, 55, DIALOG_STYLE_MSGBOX, "Players' FPS", FPSList, "Ok", "");
            }
        }
    }
I want the command when they type /fpslist to display EVERYONE's FPS, not only the person who typed /fpslist. So, how would I do this? I thought the above would make it work but apparently not. :S


Re: 2 errors - iJumbo - 10.08.2011

ShowPlayerDialog(i, not playerid <<<<<<<<< FAIL sorry xD


Re: 2 errors - [L3th4l] - 10.08.2011

You are using 2 loops that do the same thing. Use this:
pawn Код:
#define DIALOG_FPS_LIST (1337)

new
    FPSList[512];

for(new i = 0; i < MAX_PLAYERS; ++i)
{
    if(IsPlayerConnected(i) && !IsPlayerNPC(i))
    {
        format(FPSList, sizeof(FPSList), "%s%s:    %s\n", FPSList, pName(i), GetPlayerFPS(i));
    }
}
ShowPlayerDialog(playerid, DIALOG_FPS_LIST, DIALOG_STYLE_MSGBOX, "Players' FPS", FPSList, "Ok", "");
You will also need:
pawn Код:
stock pName(playerid)
{
    new
        iName[MAX_PLAYER_NAME];

    GetPlayerName(playerid, iName, sizeof(iName));
    return iName;
}



Re: 2 errors - ToPhrESH - 10.08.2011

Код:
C:\Users\Owner\Desktop\Pawno\filterscripts\Test.pwn(4824) : error 012: invalid function call, not a valid address
C:\Users\Owner\Desktop\Pawno\filterscripts\Test.pwn(4824) : warning 215: expression has no effect
C:\Users\Owner\Desktop\Pawno\filterscripts\Test.pwn(4824) : error 001: expected token: ";", but found ")"
C:\Users\Owner\Desktop\Pawno\filterscripts\Test.pwn(4824) : error 029: invalid expression, assumed zero
C:\Users\Owner\Desktop\Pawno\filterscripts\Test.pwn(4824) : fatal error 107: too many error messages on one line
Line 4824:

pawn Код:
format(FPSList, sizeof(FPSList), "%s%s:    %s\n", FPSList, pName(i), GetPlayerFPS(i));



Re: 2 errors - Riddick94 - 10.08.2011

pawn Код:
#define DIALOG_FPS_LIST (1337)

new FPSList[512];

for(new i = 0; i < MAX_PLAYERS; ++i)
{
    if(IsPlayerConnected(i) && !IsPlayerNPC(i))
    {
        format(FPSList, sizeof(FPSList), "%s%s:    %s\n", FPSList, pName(i), GetPlayerFPS(i));
        ShowPlayerDialog(playerid, DIALOG_FPS_LIST, DIALOG_STYLE_MSGBOX, "Players FPS", FPSList, "Ok", "");
    }
}


stock pName(playerid)
{
    new iName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, iName, sizeof(iName));
    return iName;
}



Re: 2 errors - ToPhrESH - 10.08.2011

Still the same errors.

EDIT: Never mind, thanks alot for all your help Lethal, you are a huge help. Thanks for help too Riddick94, there was an error in my pName. I fixed it.