Report System
#1

Is there a way i can load reports from my mysql table? I want to make a command reports which it will load the information of the reports of the server here is my report command
pawn Код:
CMD:report(playerid,params[])
{
    new reason[60],pid,Query[120],date,month,year;
    getdate(year,month,date);
    new ReportDate = getdate();
    if(sscanf(params,"us[60]",pid,reason)) return SendClientMessage(playerid,COLOR_RED," SERVER : /report [id] [ reason ]");
    if(pid == INVALID_PLAYER_ID || !IsPlayerConnected(pid)) return ErrorMessages(playerid,2);
    SendFM(playerid,COLOR_LIGHTRED,"You have reported player %s(%d) Reason: %s",GPN(pid),pid,reason);
    mysql_format(mysql, Query, sizeof(Query), "INSERT INTO `reports` (`Name`, `Reason`, `Date`) VALUES ('%s', '%s', '%d')",GPN(pid),reason,GPN(playerid),ReportDate);
    mysql_tquery(mysql,Query);
    printf(Query);
    foreach(new i: Player)
    {
        if(pinfo[i][Admin] >= 1)
        SendFM(i,COLOR_WHITE,""COL_RED"PLAYER"COL_WHITE": %s(%d) "COL_RED"REPORTED"COL_WHITE":%s(%d) "COL_RED"REASON"COL_WHITE":%s(%d)",GPN(playerid),playerid,GPN(pid),pid,reason);
    }
    return 1;
   
}
Also another problem that i have is that at Date value of mysql format it only uploads a random 3-numbered text for example "118" instead of date
Reply
#2

