Not all reports displayed
#1

Hey!

I have a problem of where I use for example /admins, /reportlist or /banlist, in this case /reportlist and it just shows first player on that list..

Thats my /reportlist command.

https://pastebin.com/fPp2G6NP
Reply
#2

You are using an if statement which only returns once.
try to use a while loop.
Код:
while(rows)
{
}
Reply
#3

Doesnt work @jasperschellekens
Reply
#4

can someone actually help me or u all newbies.. wtf
Reply
#5

NoteND, he mentioned the right idea in the wrong place.

What needs to be done is the following.
Код:
format(string,sizeof(string), "%s\r\nUsername: %s | Reason: %s", string, name, reason);
SendClientMessage(playerid, -1, string);
SendClientMessage(playerid, -1, " ");
You format only single statement. In here you need to cycle through row amount somehow, perhaps something like that under if(rows) condition and after declaring new variables:
Код:
SendClientMessage(playerid, -1, " ");
SendClientMessage(playerid, -1, "{33CCFF}:::::::::: {FFFFFF}Report List {33CCFF}::::::::::");
for(new i = 0; i < rows; i++)
{
   cache_get_value_name(i, "Username", name);
   cache_get_value_name(i, "Reason", reason);
   format(string,sizeof(string), "%s\r\nUsername: %s | Reason: %s", string, name, reason);
   SendClientMessage(playerid, -1, string);
   SendClientMessage(playerid, -1, " ");
}
Never worked with SQL, so that might be partially incorrect, verify it is and then check it out.

P.S. Learn to be a bit more respectful towards fellow scripters, or next time they might think twice about helping you.
Reply
#6

doesnt work maxandmov
Reply
#7

Quote:
Originally Posted by NoteND
Посмотреть сообщение
doesnt work maxandmov
What it doesn't work? It still shows you only a single report? or it doesn't?
Reply
#8

Quote:
Originally Posted by NoteND
Посмотреть сообщение
can someone actually help me or u all newbies.. wtf
Congratulations! i will never help you again. Do it yourself you rude prick
Reply
#9

do it like this:
Код:
 new string[256], rows, query[256];
    if(pInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not authorized to use this command.");
    mysql_format(Database, query, sizeof(query), "SELECT * FROM `reports`");
    mysql_query(Database, query);
    cache_get_row_count(rows);
    new name[256], reason[128];
    for(new index = 0; index < rows; index++)
    {
        cache_get_value_name(index, "Username", name);
        cache_get_value_name(index, "Reason", reason);
        SendClientMessage(playerid, -1, " ");
        SendClientMessage(playerid, -1, "{33CCFF}:::::::::: {FFFFFF}Report List {33CCFF}::::::::::");
        format(string,sizeof(string), "Username: %s | Reason: %s", name, reason);
        SendClientMessage(playerid, -1, string);
        SendClientMessage(playerid, -1, " ");
    }
    if(rows <= 0)
   {
        SendClientMessage(playerid, -1, " ");
        SendClientMessage(playerid, -1, "{33CCFF}:::::::::: {FFFFFF}Report List {33CCFF}::::::::::");
        SendClientMessage(playerid, COLOR_ORANGE, "Report list is currently empty.");
        SendClientMessage(playerid, -1, " ");
    }
this should work

if this doesn't work then show us your output and reports table, and make sure there are reports in the table, if there are no reports then it wont work so first check your table again.

edit:
also why do you have \r\n in SendClientMessage? it wouldnt make difference because \r nor \n work in SendClientMessage
change that line to format(string,sizeof(string), "Username: %s | Reason: %s", name, reason);

secondly you also have %s for string, why are you sending the string again? this would just 2x the amount of reports and display duplicate messages.
I dont know what you are trying to accomplish with those messages here.
Reply
#10

Quote:
Originally Posted by NoteND
Посмотреть сообщение
can someone actually help me or u all newbies.. wtf
I coded what you need. Click here
+REP PLZZ!!1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)