SA-MP Forums Archive
Errors. Help me please. - 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: Errors. Help me please. (/showthread.php?tid=504931)



Errors. Help me please. - Mriss - 06.04.2014

Firstly - Errors

Код:
C:\Users\Bradley\Desktop\SA-MP\gamemodes\cnr.pwn(1597) : error 008: must be a constant expression; assumed zero
C:\Users\Bradley\Desktop\SA-MP\gamemodes\cnr.pwn(1597) : error 029: invalid expression, assumed zero
C:\Users\Bradley\Desktop\SA-MP\gamemodes\cnr.pwn(1597) : error 017: undefined symbol "score"
C:\Users\Bradley\Desktop\SA-MP\gamemodes\cnr.pwn(1597) : fatal error 107: too many error messages on one line
Secondly - Script
pawn Код:
CMD:top5(playerid, params[])
{
    mysql_tquery(MysqlCon, "SELECT user, Score FROM `players` ORDER BY `Score` DESC LIMIT 5", "OnTop5Show", "i", playerid);
    return 1;
}

forward OnTop5Show(playerid);
public OnTop5Show(playerid) {
    new rows, fields;
    cache_get_data(rows, fields);
    new top[rows][24], score[rows][6]
    for(new i=0;i<rows;i++) {
        cache_get_row(i, 0, top[i]);
        cache_get_row(i, 1, score[i]);
    }
    printf("Rank 1: %s, Rank 2: %s, Rank 3: %s, Rank 4: %s, Rank 5: %s", top[0], top[1], top[2], top[3], top[4], top[5]);
}
Please Tell me whats wrong + fix


Re: Errors. Help me please. - Konstantinos - 06.04.2014

It'd be helpful if you could mention the line so users won't search for it.

Anyways, you cannot add size to an array with a not constant. rows is a variable; hence:
pawn Код:
new top[rows][24], score[rows][6]
will give the errors. Since you know that you want a TOP 5, change to:
pawn Код:
new top[5][24], score[5][6];
PS: size 5 makes 0-4 as valid bounds. Keep that in mind!


Re: Errors. Help me please. - Mriss - 06.04.2014

Thanks, Luv ya <3