Padarom

dynamic Report v1.12

Feb 19th, 2012
866
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 21.30 KB | None | 0 0
  1. #include <a_samp>
  2. /*                       _
  3.                         | |
  4.          _ __   __ _  __| | __ _ _ __ ___  _ __ ___
  5.         | '_ \ / _` |/ _` |/ _` | '__/ _ \| '_ ` _ \
  6.         | |_) | (_| | (_| | (_| | | | (_) | | | | | |
  7.         | .__/ \__,_|\__,_|\__,_|_|  \___/|_| |_| |_|
  8.         | |             dynamic Report v1.12
  9.         |_|
  10.     Dieses Script stammt komplett von Padarom. Lediglich die optional nutzbaren
  11.     Includes dini (von DracoBlue) und mysql (von Strickenkid) sind kein
  12.     Teil seines Werkes.
  13.     Das Script darf nur auf www.sa-mp.de und seinen Unterseiten zum
  14.     Download angeboten werden (außer mit Erlaubnis von Padarom).
  15.    
  16.     Es darf weder zum Verkauf angeboten, noch als das eigene Werk
  17.     ausgegeben werden.
  18.     --------------------------------------------------------------
  19.    
  20.    
  21.     Nachfolgend könnt ihr alles variable im Script einstellen.
  22.     Was welche Zeile bewirkt, könnt ihr im Kommentar dahinter nachlesen.
  23.    
  24.     Benötigt ihr einige Sachen nicht, klammert die entsprechende Zeile einfach aus (Mit zwei // am Anfang der Zeile).
  25. */
  26.  
  27. #define click_used                      // Soll ein Reportdialog kommen, wenn man per TAB auf einen Spieler klickt?
  28. #define used        2                   // Die Zahl je nach bevorzugter Speicherart ändern. 1 = MySQL, 2 = dini, 3 = fwrite-Funktionen
  29. #define admin_send                      // Soll jedem RCON-Admin eine Nachricht bei Reports gesendet werden?
  30. #define dini_path   "reports"           // Ordner in dem die Reports gespeichert werden, wenn andere Speicherungsart als MySQL verwendet wird.
  31.                                         // Falls nicht benötigt einfach ignorieren.
  32.  
  33. #if used == 1           // Falls die folgenden Zeilen nicht benötigt werden: Einfach ignorieren.
  34.     #define mysql_host  "localhost"     // MySQL Hostname
  35.     #define mysql_name  "username"      // MySQL Loginname
  36.     #define mysql_pw    "password"      // MySQL Passwort
  37.     #define mysql_db    "database"      // MySQL Datenbankname
  38. #endif
  39.  
  40. #if defined admin_send  // Falls zwischen Gamemode und Filterscript NICHT kommuniziert werden soll, bei pvar_name "abcd" und bei pvar_minlvl 1 eintragen.
  41.     #define pvar_name   "Adminlevel"    // PVar-Name des Adminlevels im Gamemode.
  42.     #define pvar_minlvl 2               // Minimales benötigtes Adminlevel.
  43. #endif
  44.  
  45. #if used == 2
  46.     #include <dini>                     // Name der dini-Include
  47. #endif
  48. #if used == 1
  49.     #include <mysql>                    // Name eurer MySQL-Include
  50. #endif
  51.  
  52. #define dialog1 100     // Die Dialog-ID's am besten nur ändern, wenn eine bekannte
  53. #define dialog2 101     // Überschneidung mit den Dialog-ID's im Gamemode besteht.
  54. #define dialog3 102
  55. #define dialog4 103
  56. #define dialog5 104
  57. #define dialog6 105
  58. #define dialog7 106
  59. #define dialog8 107
  60.  
  61.  
  62. //  Ab hier NICHTS mehr bearbeiten, sofern ihr die Scriptsprache PAWN nicht beherrscht oder nichts am Script ändern wollt.
  63. forward ReportPlayer(playerid, reportedid, reason[], description[]);
  64. new ID[50];
  65.  
  66. public OnFilterScriptInit()
  67. {
  68.     #if used == 1
  69.         mysql_connect(mysql_host, mysql_name, mysql_pw, mysql_db);
  70.         new query[256] = "CREATE TABLE [IF NOT EXISTS] `reports` (";
  71.         strcat(query, "`id` INT NOT NULL AUTO_INCREMENT ,");
  72.         strcat(query, "`reporter` VARCHAR( 24 ) NOT NULL ,");
  73.         strcat(query, "`reported` VARCHAR( 24 ) NOT NULL ,");
  74.         strcat(query, "`reason` VARCHAR( 24 ) NOT NULL ,");
  75.         strcat(query, "`description` VARCHAR( 68 ) NOT NULL ,");
  76.         strcat(query, "`time` VARCHAR( 24 ) NOT NULL ,");
  77.         strcat(query, "`read` INT( 2 ) ,");
  78.         strcat(query, "PRIMARY KEY ( `id` ))");
  79.         mysql_query(query);
  80.     #endif
  81.     print("-Ø  Dynamisches Report-System von Padarom  Ø-");
  82.     return 1;
  83. }
  84.  
  85. public OnPlayerText(playerid, text[])
  86. {
  87.     if(GetPVarInt(playerid, "inChat") == 1)
  88.     {
  89.         new pName[24], msg[128];
  90.         GetPlayerName(playerid, pName, 24);
  91.         format(msg, 128, "[ %s: %s ]", pName, text);
  92.         SendClientMessage(playerid, 0x2FABEDFF, msg);
  93.         SendClientMessage(GetPVarInt(playerid,"ticketPartner"), 0x2FABEDFF, msg);
  94.         return 0;
  95.     }
  96.     return 1;
  97. }
  98.  
  99. public OnPlayerConnect(playerid)
  100. {
  101.     SetPVarInt(playerid, "subject", -1);
  102.     SetPVarString(playerid, "reportreason", "");
  103.     SetPVarInt(playerid, "ticketPartner", -1);
  104.     return 1;
  105. }
  106.  
  107. public OnPlayerDisconnect(playerid, reason)
  108. {
  109.     if(GetPVarInt(playerid, "inChat") == 1)
  110.     {
  111.         SendClientMessage(GetPVarInt(playerid,"ticketPartner"), 0x2FABEDFF, "[ * Dein Ticketpartner ist offline gegangen. Das Ticket wurde beendet. ]");
  112.         SetPVarInt(GetPVarInt(playerid,"ticketPartner"),"inChat", 0);
  113.         SetPVarInt(GetPVarInt(playerid,"ticketPartner"),"ticketPartner", -1);
  114.     }
  115.     return 1;
  116. }
  117.  
  118. public OnPlayerCommandText(playerid, cmdtext[])
  119. {
  120.     if(!strcmp(cmdtext,"/report",false) || !strcmp(cmdtext,"/melden",false))
  121.     {
  122.         ShowPlayerDialog(playerid, dialog1, DIALOG_STYLE_LIST, "Beschwerde", "Hacken\nVerstoß gegen die Regeln\nBeleidigung\nAbwerben\nSpam\nIch möchte nur die Admins nerven", "Weiter", "Abbrechen");
  123.         return 1;
  124.     }
  125.     if(!strcmp(cmdtext,"/showtickets",false) || !strcmp(cmdtext,"/tickets",false) || !strcmp(cmdtext,"/checkreports",false))
  126.     {
  127.         if(!IsPlayerAdmin(playerid) && GetPVarInt(playerid, pvar_name) < pvar_minlvl) return SendClientMessage(playerid, 0xEDB90CFF, "* Du hast keine Berechtigungen um diesen Command zu nutzen.");
  128.         ShowTicketDialog(playerid);
  129.         return 1;
  130.     }
  131.     if(!strcmp(cmdtext,"/tchat"))
  132.     {
  133.         if(GetPVarInt(playerid,"ticketPartner") != -1 && GetPVarInt(playerid,"inChat") == 0)
  134.         {
  135.             SetPVarInt(playerid,"inChat",1);
  136.             SetPVarInt(GetPVarInt(playerid,"ticketPartner"),"inChat",1);
  137.             SendClientMessage(playerid, 0xEDB90CFF, "* Du hast den Ticketchat angenommen. Du kannst nun mit dem Admin reden.");
  138.             SendClientMessage(GetPVarInt(playerid,"ticketPartner"), 0xEDB90CFF, "* Dein Ticketchat wurde gestartet. Du kannst nun mit dem Verfasser des Tickets reden.");
  139.         }
  140.         else if(GetPVarInt(playerid,"inChat") == 1)
  141.         {
  142.             SendClientMessage(playerid, 0xEDB90CFF, "* Du hast den Ticketchat beendet.");
  143.             SendClientMessage(GetPVarInt(playerid,"ticketPartner"), 0xEDB90CFF, "* Dein aktiver Ticketchat wurde beendet.");
  144.             SetPVarInt(playerid,"inChat",0);
  145.             SetPVarInt(GetPVarInt(playerid,"ticketPartner"),"inChat",0);
  146.             SetPVarInt(GetPVarInt(playerid,"ticketPartner"),"ticketPartner",-1);
  147.             SetPVarInt(playerid,"ticketPartner",-1);
  148.         }
  149.         else SendClientMessage(playerid, 0xEDB90CFF, "* Du hast aktuell keinen Ticketchat am Laufen.");
  150.         return 1;
  151.     }
  152.     return 0;
  153. }
  154.  
  155. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  156. {
  157.     if(dialogid == dialog1 && response)
  158.     {
  159.         switch(listitem)
  160.         {
  161.             case 0: SetPVarString(playerid, "reason", "Hacken");
  162.             case 1: SetPVarString(playerid, "reason", "Regelverstoß");
  163.             case 2: SetPVarString(playerid, "reason", "Beleidigung");
  164.             case 3: SetPVarString(playerid, "reason", "Abwerben");
  165.             case 4: SetPVarString(playerid, "reason", "Spam");
  166.             case 5: return SendClientMessage(playerid, 0xEDB90CFF, "* Wenigstens bist du ehrlich ;)");
  167.         }
  168.         if(GetPVarInt(playerid, "subject") == -1) ShowPlayerDialog(playerid, dialog2, DIALOG_STYLE_INPUT, "Beschwerde - Seite 2", "Bitte gib nun den Namen oder die ID des zu meldenden Spielers an.", "Weiter", "Zurück");
  169.         else ShowPlayerDialog(playerid, dialog3, DIALOG_STYLE_INPUT, "Beschwerde - Seite 3", "Bitte gib nun eine kurze Beschreibung zu deiner Beschwerde an.", "Weiter", "Zurück");
  170.     }
  171.     else if(dialogid == dialog2)
  172.     {
  173.         if(response)
  174.         {
  175.             new sName[24];
  176.             if(!IsNumeric(inputtext))
  177.             {
  178.                 for(new i=0; i<MAX_PLAYERS; i++)
  179.                 {
  180.                     if(IsPlayerConnected(i))
  181.                     {
  182.                         GetPlayerName(i, sName, 24);
  183.                         if(!strcmp(inputtext, sName, true))
  184.                         {
  185.                             SetPVarInt(playerid, "subject", i);
  186.                             break;
  187.                         }
  188.                     }
  189.                 }
  190.                 if(GetPVarInt(playerid,"subject") == -1) return ShowPlayerDialog(playerid, dialog2, DIALOG_STYLE_INPUT, "Beschwerde - Seite 2", "Bitte gib nun den Namen oder die ID des zu meldenden Spielers an.", "Weiter", "Zurück");
  191.             }
  192.             else
  193.             {
  194.                 if(!IsPlayerConnected(strval(inputtext)) || !strlen(inputtext)) return ShowPlayerDialog(playerid, dialog2, DIALOG_STYLE_INPUT, "Beschwerde - Seite 2", "Bitte gib nun den Namen oder die ID des zu meldenden Spielers an.", "Weiter", "Zurück");
  195.                 else SetPVarInt(playerid, "subject", strval(inputtext));
  196.             }
  197.             ShowPlayerDialog(playerid, dialog3, DIALOG_STYLE_INPUT, "Beschwerde - Seite 3", "Bitte gib nun eine kurze Beschreibung zu deiner Beschwerde an.", "Weiter", "Zurück");
  198.         }
  199.         else return ShowPlayerDialog(playerid, dialog1, DIALOG_STYLE_LIST, "Beschwerde", "Hacken\nVerstoß gegen die Regeln\nBeleidigung\nAbwerben\nSpam\nIch möchte nur die Admins nerven", "Weiter", "Abbrechen");
  200.     }
  201.     else if(dialogid == dialog3)
  202.     {
  203.         if(response)
  204.         {
  205.             if(!strlen(inputtext)) return ShowPlayerDialog(playerid, dialog3, DIALOG_STYLE_INPUT, "Beschwerde - Seite 3", "Bitte gib nun eine kurze Beschreibung zu deiner Beschwerde an.", "Weiter", "Zurück");
  206.             else
  207.             {
  208.                 new text[256], sName[24], reason[24], description[128];
  209.                 SetPVarString(playerid, "description", inputtext);
  210.                 GetPlayerName(GetPVarInt(playerid, "subject"), sName, 24);
  211.                 GetPVarString(playerid, "reason", reason, 24);
  212.                 GetPVarString(playerid, "description", description, 128);
  213.                 format(text, 256, "{ED9E15}Spieler: {FFFFFF}%s (ID: %i)\n{ED9E15}Grund: {FFFFFF}%s\n{ED9E15}Beschreibung: {FFFFFF}%s\n\nWenn diese Beschwerde korrekt ist, klicke bitte auf Absenden. Ansonsten auf Abbrechen.", sName, GetPVarInt(playerid, "subject"), reason, description);
  214.                 ShowPlayerDialog(playerid, dialog4, DIALOG_STYLE_MSGBOX, "Beschwerde - Abschluss", text, "Absenden", "Abbrechen");
  215.             }
  216.         }
  217.         else return ShowPlayerDialog(playerid, dialog2, DIALOG_STYLE_INPUT, "Beschwerde - Seite 2", "Bitte gib nun den Namen oder die ID des zu meldenden Spielers an.", "Weiter", "Zurück");
  218.     }
  219.     else if(dialogid == dialog4)
  220.     {
  221.         if(!response) return SetPVarInt(playerid, "subject", -1);
  222.         new reason[24], description[64];
  223.         GetPVarString(playerid, "reason", reason, 24);
  224.         GetPVarString(playerid, "description", description, 64);
  225.         ReportPlayer(playerid, GetPVarInt(playerid, "subject"), reason, description);
  226.         SendClientMessage(playerid, 0xEDB90CFF, "* Deine Beschwerde wurde erfolgreich eingereicht.");
  227.         SetPVarInt(playerid, "subject", -1);
  228.     }
  229.     else if(dialogid == dialog5)
  230.     {
  231.         if(!response) return 1;
  232.         new autor[256], subject[256], description[256], reason[256], time[256];
  233.         new path[68], text[500], string[128];
  234.         #if used == 1
  235.             #pragma unused string
  236.             format(path, 68, "SELECT * FROM reports WHERE id = %i", ID[listitem]);
  237.             mysql_query(path);
  238.             mysql_store_result();
  239.             mysql_fetch_field("reason", reason);
  240.             mysql_fetch_field("time", time);
  241.             mysql_fetch_field("subject", subject);
  242.             mysql_fetch_field("description", description);
  243.             mysql_fetch_field("reporter", autor);
  244.             mysql_free_result();
  245.             format(path, 68, "UPDATE reports SET read = 1 WHERE id = %i", ID[listitem]);
  246.             mysql_query(path);
  247.         #endif
  248.         #if used == 2
  249.             #pragma unused string
  250.             format(path, 68, "/%s/%i.ini", dini_path, ID[listitem]);
  251.             autor = dini_Get(path, "reporter");
  252.             subject = dini_Get(path, "subject");
  253.             description = dini_Get(path, "description");
  254.             reason = dini_Get(path, "reason");
  255.             time = dini_Get(path, "time");
  256.             dini_IntSet(path, "read", 1);
  257.             SetPVarInt(playerid,"sTicket",ID[listitem]);
  258.             #endif
  259.         #if used == 3
  260.             format(path, 68, "/%s/%i.txt", dini_path, ID[listitem]);
  261.             new File:report = fopen(path, io_read);
  262.             while(fread(report, string))
  263.             {
  264.                 string[strlen(string)-1] = '\0';
  265.                 if(strfind(string, "subject", true) != -1) { strdel(string, 0, 8); subject = string; }
  266.                 if(strfind(string, "time", true) != -1) { strdel(string, 0, 5); time = string; }
  267.                 if(strfind(string, "reason", true) != -1) { strdel(string, 0, 7); reason = string; }
  268.                 if(strfind(string, "description", true) != -1) { strdel(string, 0, 12); description = string; }
  269.                 if(strfind(string, "reporter", true) != -1) { strdel(string, 0, 9); autor = string; }
  270.             }
  271.             fclose(report);
  272.             fremove(path);
  273.             report = fopen(path, io_readwrite);
  274.             format(text, 256, "reporter=%s\r\nsubject=%s\r\nreason=%s\r\ndescription=%s\r\ntime=%s\r\nread=1", autor, subject, reason, description, time);
  275.             fwrite(report, text);
  276.             fclose(report);
  277.             SetPVarInt(playerid,"sTicket",ID[listitem]);
  278.         #endif
  279.         new bool:online, pName[24];
  280.         for(new i=0; i<MAX_PLAYERS; i++)
  281.         {
  282.             if(IsPlayerConnected(i))
  283.             {
  284.                 GetPlayerName(i, pName, 24);
  285.                 if(!strcmp(pName, autor, true, strlen(pName)))
  286.                 {
  287.                     online = true;
  288.                     SetPVarInt(playerid,"ticketReady",1);
  289.                     SetPVarInt(playerid,"ticketPartner",i);
  290.                     break;
  291.                 }
  292.             }
  293.         }
  294.         if(online == true) format(text, 500, "{ED9E15}Beschwerde verfasst (am %s Uhr) von {FFFFFF}%s\n{ED9E15}Spieler: {FFFFFF}%s\n{ED9E15}Grund: {FFFFFF}%s\n{ED9E15}Beschreibung: {FFFFFF}%s\n\nDer Autor des Tickets ist aktuell online. Um dich mit ihm zu unterhalten, klicke auf den rechten Button.", time, autor, subject, reason, description);
  295.         else format(text, 500, "{ED9E15}Beschwerde verfasst (am %s Uhr) von {FFFFFF}%s\n{ED9E15}Spieler: {FFFFFF}%s\n{ED9E15}Grund: {FFFFFF}%s\n{ED9E15}Beschreibung: {FFFFFF}%s\n\nDer Autor des Tickets ist aktuell offline. Wenn du dich mit ihm unterhalten willst, musst du dich noch ein bisschen gedulden.", time, autor, subject, reason, description);
  296.         if(online == true) ShowPlayerDialog(playerid, dialog6, DIALOG_STYLE_MSGBOX, "Beschwerde", text, "Zurück", "Chat");
  297.         else ShowPlayerDialog(playerid, dialog6, DIALOG_STYLE_MSGBOX, "Beschwerde", text, "Zurück", "Zurück");
  298.        
  299.     }
  300.     else if(dialogid == dialog6)
  301.     {
  302.         if(!response && GetPVarInt(playerid,"ticketReady") == 0) { ShowTicketDialog(playerid); SetPVarInt(playerid,"sTicket",-1); }
  303.         else if(!response && GetPVarInt(playerid,"ticketReady") == 1)
  304.         {
  305.             new msg[128], pName[24];
  306.             SetPVarInt(GetPVarInt(playerid,"ticketPartner"),"ticketPartner",playerid);
  307.             SetPVarInt(playerid, "ticketReady", 0);
  308.             GetPlayerName(playerid, pName, 24);
  309.             format(msg, 128, "* Der Admin %s möchte gerne bezüglich deiner Beschwerde mit dir sprechen. Tippe /tchat, sobald du Zeit hast.", pName);
  310.             SendClientMessage(GetPVarInt(playerid,"ticketPartner"), 0xEDB90CFF, msg);
  311.             GetPlayerName(GetPVarInt(playerid,"ticketPartner"), pName, 24);
  312.             format(msg, 128, "* Eine Ticketchat-Anfrage wurde an %s verschickt. Bitte warte, bis er sie akzeptiert.", pName);
  313.             SendClientMessage(playerid, 0xEDB90CFF, msg);
  314.         }
  315.         else if(response)
  316.         {
  317.             SetPVarInt(playerid, "ticketPartner", 0);
  318.             SetPVarInt(playerid, "ticketReady", 0);
  319.             ShowPlayerDialog(playerid, dialog7, DIALOG_STYLE_MSGBOX, "Löschen der Beschwerde", "Du hast die Beschwerde nun eingesehen.\nWillst du sie löschen?", "Ja", "Nein");
  320.         }
  321.     }
  322.     else if(dialogid == dialog7)
  323.     {
  324.         if(response)
  325.         {
  326.             new path[68];
  327.             #if used == 1
  328.                 format(path, 68, "DELETE FROM reports WHERE id = %i", GetPVarInt(playerid,"sTicket"));
  329.                 mysql_query(path);
  330.             #endif
  331.             #if used == 2
  332.                 format(path, 68, "/%s/%i.ini", dini_path, GetPVarInt(playerid,"sTicket"));
  333.                 dini_Remove(path);
  334.             #endif
  335.             #if used == 3
  336.                 format(path, 68, "/%s/%i.txt", dini_path, GetPVarInt(playerid,"sTicket"));
  337.                 fremove(path);
  338.             #endif
  339.             ShowTicketDialog(playerid);
  340.             SendClientMessage(playerid, 0xEDB90CFF, "* Das Ticket wurde erfolgreich gelöscht.");
  341.             SetPVarInt(playerid, "sTicket", 0);
  342.         }
  343.         else ShowTicketDialog(playerid);
  344.     }
  345.     return 1;
  346. }
  347.  
  348. public OnPlayerClickPlayer(playerid, clickedplayerid)
  349. {
  350.     #if defined click_used
  351.         SetPVarInt(playerid, "subject", clickedplayerid);
  352.         ShowPlayerDialog(playerid, dialog1, DIALOG_STYLE_LIST, "Beschwerde - Seite 1", "Hacken\nVerstoß gegen die Regeln\nBeleidigung\nAbwerben\nSpam\nIch möchte nur die Admins nerven", "Weiter", "Abbrechen");
  353.     #endif
  354.     return 1;
  355. }
  356.  
  357. ShowTicketDialog(playerid)
  358. {
  359.         new i=0, count=0, path[68], msg[1028] = "", cat[128], bool:exists;
  360.         new reason[256], date[256], subject[256], read[256], string[82];
  361.         #if used == 1
  362.             #pragma unused string
  363.             do
  364.             {
  365.                 i++;
  366.                 format(path, 68, "SELECT * FROM reports WHERE id = %i", i);
  367.                 mysql_query(path);
  368.                 mysql_store_result();
  369.                 if(mysql_num_rows())
  370.                 {
  371.                     ID[count] = i;
  372.                     count++;
  373.                     exists = true;
  374.                     mysql_fetch_field("reason", reason);
  375.                     mysql_fetch_field("time", date);
  376.                     mysql_fetch_field("subject", subject);
  377.                     mysql_fetch_field("read", read);
  378.                     if(strval(read)) format(cat, 68, "{ED9E15}%s {FFFFFF}%s: %s\n", date, subject, reason);
  379.                     else format(cat, 68,"{ED9E15}%s {ED1515}%s: %s\n", date, subject, reason);
  380.                     strcat(msg, cat);
  381.                     mysql_free_result();
  382.                 }
  383.                 else mysql_free_result();
  384.             }
  385.             while(i<50);
  386.             if(!exists) return ShowPlayerDialog(playerid, dialog8, DIALOG_STYLE_MSGBOX, "Beschwerden", "Es sind aktuell keine Beschwerden eingetragen.", "Okay", "Nicht okay");
  387.             ShowPlayerDialog(playerid, dialog5, DIALOG_STYLE_LIST, "Beschwerden", msg, "Auswählen", "Abbrechen");
  388.         #endif
  389.         #if used == 2
  390.             #pragma unused string
  391.             do
  392.             {
  393.                 i++;
  394.                 format(path, 68, "/%s/%i.ini", dini_path, i);
  395.                 if(dini_Exists(path))
  396.                 {
  397.                     ID[count] = i;
  398.                     count++;
  399.                     exists = true;
  400.                     reason = dini_Get(path, "reason");
  401.                     date = dini_Get(path, "time");
  402.                     subject = dini_Get(path, "subject");
  403.                     read = dini_Get(path, "read");
  404.                     if(strval(read)) format(cat, 68, "{ED9E15}%s {FFFFFF}%s: %s\n", date, subject, reason);
  405.                     else format(cat, 68,"{ED9E15}%s {ED1515}%s: %s\n", date, subject, reason);
  406.                     strcat(msg, cat);
  407.                 }
  408.             }
  409.             while(i<50);
  410.             if(!exists) return ShowPlayerDialog(playerid, dialog8, DIALOG_STYLE_MSGBOX, "Beschwerden", "Es sind aktuell keine Beschwerden eingetragen.", "Okay", "Nicht okay");
  411.             ShowPlayerDialog(playerid, dialog5, DIALOG_STYLE_LIST, "Beschwerden", msg, "Auswählen", "Abbrechen");
  412.         #endif
  413.         #if used == 3
  414.             do
  415.             {
  416.                 i++;
  417.                 format(path, 68, "/%s/%i.txt", dini_path, i);
  418.                 if(fexist(path))
  419.                 {
  420.                     ID[count] = i;
  421.                     count++;
  422.                     exists = true;
  423.                     new File:report = fopen(path, io_read);
  424.                     while(fread(report, string))
  425.                     {
  426.                         if(strfind(string, "subject", true) != -1) { string[strlen(string)-1] = '\0'; strdel(string, 0, 8); subject = string; }
  427.                         if(strfind(string, "time", true) != -1) {  string[strlen(string)-1] = '\0'; strdel(string, 0, 5);date = string; }
  428.                         if(strfind(string, "reason", true) != -1) { string[strlen(string)-1] = '\0'; strdel(string, 0, 7); reason = string; }
  429.                         if(strfind(string, "read", true) != -1) { strdel(string, 0, 5); read = string; }
  430.                     }
  431.                     if(strval(read)) format(cat, 68, "{ED9E15}%s {FFFFFF}%s: %s\n", date, subject, reason);
  432.                     else format(cat, 68,"{ED9E15}%s {ED1515}%s: %s\n", date, subject, reason);
  433.                     strcat(msg, cat);
  434.                     fclose(report);
  435.                 }
  436.             }
  437.             while(i<50);
  438.             if(!exists) return ShowPlayerDialog(playerid, dialog8, DIALOG_STYLE_MSGBOX, "Beschwerden", "Es sind aktuell keine Beschwerden eingetragen.", "Okay", "Nicht okay");
  439.             ShowPlayerDialog(playerid, dialog5, DIALOG_STYLE_LIST, "Beschwerden", msg, "Auswählen", "Abbrechen");
  440.         #endif
  441.         return 1;
  442. }
  443.  
  444. stock IsNumeric(const string[])
  445. {
  446.     new length=strlen(string);
  447.     if(length==0)
  448.     {
  449.         return 0;
  450.     }
  451.     for (new i=0; i<length; i++)
  452.     {
  453.         if (!((string[i] <= '9' && string[i] >= '0') || (i==0 && (string[i]=='-' || string[i]=='+'))))
  454.         {
  455.             return false;
  456.         }
  457.     }
  458.     return 1;
  459. }
  460.  
  461. public ReportPlayer(playerid, reportedid, reason[], description[])
  462. {
  463.     new path[256], i=0, pName[24], sName[24], msg[128], date[24];
  464.     GetPlayerName(playerid, pName, 24);
  465.     GetPlayerName(reportedid, sName, 24);
  466.     new y, m, d, h, minu;
  467.     getdate(y, m, d);
  468.     gettime(h, minu);
  469.     format(date, 24, "%02i.%02i.%i %02i:%02i", d, m, y, h, minu);
  470.     #if used == 1
  471.         #pragma unused i
  472.         mysql_real_escape_string(pName, pName);
  473.         mysql_real_escape_string(sName, sName);
  474.         mysql_real_escape_string(description, description);
  475.         format(path, 128, "INSERT INTO reports (reporter, subject, reason, description, time) VALUES (%s, %s, %s, %s, %s)", pName, sName, reason, description, date);
  476.         mysql_query(path);
  477.     #endif
  478.     #if used == 2
  479.         do {
  480.             i++;
  481.             format(path, 68, "/%s/%i.ini", dini_path, i);
  482.         }
  483.         while(dini_Exists(path));
  484.         dini_Create(path);
  485.         dini_Set(path, "reporter", pName);
  486.         dini_Set(path, "subject", sName);
  487.         dini_Set(path, "reason", reason);
  488.         dini_Set(path, "description", description);
  489.         dini_Set(path, "time", date);
  490.     #endif
  491.     #if used == 3
  492.         new text[256];
  493.         do {
  494.             i++;
  495.             format(path, 68, "/%s/%i.txt", dini_path, i);
  496.         }
  497.         while(fexist(path));
  498.         new File:report = fopen(path, io_readwrite);
  499.         format(text, 256, "reporter=%s\r\nsubject=%s\r\nreason=%s\r\ndescription=%s\r\ntime=%s\r\nread=0", pName, sName, reason, description, date);
  500.         fwrite(report, text);
  501.         fclose(report);
  502.     #endif
  503.     #if defined admin_send
  504.         for(new a=0; a<MAX_PLAYERS; a++)
  505.         {
  506.             if(IsPlayerConnected(a) && (IsPlayerAdmin(a) || GetPVarInt(a, pvar_name)>pvar_minlvl))
  507.             {
  508.                 format(msg, 128, "* %s (ID: %i) hat %s (ID: %i) gemeldet. Nutze /tickets um das Ticket zu überprüfen.", pName, playerid, sName, reportedid);
  509.                 SendClientMessage(a, 0xEDB90CFF, msg);
  510.             }
  511.         }
  512.     #endif
  513.     return 1;
  514. }
Advertisement
Add Comment
Please, Sign In to add comment