Guest User

Report System

a guest
Feb 15th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 11.61 KB | None | 0 0
  1. // Advance Report System
  2. // Stark.7
  3.  
  4. #include <a_samp>
  5. #include <a_mysql>
  6. #include <sscanf2>
  7. #include <zcmd>
  8. #include <colors>
  9.  
  10.  
  11. #define MAX_REPORTS                 10
  12. #define D_REPORT_MANAGER1           999
  13. #define D_REPORT_MANAGER2           888
  14. #define D_REPORT_READ1              1
  15. #define D_REPORT_DELETE1            2
  16. #define D_REPORT_READ2              3
  17. #define D_REPORT_DELETE2            4
  18. #define D_REPORT_READ3              5
  19. #define D_REPORT_DELETE3            6
  20. #define D_REPORT_READ4              7
  21. #define D_REPORT_DELETE4            8
  22. #define D_REPORT_READ5              9
  23. #define D_REPORT_DELETE5            10
  24. #define D_REPORT_READ6              11
  25. #define D_REPORT_DELETE6            12
  26. #define D_REPORT_READ7              13
  27. #define D_REPORT_DELETE7            14
  28. #define D_REPORT_READ8              15
  29. #define D_REPORT_DELETE8            16
  30. #define D_REPORT_READ9              17
  31. #define D_REPORT_DELETE9            18
  32. #define D_REPORT_READ10             19
  33. #define D_REPORT_DELETE10           20
  34. #define REP_VERSION                 "v0.1.1"
  35.  
  36. enum rData
  37. {
  38.     rID,
  39.     rPlayer[32],
  40.     rReport[1024],
  41.     rStatus
  42. }
  43. // new RData[MAX_REPORTS][rData];
  44.  
  45. /*new totalReports,;*/ new totalReports2, reportIDx, reportPlayerx[32+2], reportMessagex[1024+2], reportStatusx, cacheID;
  46. new iReportTick[MAX_PLAYERS], SQL = -1, query[1024], result[1030];
  47.  
  48. #define defined FILTERSCRIPT
  49. public OnFilterScriptInit()
  50. {
  51.     print("\n*******************************");
  52.     print(" Advance Report system samp ! ");
  53.     printf(" Advance Report system %s ! ", REP_VERSION);
  54.     print("*******************************\n");
  55.     SQL = mysql_connect("localhost", "root", "bazadedate", "", 3306);
  56.     if(mysql_errno() != 0) printf("Error conecting to database !");
  57.     mysql_log(LOG_DEBUG | LOG_WARNING, LOG_TYPE_HTML);
  58.     return 1;
  59. }
  60.  
  61. public OnFilterScriptExit()
  62. {
  63.     mysql_close(SQL);
  64.     return 1;
  65. }
  66.  
  67. main()
  68. {
  69.     print("\n--------------------------------------");
  70.     print(" Advance Report system samp ! ");
  71.     print("--------------------------------------\n");
  72. }
  73.  
  74. public OnPlayerRequestClass(playerid, classid)
  75. {
  76.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  77.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  78.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  79.     return 1;
  80. }
  81.  
  82. public OnPlayerConnect(playerid)
  83. {
  84.     return 1;
  85. }
  86.  
  87. public OnPlayerDisconnect(playerid, reason)
  88. {
  89.     return 1;
  90. }
  91.  
  92. public OnPlayerSpawn(playerid)
  93. {
  94.     return 1;
  95. }
  96.  
  97. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  98. {
  99.     switch(dialogid)
  100.     {
  101.         case D_REPORT_MANAGER1:
  102.         {
  103.             if(response)
  104.             {
  105.                 new Name[32], str[1024];
  106.                 GetPlayerName(playerid, Name, sizeof(Name));
  107.                 mysql_format(SQL, query, sizeof(query), "INSERT INTO `reports`(`Player`, `Problem`) VALUES ('%s','%s')", Name, inputtext);
  108.                 mysql_query(SQL, query, true);
  109.                 cacheID = cache_insert_id();
  110.                 format(str, sizeof(str), "[DEBUG] New report: Player: %s | Problem: %s | ID: %d", Name, inputtext, cacheID);
  111.                 printf(str);
  112.                 SendClientMessage(playerid, COLOR_CONTROL, "Reportul dvs. a fost trimis echipei de admini !");
  113.                 return 1;
  114.             }
  115.         }
  116.        
  117.         case D_REPORT_MANAGER2:
  118.         {
  119.             if(listitem == 0)
  120.             {
  121.                 ShowPlayerDialog(playerid, 50, DIALOG_STYLE_LIST, "Report Options", "Read\nDelete", "Select", "");
  122.                 /*
  123.                 new str[1222];
  124.                 format(str, sizeof(str), "ID: %d | Report: %s | Player: %s | Status: %d", reportIDx, reportMessagex, reportPlayerx, reportStatusx);
  125.                 SendClientMessage(playerid, COLOR_INFO, str);
  126.                 */
  127.             }
  128.            
  129.             if(listitem == 1)
  130.             {
  131.                 ShowPlayerDialog(playerid, 51, DIALOG_STYLE_LIST, "Report Options", "Read\nDelete", "Select", "");
  132.                 /*
  133.                 new str[1222];
  134.                 format(str, sizeof(str), "ID: %d | Report: %s | Player: %s | Status: %d", reportIDx, reportMessagex, reportPlayerx, reportStatusx);
  135.                 SendClientMessage(playerid, COLOR_INFO, str);
  136.                 */
  137.             }
  138.            
  139.             if(listitem == 2)
  140.             {
  141.                 ShowPlayerDialog(playerid, 52, DIALOG_STYLE_LIST, "Report Options", "Read\nDelete", "Select", "");
  142.                 /*
  143.                 new str[1222];
  144.                 format(str, sizeof(str), "ID: %d | Report: %s | Player: %s | Status: %d", reportIDx, reportMessagex, reportPlayerx, reportStatusx);
  145.                 SendClientMessage(playerid, COLOR_INFO, str);
  146.                 */
  147.             }
  148.            
  149.             if(listitem == 3)
  150.             {
  151.                 ShowPlayerDialog(playerid, 53, DIALOG_STYLE_LIST, "Report Options", "Read\nDelete", "Select", "");
  152.                 /*
  153.                 new str[1222];
  154.                 format(str, sizeof(str), "ID: %d | Report: %s | Player: %s | Status: %d", reportIDx, reportMessagex, reportPlayerx, reportStatusx);
  155.                 SendClientMessage(playerid, COLOR_INFO, str);
  156.                 */
  157.             }
  158.            
  159.             if(listitem == 4)
  160.             {
  161.                 ShowPlayerDialog(playerid, 54, DIALOG_STYLE_LIST, "Report Options", "Read\nDelete", "Select", "");
  162.                 /*
  163.                 new str[1222];
  164.                 format(str, sizeof(str), "ID: %d | Report: %s | Player: %s | Status: %d", reportIDx, reportMessagex, reportPlayerx, reportStatusx);
  165.                 SendClientMessage(playerid, COLOR_INFO, str);
  166.                 */
  167.             }
  168.            
  169.             if(listitem == 5)
  170.             {
  171.                 ShowPlayerDialog(playerid, 55, DIALOG_STYLE_LIST, "Report Options", "Read\nDelete", "Select", "");
  172.                 /*
  173.                 new str[1222];
  174.                 format(str, sizeof(str), "ID: %d | Report: %s | Player: %s | Status: %d", reportIDx, reportMessagex, reportPlayerx, reportStatusx);
  175.                 SendClientMessage(playerid, COLOR_INFO, str);
  176.                 */
  177.             }
  178.  
  179.             if(listitem == 6)
  180.             {
  181.                 ShowPlayerDialog(playerid, 56, DIALOG_STYLE_LIST, "Report Options", "Read\nDelete", "Select", "");
  182.                 /*
  183.                 new str[1222];
  184.                 format(str, sizeof(str), "ID: %d | Report: %s | Player: %s | Status: %d", reportIDx, reportMessagex, reportPlayerx, reportStatusx);
  185.                 SendClientMessage(playerid, COLOR_INFO, str);
  186.                 */
  187.             }
  188.            
  189.             if(listitem == 7)
  190.             {
  191.                 ShowPlayerDialog(playerid, 57, DIALOG_STYLE_LIST, "Report Options", "Read\nDelete", "Select", "");
  192.                 /*
  193.                 new str[1222];
  194.                 format(str, sizeof(str), "ID: %d | Report: %s | Player: %s | Status: %d", reportIDx, reportMessagex, reportPlayerx, reportStatusx);
  195.                 SendClientMessage(playerid, COLOR_INFO, str);
  196.                 */
  197.             }
  198.            
  199.             if(listitem == 8)
  200.             {
  201.                 ShowPlayerDialog(playerid, 58, DIALOG_STYLE_LIST, "Report Options", "Read\nDelete", "Select", "");
  202.                 /*
  203.                 new str[1222];
  204.                 format(str, sizeof(str), "ID: %d | Report: %s | Player: %s | Status: %d", reportIDx, reportMessagex, reportPlayerx, reportStatusx);
  205.                 SendClientMessage(playerid, COLOR_INFO, str);
  206.                 */
  207.             }
  208.            
  209.             if(listitem == 9)
  210.             {
  211.                 ShowPlayerDialog(playerid, 59, DIALOG_STYLE_LIST, "Report Options", "Read\nDelete", "Select", "");
  212.                 /*
  213.                 new str[1222];
  214.                 format(str, sizeof(str), "ID: %d | Report: %s | Player: %s | Status: %d", reportIDx, reportMessagex, reportPlayerx, reportStatusx);
  215.                 SendClientMessage(playerid, COLOR_INFO, str);
  216.                 */
  217.             }
  218.         }
  219.        
  220.         case 50, 51, 52, 53, 54, 55:
  221.         {
  222.             if(listitem == 0) // D_REPORT_READ1
  223.             {
  224.                 new str[1222];
  225.                 format(str, sizeof(str), "ID: %d | Report: %s | Player: %s | Status: %d", reportIDx, reportMessagex, reportPlayerx, reportStatusx);
  226.                 ShowPlayerDialog(playerid, D_REPORT_READ1, DIALOG_STYLE_MSGBOX, "Read Report", str, "Back", "");
  227.             }
  228.            
  229.             if(listitem == 1) // D_REPORT_DELETE1
  230.             {
  231.                 ShowPlayerDialog(playerid, D_REPORT_DELETE1, DIALOG_STYLE_MSGBOX, "Delete Report", "Esti sigur ca vrei stergi acest report?", "Delete", "Close");
  232.             }
  233.         }
  234.        
  235.         case 56, 57, 58, 59:
  236.         {
  237.             if(listitem == 0) // D_REPORT_READ1
  238.             {
  239.                 new str[1222];
  240.                 format(str, sizeof(str), "ID: %d | Report: %s | Player: %s | Status: %d", reportIDx, reportMessagex, reportPlayerx, reportStatusx);
  241.                 ShowPlayerDialog(playerid, D_REPORT_READ1, DIALOG_STYLE_MSGBOX, "Read Report", str, "Back", "");
  242.             }
  243.  
  244.             if(listitem == 1) // D_REPORT_DELETE1
  245.             {
  246.                 ShowPlayerDialog(playerid, D_REPORT_DELETE1, DIALOG_STYLE_MSGBOX, "Delete Report", "Esti sigur ca vrei stergi acest report?", "Delete", "Close");
  247.             }
  248.         }
  249.        
  250.         case D_REPORT_DELETE1:
  251.         {
  252.             mysql_format(SQL, query, sizeof(query), "DELETE FROM `reports` WHERE `ID`='%d'", reportIDx);
  253.             mysql_query(SQL, query, true);
  254.         }
  255.        
  256.         case D_REPORT_DELETE2:
  257.         {
  258.             mysql_format(SQL, query, sizeof(query), "DELETE FROM `reports` WHERE `ID`='%d'", reportIDx);
  259.             mysql_query(SQL, query, true);
  260.         }
  261.        
  262.         case D_REPORT_DELETE3:
  263.         {
  264.             mysql_format(SQL, query, sizeof(query), "DELETE FROM `reports` WHERE `ID`='%d'", reportIDx);
  265.             mysql_query(SQL, query, true);
  266.         }
  267.        
  268.         case D_REPORT_DELETE4:
  269.         {
  270.             mysql_format(SQL, query, sizeof(query), "DELETE FROM `reports` WHERE `ID`='%d'", reportIDx);
  271.             mysql_query(SQL, query, true);
  272.         }
  273.        
  274.         case D_REPORT_DELETE5:
  275.         {
  276.             mysql_format(SQL, query, sizeof(query), "DELETE FROM `reports` WHERE `ID`='%d'", reportIDx);
  277.             mysql_query(SQL, query, true);
  278.         }
  279.        
  280.         case D_REPORT_DELETE6, D_REPORT_DELETE7, D_REPORT_DELETE8, D_REPORT_DELETE9:
  281.         {
  282.             mysql_format(SQL, query, sizeof(query), "DELETE FROM `reports` WHERE `ID`='%d'", reportIDx);
  283.             mysql_query(SQL, query, true);
  284.         }
  285.     }
  286.     return 1;
  287. }
  288.  
  289. CMD:report(playerid, params[])
  290. {
  291.     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_BLUE, "[SERVER ERROR]: Nu esti conectat !");
  292.     if(IsPlayerConnected(playerid))
  293.     {
  294.         if((GetTickCount() - iReportTick[playerid]) < 60000) return SendClientMessage(playerid, COLOR_BLUE, "[SERVER ERROR]: Trebui sa astepti 60 secunde inainte de a folosi iar comanda.");
  295.         ShowPlayerDialog(playerid, D_REPORT_MANAGER1, DIALOG_STYLE_INPUT, "Report Manager", "Ce problema aveti?", "Submit", "Cancel");
  296.         iReportTick[playerid] = GetTickCount();
  297.     }
  298.     return 1;
  299. }
  300.  
  301. CMD:reports(playerid, params[])
  302. {
  303.     if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_BLUE, "[SERVER ERROR]: Nu esti conectat !");
  304.     if(IsPlayerConnected(playerid))
  305.     {
  306.         new head[128], aim[1500];
  307.         new str[48];
  308.         new Cache:result1 = mysql_query(SQL, "SELECT * FROM `reports` ORDER BY `reports`.`ID` ASC");
  309.         for(new i, j = cache_get_row_count(); i != j; ++i)
  310.         {
  311.             cache_get_field_content(i, "ID", result);           reportIDx = strval(result);
  312.             cache_get_field_content(i, "Player", result);       strmid(reportPlayerx, result, 0, sizeof(result), 32);
  313.             cache_get_field_content(i, "Problem", result);      strmid(reportMessagex, result, 0, sizeof(result), 1024);
  314.             cache_get_field_content(i, "Status", result);       reportStatusx = strval(result);
  315.             totalReports2 = cache_get_row_count();
  316.         }
  317.         cache_delete(result1);
  318.         for(new xf = 1; xf < 20; xf++)
  319.         {
  320.             if(reportStatusx == 0) strcat(str, "Read");
  321.             if(reportStatusx == 1) strcat(str, "Unread");
  322.            
  323.             format(aim, sizeof(aim),"[%d] %s [%d]", reportIDx, reportPlayerx, str);
  324.         }
  325.         if(totalReports2 >= 1)
  326.         {
  327.             format(head, sizeof(head), "%d New Reports", totalReports2);
  328.             ShowPlayerDialog(playerid, D_REPORT_MANAGER2, DIALOG_STYLE_LIST, head, aim, "Select", "Close");
  329.             SendClientMessage(playerid, COLOR_HIGHLIGHT, aim);
  330.         } else SendClientMessage(playerid, COLOR_INFO, "Nu sunt report-uri noi !");
  331.     }
  332.     return 1;
  333. }
Advertisement
Add Comment
Please, Sign In to add comment