Dialogs / question improved
#1




Header 1= Username
Header 2= Targetname
Header 3= Reason
Header 4= Date

What I want to do:

Every MYSQL info to be set inside the dialog style.


PHP код:
CMD:reports(playeridparams[])
{
    if(
pInfo[playerid][pAdminLevel] < 1) return SendClientMessage(playerid,-1,""COL_RED"Nu detii functia administrativa necesara!");
    
mysql_tquery(handle"SELECT * FROM `reportlog`""ShowReports""d"playerid);
    
ShowPlayerDialog(playeridDIALOG_REPORTSDIALOG_STYLE_TABLIST_HEADERS"Caption",
"Header 1\tHeader 2\tHeader 3\tHeader 4\n\
Item 1 Column 1\tItem 1 Column 2\tItem 1 Column 3\tItem 1 Column 4\n\
{FF0000}Item 2 Column 1\t{33AA33}Item 2 Column 2\tItem 2 Column 3\tItem 2 Column 4"
,
"Button 1""Button 2");
    return 
1;

But i don't know what should I type after Header4

Also, I don't know how to set "case" to show the same Option for every report inside the dialog
Reply
#2

not sure about the limit, as for dialog in /reports use strcat
pawn Код:
#define DIALOG_UNUSED 1

CMD:reports(playerid, params[])
{
    if(pInfo[playerid][pAdminLevel] < 1) return SendClientMessage(playerid,-1,""COL_RED"Not Admin!");
    mysql_tquery(mysql, "SELECT * FROM `reportlog`", "ShowReports", "d", playerid);
    return 1;
}

forward ShowReports(playerid);
public ShowReports(playerid)
{
    new rows, fields, handlingarray[500];
    cache_get_data(rows, fields, handle);
    if(rows != 0)
    {
        strcat(handlingarray, "Username\t\tTargetname\t\tReason\t\tDate");
        for(new i = 0; i < rows; i++)
        {
            new reporter[MAX_PLAYER_NAME], reported[MAX_PLAYER_NAME], reportid, reportedon[25], reportreason[25], showreps[200];
            reportid = cache_get_field_content_int(i, "ID");
            cache_get_field_content(i, "Username", reporter);
            cache_get_field_content(i, "Targetname", reported);
            cache_get_field_content(i, "Data", reportedon);
            cache_get_field_content(i, "Report", reportreason);
            format(showreps, sizeof(showreps), "%s\t\t%s\t\t%s\t\t%s", reporter, reported, reportreason, reportdon);
            strcat(handlingarray, showreps);
        }
        ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_TABLIST_HEADERS, "Reports", handlingarray, "OK", "");
    }
    else if(rows == 0)
    {
        SendClientMessage(playerid, RED, "There are currently no reports!");
    }
    return 1;
}
Reply
#3

It shows only ONE report instead of all of them.