PHP код:
CMD:report(playerid,params[])
{
    new 
reason[60],pid,Query[120],date,month,year;
    
getdate(year,month,date);
    new 
ReportDate getdate();
    if(
sscanf(params,"us[60]",pid,reason)) return SendClientMessage(playerid,COLOR_RED," SERVER : /report [id] [ reason ]");
    if(
pid == INVALID_PLAYER_ID || !IsPlayerConnected(pid)) return ErrorMessages(playerid,2);
    
SendFM(playerid,COLOR_LIGHTRED,"You have reported player %s(%d) Reason: %s",GPN(pid),pid,reason);
    
mysql_format(mysqlQuerysizeof(Query), "INSERT INTO `reports` (`Name`, `Reason`, `Date`) VALUES ('%s', '%s', '%s')",GPN(pid),reason,GPN(playerid),ReportDate);
    
mysql_tquery(mysql,Query);
    
printf(Query);
    foreach(new 
iPlayer)
    {
        if(
pinfo[i][Admin] >= 1)
        
SendFM(i,COLOR_WHITE,""COL_RED"PLAYER"COL_WHITE": %s(%d) "COL_RED"REPORTED"COL_WHITE":%s(%d) "COL_RED"REASON"COL_WHITE":%s(%d)",GPN(playerid),playerid,GPN(pid),pid,reason);
    }
    return 
1;
    

make date value to %s, can you tell me which mysql version are you using?
Reply
#3

R39-2
Reply
#4

try this i did not test it but it should work i think
PHP код:
CMD:reports(playerid,params[]) {
   if(
IsPlayerAdmin(playerid)) {
   new 
Query[250];
   
mysql_format(mysqlQuerysizeof(Query),"SELECT * FROM `reports` LIMIT 10"); // read player account
   
mysql_tquery(mysqlQuery"Reports""i"playerid); // to read if player account exist
   
} else return SendClientMessage(playerid,-1,"ERROR:You should be rcon to use this command"); 
 return 
1;
}
forward Reports1(playerid);
public 
Reports1(playerid) {
      new 
rowsfields;
      
cache_get_data(rowsfieldsmysql);
      if(
rows) {
      new 
string[500];
      new 
Name[MAX_PLAYER_NAME+1],Reason[128],Date[128];
      
      
cache_get_field_content(0"Name"Namemysqlsizeof(Name));
      
cache_get_field_content(0"Reason"Reasonmysqlsizeof(Reason));
      
cache_get_field_content(0"Date"Datemysqlsizeof(Date));
      
format(string,sizeof string,"Name\tReason\tDate\n\%s\t%s\t%s",Name,Reason,Date);
      
ShowPlayerDialog(playerid, -1DIALOG_STYLE_TABLIST_HEADERS"Reports",string,"Exit""");
  }

Reply
#5

Thanks for help!
I have one last question is there a way i could remove reports from table through a command for admins? after listing the reports?
Reply
#6

this should do the jop:
PHP код:
CMD:dreport(playerid,params[]) {
 if(
IsPlayerAdmin(playerid)) {
    if(
isnull(params)) return SendClientMessage(playerid,-1,"/dreport [Name]");
    new 
Query[250];
    
mysql_format(mysqlQuerysizeof(Query),"SELECT * `reports` WHERE `Name` = '%e' LIMIT 1",params); // read player account
    
mysql_tquery(mysqlQuery"DReport""i"playerid); // to read if player account exist
    
} else return SendClientMessage(playerid,-1,"ERROR:You should be rcon to use this command");
 return 
1;
}

forward DReport(playerid);
public 
DReport(playerid) {
 new 
rowsfields;
 
cache_get_data(rowsfieldsmysql);
 if(
rows)
     {
     new 
Query[250],Name[MAX_PLAYER_NAME+1];
     
cache_get_field_content(0"Name"Namemysqlsizeof(Name));
     
format(Query100"DELETE FROM `bannedips` WHERE `Name` = '%s'"Name);
     
mysql_tquery(mysqlQuery"""");
     
SendClientMessage(playerid,-1,"Report Successfully Deleted");
 } if(!
rows) {
     return 
SendClientMessage(playerid,-1,"Reported Name Not Exist on database");
    }
 return 
1;

Reply
#7

Quote:
Originally Posted by jlalt
Посмотреть сообщение
this should do the jop:
PHP код:
CMD:dreport(playerid,params[]) {
 if(
IsPlayerAdmin(playerid)) {
    if(
isnull(params)) return SendClientMessage(playerid,-1,"/dreport [Name]");
    new 
Query[250];
    
mysql_format(mysqlQuerysizeof(Query),"SELECT * `reports` WHERE `Name` = '%e' LIMIT 1",params); // read player account
    
mysql_tquery(mysqlQuery"DReport""i"playerid); // to read if player account exist
    
} else return SendClientMessage(playerid,-1,"ERROR:You should be rcon to use this command");
 return 
1;
}
forward DReport(playerid);
public 
DReport(playerid) {
 new 
rowsfields;
 
cache_get_data(rowsfieldsmysql);
 if(
rows)
     {
     new 
Query[250],Name[MAX_PLAYER_NAME+1];
     
cache_get_field_content(0"Name"Namemysqlsizeof(Name));
     
format(Query100"DELETE FROM `bannedips` WHERE `Name` = '%s'"Name);
     
mysql_tquery(mysqlQuery"""");
     
SendClientMessage(playerid,-1,"Report Successfully Deleted");
 } if(!
rows) {
     return 
SendClientMessage(playerid,-1,"Reported Name Not Exist on database");
    }
 return 
1;

I will check it out to see if it works. Though i am glad you are so helpful here is some kind +rep from me.
EDIT: I press reports and it doesnt show something!
Reply
#8

me nab xD
PHP код:
 mysql_tquery(mysqlQuery"Reports""i"playerid); // to read if player account exist 
PHP код:
forward Reports1(playerid);
public 
Reports1(playerid) { 
Reports called Report1 showed lol omg xD

PHP код:
CMD:reports(playerid,params[]) {
   if(
IsPlayerAdmin(playerid)) {
   new 
Query[250];
   
mysql_format(mysqlQuerysizeof(Query),"SELECT * FROM `reports` LIMIT 10"); // read player account
   
mysql_tquery(mysqlQuery"Reports1""i"playerid); // to read if player account exist
   
} else return SendClientMessage(playerid,-1,"ERROR:You should be rcon to use this command"); 
 return 
1;
}
forward Reports1(playerid);
public 
Reports1(playerid) {
      new 
rowsfields;
      
cache_get_data(rowsfieldsmysql);
      if(
rows) {
      new 
string[500];
      new 
Name[MAX_PLAYER_NAME+1],Reason[128],Date[128];
      
      
cache_get_field_content(0"Name"Namemysqlsizeof(Name));
      
cache_get_field_content(0"Reason"Reasonmysqlsizeof(Reason));
      
cache_get_field_content(0"Date"Datemysqlsizeof(Date));
      
format(string,sizeof string,"Name\tReason\tDate\n\%s\t%s\t%s",Name,Reason,Date);
      
ShowPlayerDialog(playerid, -1DIALOG_STYLE_TABLIST_HEADERS"Reports",string,"Exit""");
  }

in report you miss reporter name
PHP код:
    mysql_format(mysqlQuerysizeof(Query), "INSERT INTO `reports` (`Name`, `Reason`,  `Date`) VALUES ('%s', '%s', '%s', '%s')",GPN(pid),reason,GPN(playerid),ReportDate); 
should be like:
PHP код:
mysql_format(mysqlQuerysizeof(Query), "INSERT INTO `reports` (`Name`, `Reason`, `Reporter`, `Date`) VALUES ('%s', '%s', '%s', '%s')",GPN(pid),reason,GPN(playerid),ReportDate); 
and the dialog / report 1 should be edited:
PHP код:
forward Reports1(playerid);
public 
Reports1(playerid) {
      new 
rowsfields;
      
cache_get_data(rowsfieldsmysql);
      if(
rows) {
      new 
string[500];
      new 
Name[MAX_PLAYER_NAME+1],Reason[128],Date[128],Reporter[[MAX_PLAYER_NAME+1];
      
cache_get_field_content(0"Name"Namemysqlsizeof(Name));
      
cache_get_field_content(0"Reason"Reasonmysqlsizeof(Reason));
      
cache_get_field_content(0"Reporter"Reportermysqlsizeof(Reporter));
      
cache_get_field_content(0"Date"Datemysqlsizeof(Date));
      
format(string,sizeof string,"Name\tReporter\tReason\tDate\n\%s\t%s\t%s\t%s",Name,Reporter,Reason,Date);
      
ShowPlayerDialog(playerid, -1DIALOG_STYLE_TABLIST_HEADERS"Reports",string,"Exit""");
  }

Reply
#9

function for server reports
PHP код:
function ServerReports(playerid
{
      new 
rowsfields;
      
cache_get_data(rowsfieldsmysql);
      if(
rows) {
      new 
string[500];
      new 
gName[MAX_PLAYER_NAME+1],Reason[128],Date[128];
      
      
cache_get_field_content(0"Name"gNamesizeof(gName));
      
cache_get_field_content(0"Reason"Reasonsizeof(Reason));
      
cache_get_field_content(0"Date"Datesizeof(Date));
      
format(string,sizeof string,"Name\tReason\tDate\n\%s\t%s\t%s",gName,Reason,Date);
      
ShowPlayerDialog(playerid, -1DIALOG_STYLE_TABLIST_HEADERS"Reports",string,"Exit""");
  }
  return 
1;

report command
PHP код:
CMD:report(playerid,params[])
{
    new 
reason[60],pid,Query[120],date,month,year;
    
getdate(year,month,date);
    new 
ReportDate getdate();
    if(
sscanf(params,"us[60]",pid,reason)) return SendClientMessage(playerid,COLOR_RED," SERVER : /report [id] [ reason ]");
    if(
pid == INVALID_PLAYER_ID || !IsPlayerConnected(pid)) return ErrorMessages(playerid,2);
    
SendFM(playerid,COLOR_LIGHTRED,"You have reported player %s(%d) Reason: %s",GPN(pid),pid,reason);
    
mysql_format(mysqlQuerysizeof(Query), "INSERT INTO `reports` (`Name`, `Reason`, `Date`) VALUES ('%s', '%s', '%s')",GPN(pid),reason,ReportDate);
    
mysql_tquery(mysql,Query);
    
printf(Query);
    foreach(new 
iPlayer)
    {
        if(
pinfo[i][Admin] >= 1)
        
SendFM(i,COLOR_WHITE,""COL_RED"PLAYER"COL_WHITE": %s(%d) "COL_RED"REPORTED"COL_WHITE":%s(%d) "COL_RED"REASON"COL_WHITE":%s(%d)",GPN(playerid),playerid,GPN(pid),pid,reason);
    }
    return 
1;
    
}
CMD:reports(playerid,params[]) 
{
   if(
pinfo[playerid][Admin] < 1) return 0;
            new 
Query[250];
        
mysql_format(mysqlQuerysizeof(Query),"SELECT * FROM `reports` LIMIT 10"); // read player account
        
mysql_tquery(mysqlQuery"ServerReports""i"playerid); // to read if player account exist
    
return 1;

Reply
#10

this have to work well cause it tested
PHP код:
CMD:report(playerid,params[])
{
    new 
reason[60],pid,Query[120];
    if(
sscanf(params,"us[60]",pid,reason)) return SendClientMessage(playerid,COLOR_RED," SERVER : /report [id] [ reason ]");
    if(
pid == INVALID_PLAYER_ID || !IsPlayerConnected(pid)) return ErrorMessages(playerid,2);
    
SendFM(playerid,COLOR_LIGHTRED,"You have reported player %s(%d) Reason: %s",GPN(pid),pid,reason);
    new 
day1,month1,year1,Date1[128]; getdate(year1month1day1);
    
format(Date1,sizeof Date1,"%d-%d-%d",year1,month1,day1);
    
mysql_format(mysqlQuerysizeof(Query), "INSERT INTO `reports` (`Name`, `Reason`, `Date`) VALUES ('%s', '%s', '%s')",GPN(pid),reason,Date1);
    
mysql_tquery(mysql,Query);
    
printf(Query);
    foreach(new 
iPlayer)
    {
        if(
pinfo[i][Admin] >= 1)
        
SendFM(i,COLOR_WHITE,""COL_RED"PLAYER"COL_WHITE": %s(%d) "COL_RED"REPORTED"COL_WHITE":%s(%d) "COL_RED"REASON"COL_WHITE":%s(%d)",GPN(playerid),playerid,GPN(pid),pid,reason);
    }
    return 
1;

new /reports command this gonna show last 10 reports
PHP код:
CMD:reports(playerid,params[]) {
   if(
IsPlayerAdmin(playerid)) {
   new 
Query[250];
   
mysql_format(mysqlQuerysizeof(Query),"SELECT * FROM `reports`"); // read player account
   
mysql_tquery(mysqlQuery"Reports1""i"playerid); // to read if player account exist
   
return 1;
   } else return 
SendClientMessage(playerid,-1,"ERROR:You should be rcon to use this command");
}
forward Reports1(playerid);
public 
Reports1(playerid) {
      new 
rowsfields;
      
cache_get_data(rowsfieldsmysql);
      if(
rows) {
      new 
string[128],handle[1000];
      new 
Name1[MAX_PLAYER_NAME+1],Reason[128],Date[128];
      
strcat(handle,"Name\tReason\tDate");
      if(
cache_get_row_count(mysql) >= 10) {
      
cache_get_row(cache_get_row_count()-10Name1); cache_get_row(cache_get_row_count()-12Reason); cache_get_row(cache_get_row_count()-13Date);
      
format(string,sizeof string,"\n\%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
      
cache_get_row(cache_get_row_count()-20Name1);  cache_get_row(cache_get_row_count()-22Reason); cache_get_row(cache_get_row_count()-23Date);
      
format(string,sizeof string,"\n\%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
      
cache_get_row(cache_get_row_count()-30Name1); cache_get_row(cache_get_row_count()-32Reason); cache_get_row(cache_get_row_count()-33Date);
      
format(string,sizeof string,"\n\%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
      
cache_get_row(cache_get_row_count()-40Name1); cache_get_row(cache_get_row_count()-42Reason); cache_get_row(cache_get_row_count()-43Date);
      
format(string,sizeof string,"\n\%s\t%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
      
cache_get_row(cache_get_row_count()-50Name1); cache_get_row(cache_get_row_count()-52Reason); cache_get_row(cache_get_row_count()-53Date);
      
format(string,sizeof string,"\n\%s\t%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
      
cache_get_row(cache_get_row_count()-60Name1); cache_get_row(cache_get_row_count()-62Reason); cache_get_row(cache_get_row_count()-63Date);
      
format(string,sizeof string,"\n\%s\t%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
      
cache_get_row(cache_get_row_count()-70Name1); cache_get_row(cache_get_row_count()-72Reason); cache_get_row(cache_get_row_count()-73Date);
      
format(string,sizeof string,"\n\%s\t%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
      
cache_get_row(cache_get_row_count()-80Name1); cache_get_row(cache_get_row_count()-82Reason); cache_get_row(cache_get_row_count()-83Date);
      
format(string,sizeof string,"\n\%s\t%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
      
cache_get_row(cache_get_row_count()-90Name1); cache_get_row(cache_get_row_count()-92Reason); cache_get_row(cache_get_row_count()-93Date);
      
format(string,sizeof string,"\n\%s\t%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
      
cache_get_row(cache_get_row_count()-100Name1); cache_get_row(cache_get_row_count()-102Reason); cache_get_row(cache_get_row_count()-103Date);
      
format(string,sizeof string,"\n\%s\t%s\t%s\t%s",Name1,Reason,Date); strcat(handle,string);
      return 
ShowPlayerDialog(playerid3654DIALOG_STYLE_TABLIST_HEADERS"Reports",handle,"Exit""");
      }
      if(
cache_get_row_count() >= 10) {
      
cache_get_row(100Name1); cache_get_row(102Reason); cache_get_row(103Date);
      
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
      
strcat(handle,string);}
      if(
cache_get_row_count() >= 9) {
      
cache_get_row(80Name1); cache_get_row(82Reason); cache_get_row(83Date);
      
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
      
strcat(handle,string);}
      if(
cache_get_row_count() >= 8) {
      
cache_get_row(70Name1); cache_get_row(72Reason); cache_get_row(73Date);
      
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
      
strcat(handle,string);}
      if(
cache_get_row_count() >= 7) {
      
cache_get_row(60Name1); cache_get_row(62Reason); cache_get_row(63Date);
      
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
      
strcat(handle,string);}
      if(
cache_get_row_count() >= 6) {
      
cache_get_row(50Name1); cache_get_row(52Reason); cache_get_row(53Date);
      
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
      
strcat(handle,string);}
      if(
cache_get_row_count() >= 5) {
      
cache_get_row(40Name1); cache_get_row(42Reason); cache_get_row(43Date);
      
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
      
strcat(handle,string);}
      if(
cache_get_row_count() >= 4) {
      
cache_get_row(30Name1); cache_get_row(32Reason); cache_get_row(33Date);
      
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
      
strcat(handle,string);}
      if(
cache_get_row_count() >= 3) {
      
cache_get_row(20Name1); cache_get_row(22Reason); cache_get_row(23Date);
      
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
      
strcat(handle,string);}
      if(
cache_get_row_count() >= 2) {
      
cache_get_row(10Name1);cache_get_row(12Reason); cache_get_row(13Date);
      
format(string,sizeof string,"\n%s\t%s\t%s\t%s",Name1,Reason,Date);
      
strcat(handle,string);}
      if(
cache_get_row_count() >= 1) {
      
cache_get_row(00Name1); cache_get_row(02Reason); cache_get_row(03Date);
      
format(string,sizeof string,"\n\%s\t%s\t%s\t%s",Name1,Reason,Date);
      
strcat(handle,string);}
      
ShowPlayerDialog(playerid3654DIALOG_STYLE_TABLIST_HEADERS"Reports",handle,"Exit""");
      }
      if(!
rows) {
      
SendClientMessage(playerid,-1,"There Are no Reports at this moment");
   }
      return 
1;

now i'll fix the dreport :c, also i hope this both gonna work :d

and here we go delete report:
PHP код:
CMD:dreport(playerid,params[]) {
     if(
IsPlayerAdmin(playerid)) {
     if(
isnull(params)) return SendClientMessage(playerid,-1,"usage /dreport [name]");
     new 
Query[250];
     
mysql_format(mysqlQuerysizeof(Query),"SELECT * FROM `reports` WHERE `Name` = '%e'",params); // read player account
     
mysql_tquery(mysqlQuery"DeleteReport""i"playerid); // to read if player account exist
     
} else return SendClientMessage(playerid,-1,"ERROR:You should be rcon to use this command");
     return 
1;
}
forward DeleteReport(playerid);
public 
DeleteReport(playerid){
 new 
rowsfields;
 
cache_get_data(rowsfieldsmysql);
 if(
rows)
     {
     new 
Query[250],Name1[MAX_PLAYER_NAME+1];
     
cache_get_field_content(0"Name"Name1mysqlsizeof(Name1));
     
format(Query100"DELETE FROM `reports` WHERE `Name` = '%s'"Name1);
     
mysql_tquery(mysqlQuery"""");
     
SendClientMessage(playerid,-1,"Report Successfully Deleted");
 } if(!
rows) {
     return 
SendClientMessage(playerid,-1,"Name Not Exist on database");
    }
 return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)