Not all reports displayed -
NoteND - 24.03.2018
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
Re: Not all reports displayed -
jasperschellekens - 24.03.2018
You are using an if statement which only returns once.
try to use a while loop.
Re: Not all reports displayed -
NoteND - 24.03.2018
Doesnt work @jasperschellekens
Re: Not all reports displayed -
NoteND - 24.03.2018
can someone actually help me or u all newbies.. wtf
Re: Not all reports displayed -
Maxandmov - 24.03.2018
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.
Re: Not all reports displayed -
NoteND - 24.03.2018
doesnt work maxandmov
Re: Not all reports displayed -
Maximun - 24.03.2018
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?
Re: Not all reports displayed -
jasperschellekens - 24.03.2018
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
Re: Not all reports displayed -
MafiaOink - 24.03.2018
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.
Re: Not all reports displayed -
v1k1nG - 24.03.2018
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