PHP код:
    {
        
strcat(handlingarray"ID\tUsername\t\tTargetname\t\tReason\t\tDate");
            
format(showrepssizeof(showreps), "%i\t%s\t\t%s\t\t%s\t\t%s",reportidreporterreportedreportreasonreportedon); 
But it show only ID, username, Targetname, Reason without date

and at ID it shows very bugged, like it would be "date"

Reply
#4

sorry did silly mistake forgot "\n"
pawn Код:
forward ShowReports(playerid);
public ShowReports(playerid)
{
    new rows, fields, handlingarray[500];
    cache_get_data(rows, fields, handle);
    if(rows != 0)
    {
        strcat(handlingarray, "ID\tUsername\t\tTargetname\t\tReason\t\tDate\n");
        for(new i = 0; i < rows; i++)
        {
            new reporter[MAX_PLAYER_NAME], reported[MAX_PLAYER_NAME], reportid, reportedon[25], reportreason[25], showreps[200];
            reportid = cache_get_field_content_int(i, "ID");
            cache_get_field_content(i, "Username", reporter);
            cache_get_field_content(i, "Targetname", reported);
            cache_get_field_content(i, "Data", reportedon);
            cache_get_field_content(i, "Report", reportreason);
            format(showreps, sizeof(showreps), "%i\t%s\t\t%s\t\t%s\t\t%s\n", reportid, reporter, reported, reportreason, reportdon);
            strcat(handlingarray, showreps);
        }
        ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_TABLIST_HEADERS, "Reports", handlingarray, "OK", "");
    }
    else if(rows == 0)
    {
        SendClientMessage(playerid, RED, "There are currently no reports!");
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by ReD_HunTeR
Посмотреть сообщение
sorry did silly mistake forgot "\n"
pawn Код:
forward ShowReports(playerid);
public ShowReports(playerid)
{
    new rows, fields, handlingarray[500];
    cache_get_data(rows, fields, handle);
    if(rows != 0)
    {
        strcat(handlingarray, "ID\tUsername\t\tTargetname\t\tReason\t\tDate\n");
        for(new i = 0; i < rows; i++)
        {
            new reporter[MAX_PLAYER_NAME], reported[MAX_PLAYER_NAME], reportid, reportedon[25], reportreason[25], showreps[200];
            reportid = cache_get_field_content_int(i, "ID");
            cache_get_field_content(i, "Username", reporter);
            cache_get_field_content(i, "Targetname", reported);
            cache_get_field_content(i, "Data", reportedon);
            cache_get_field_content(i, "Report", reportreason);
            format(showreps, sizeof(showreps), "%i\t%s\t\t%s\t\t%s\t\t%s\n", reportid, reporter, reported, reportreason, reportdon);
            strcat(handlingarray, showreps);
        }
        ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_TABLIST_HEADERS, "Reports", handlingarray, "OK", "");
    }
    else if(rows == 0)
    {
        SendClientMessage(playerid, RED, "There are currently no reports!");
    }
    return 1;
}
Well it doesn't show the DATA column
beside that it's too "small"

and shall I increase the size of handlingarray because it doesn't show everything

Reply
#6

oh well, i have just checked limits of header https://sampwiki.blast.hk/wiki/Limits its 4
and yea consider increasing holdingarray to 1000 or something so u can see rest of the lines
Reply
#7

I'd also advise changing

Код:
mysql_tquery(mysql, "SELECT * FROM `reportlog`", "ShowReports", "d", playerid);
to

Код:
mysql_tquery(mysql, "SELECT * FROM `reportlog` ORDER BY ID DESC LIMIT 100", "ShowReports", "d", playerid);
If you have a few thousand bans further down the line the command may take a few seconds to display the dialog depending on the specs of the server you'll be running it on, the query above will display the last 100 bans by ordering them by id in a descending order.
Reply
#8

Thank you both! I have other question


PHP код:
CMD:acceptreport(playeridparams[])
{
    if(
pInfo[playerid][pAdminLevel] < 1) return SendClientMessage(playerid,-1,""COL_RED"Not Admin!");
    new 
str[128], Cache:delreprepid;
    if(
sscanf(params"i"repid)) return SendClientMessage(playerid, -1"Usage: /acceptreport [Report ID]");
    
mysql_format(handlestrsizeof(str), "SELECT * FROM `reportlog` WHERE `ID` = '%d'"repid);
    
delrep mysql_query(handlestrtrue);
    new 
count cache_num_rows();
    if(
count 0)
    {
    
mysql_format(handlestrsizeof(str), "DELETE FROM `reportlog` WHERE `ID` = '%d'"repid);
    
mysql_query(handlestrfalse);
    
format(strsizeof(str), "You have accepted the report ID: [#%d]"repid);
    
SendClientMessage(playeridCOLOR_YELLOWstr);
    }
    else return 
SendClientMessage(playeridCOLOR_YELLOW"Report ID not valide!");
    
cache_delete(delrep);
    return 
1;

How can I:
  • Get the Username of the ID? ex
    PHP код:
    You have accepted the report ID: %d  from user: %
  • How can I SendClientMessage to targetid? (to the username who reported, doesn't matter if he is online or offline)
Reply
#9

You'd have to fetch the Username and store it in a variable before you delete the row.

Код:
new tmpName[MAX_PLAYER_NAME];
cache_get_field_content(0, "Username", tmpName, handle, MAX_PLAYER_NAME);
To which you can then use tmpName when you format your string which should work just fine.

(parameters on the cache_get_field_content might be slightly incorrect as i'm not familiar with the version of mysql you're using)
Reply
#10

Quote:
Originally Posted by Chyakka
Посмотреть сообщение
You'd have to fetch the Username and store it in a variable before you delete the row.

Код:
new tmpName[MAX_PLAYER_NAME];
cache_get_field_content(0, "Username", tmpName, handle, MAX_PLAYER_NAME);
To which you can then use tmpName when you format your string which should work just fine.

(parameters on the cache_get_field_content might be slightly incorrect as i'm not familiar with the version of mysql you're using)
Argument mitchmatch

PHP код:
SendClientMessage(tmpNameCOLOR_YELLOWstr2); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)