Advertisement
Guest User

Reportsystem

a guest
Oct 21st, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.71 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #define DIALOG_REPORT 12345
  4. #define DIALOG_BESCHWERDE 23456
  5. #define DIALOG_SUPPORT 23457
  6. #define DIALOG_BUG 23458
  7. #define DIALOG_ABBRECHEN 23459
  8.  
  9. #define weiß 0xFFFFFFAA
  10. #define rot 0xFF0000FF
  11. #define orange 0xFF9300FF
  12.  
  13. #include <a_samp>
  14. #include <ocmd>
  15. #include <dini>
  16.  
  17.  
  18.  
  19. public OnFilterScriptInit()
  20. {
  21.     print("\n--------------------------------------");
  22.     print(" Reportsystem");
  23.     print("--------------------------------------\n");
  24.     return 1;
  25. }
  26.  
  27.  
  28. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  29. {
  30.     if(dialogid == DIALOG_REPORT)
  31.     {
  32.         if(response == 1)
  33.         {
  34.             if(listitem == 0)
  35.             {
  36.                 ShowPlayerDialog(playerid,DIALOG_BESCHWERDE,DIALOG_STYLE_INPUT,"Report System - Beschwerde","Gib bitte nun deine Beschwerde ein:","Bestätigen","Abbrechen");
  37.                 return 1;
  38.             }
  39.             if(listitem == 1)
  40.             {
  41.                 ShowPlayerDialog(playerid,DIALOG_SUPPORT,DIALOG_STYLE_INPUT,"Report System - Support","Gib bitte nun deine Frage ein:","Bestätigen","Abbrechen");
  42.                 return 1;
  43.             }
  44.             if(listitem == 2)
  45.             {
  46.                 ShowPlayerDialog(playerid,DIALOG_BUG,DIALOG_STYLE_INPUT,"Report System - Bug Meldung","Gib bitte nun den Bug ein:","Bestätigen","Abbrechen");
  47.                 return 1;
  48.             }
  49.         }
  50.         if(response == 0)
  51.         {
  52.             ShowPlayerDialog(playerid,DIALOG_ABBRECHEN,DIALOG_STYLE_MSGBOX,"Report System - Abbrechen","Du verlässt nun das Report System!","Bestätigen","Zurück");
  53.         }
  54.     }
  55.     if(dialogid == DIALOG_BESCHWERDE)
  56.     {
  57.         if(response == 1)
  58.         {
  59.             new string[128];
  60.             SendClientMessage(playerid,orange,"Dein Beschwerde wurde abgespeichert und wurde an die Administratoren weitergeleitet!");
  61.             format(string,sizeof(string),"[REPORT-SYSTEM]: %s hat eine Beschwerde eingesendet: [ %s ]",Name(playerid),inputtext);
  62.             AdminNachricht(rot,string);
  63.             SetPVarInt(playerid,"Report",1);
  64.         }
  65.         if(response == 0)
  66.         {
  67.             ShowPlayerDialog(playerid,DIALOG_ABBRECHEN,DIALOG_STYLE_MSGBOX,"Report System - Abbrechen","Du verlässt nun das Report System!","Bestätigen","Zurück");
  68.         }
  69.     }
  70.     if(dialogid == DIALOG_SUPPORT)
  71.     {
  72.         if(response == 1)
  73.         {
  74.             new string[128];
  75.             SendClientMessage(playerid,orange,"Deine Support Anfrage wurde abgespeichert und wurde an die Administratoren weitergeleitet!");
  76.             format(string,sizeof(string),"[REPORT-SYSTEM]: %s hat eine Support Anfrage eingesendet: [ %s ]",Name(playerid),inputtext);
  77.             AdminNachricht(rot,string);
  78.             SetPVarInt(playerid,"Report",1);
  79.         }
  80.         if(response == 0)
  81.         {
  82.             ShowPlayerDialog(playerid,DIALOG_ABBRECHEN,DIALOG_STYLE_MSGBOX,"Report System - Abbrechen","Du verlässt nun das Report System!","Bestätigen","Zurück");
  83.         }
  84.     }
  85.     if(dialogid == DIALOG_BUG)
  86.     {
  87.         if(response == 1)
  88.         {
  89.             new string[128];
  90.             SendClientMessage(playerid,orange,"Deine Bug Meldung wurde abgespeichert und wurde an die Administratoren weitergeleitet!");
  91.             format(string,sizeof(string),"[REPORT-SYSTEM]: %s hat eine Bug Meldung eingesendet: [ %s ]",Name(playerid),inputtext);
  92.             AdminNachricht(rot,string);
  93.             SetPVarInt(playerid,"Report",1);
  94.         }
  95.         if(response == 0)
  96.         {
  97.             ShowPlayerDialog(playerid,DIALOG_ABBRECHEN,DIALOG_STYLE_MSGBOX,"Report System - Abbrechen","Du verlässt nun das Report System!","Bestätigen","Zurück");
  98.         }
  99.     }
  100.     if(dialogid == DIALOG_ABBRECHEN)
  101.     {
  102.         if(response == 0)
  103.         {
  104.             ShowPlayerDialog(playerid,DIALOG_REPORT,DIALOG_STYLE_LIST,"Report System","Beschwerde\nSupport\nBug Meldung","Weiter","Abbrechen");
  105.         }
  106.     }
  107.     return 1;
  108. }
  109.  
  110. ocmd:report(playerid,params[])
  111. {
  112.     ShowPlayerDialog(playerid,DIALOG_REPORT,DIALOG_STYLE_LIST,"Report System","Beschwerde\nSupport\nBug Meldung","Weiter","Abbrechen");
  113.     return 1;
  114. }
  115.  
  116. ocmd:oreport(playerid,params[])
  117. {
  118.     new pID, string[128];
  119.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,rot,"Du bist kein Admin und hast nicht das Recht Reports zu öffnen!");
  120.     if(sscanf(params,"u",pID)) return SendClientMessage(playerid,weiß,"/oreport [ID]");
  121.     format(string,sizeof(string),"** Administrator %s hat deinen Report geöffnet und bearbeitet ihn nun. Der Live Chat wurde aktiviert, nutze /rc!",Name(playerid));
  122.     SendClientMessage(pID,orange,string);
  123.     SendClientMessage(playerid,orange,"Du hast den Report geöffnet und beginnst den Live Chat, du schreibst mit /ra!");
  124.     SetPVarInt(playerid,"LiveChat",1);
  125.     SetPVarInt(pID,"LiveChat",1);
  126.     SetPVarInt(pID,"Report",0);
  127.     SetPVarInt(playerid,"RPartner",pID);
  128.     SetPVarInt(pID,"RPartner",playerid);
  129.     return 1;
  130. }
  131. ocmd:sreport(playerid,params[])
  132. {
  133.     new pID, string[128];
  134.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,rot,"Du bist kein Admin und hast nicht das Recht Reports zu schließen!");
  135.     if(sscanf(params,"u",pID)) return SendClientMessage(playerid,weiß,"/sreport [ID]");
  136.     format(string,sizeof(string),"** Administrator %s hat den Livechat beendet.",Name(playerid));
  137.     SendClientMessage(pID,orange,string);
  138.     SendClientMessage(playerid,orange,"Du hast den Report geschlossen!");
  139.     SetPVarInt(playerid,"LiveChat",0);
  140.     SetPVarInt(pID,"LiveChat",0);
  141.     DeletePVar(playerid,"RPartner");
  142.     DeletePVar(pID,"RPartner");
  143.     return 1;
  144. }
  145. ocmd:lreport(playerid,params[])
  146. {
  147.     new pID, string[128];
  148.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,rot,"Du bist kein Admin und hast nicht das Recht Reports zu schließen!");
  149.     if(sscanf(params,"u",pID)) return SendClientMessage(playerid,weiß,"/lreport [ID]");
  150.     format(string,sizeof(string),"** Administrator %s hat deinen Report gelöscht!",Name(playerid));
  151.     SendClientMessage(pID,orange,string);
  152.     SendClientMessage(playerid,orange,"Du hast den Report gelöscht!");
  153.     DeletePVar(pID,"Report");
  154.     return 1;
  155. }
  156. ocmd:rc(playerid,params[])
  157. {
  158.     new text[128],string[128],string1[128];
  159.     if(GetPVarInt(playerid,"LiveChat") != 1) return SendClientMessage(playerid,rot,"Du bist in keinem Live Chat!");
  160.     if(sscanf(params,"s",text)) return SendClientMessage(playerid,weiß,"/rc [text]");
  161.     format(string,sizeof(string),"[LIVECHAT]: %s: %s",Name(playerid),text);
  162.     SendClientMessage(GetPVarInt(playerid,"RPartner"),orange,string);
  163.     format(string1,sizeof(string1),"[LIVECHAT]: %s: %s",Name(playerid),text);
  164.     SendClientMessage(playerid,orange,string1);
  165.     return 1;
  166. }
  167. ocmd:ra(playerid,params[])
  168. {
  169.     new text[128],string[128],string1[128];
  170.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,rot,"Du bist kein Admin und hast nicht das Recht den Admin Report Chat zu nutzen!");
  171.     if(GetPVarInt(playerid,"LiveChat") != 1) return SendClientMessage(playerid,rot,"Du bist in keinem Live Chat!");
  172.     if(sscanf(params,"s",text)) return SendClientMessage(playerid,weiß,"/ra [text]");
  173.     format(string,sizeof(string),"[LIVECHAT]: %s: %s",Name(playerid),text);
  174.     SendClientMessage(GetPVarInt(playerid,"RPartner"),orange,string);
  175.     format(string1,sizeof(string1),"[LIVECHAT]: %s: %s",Name(playerid),text);
  176.     SendClientMessage(playerid,orange,string1);
  177.     return 1;
  178. }
  179. ocmd:reports(playerid,params[])
  180. {
  181.     #pragma unused params
  182.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,rot,"Du bist kein Admin und hast nicht das Recht Reports zu sehen!");
  183.     for(new i = 0; i < MAX_PLAYERS; i++)
  184.     {
  185.         if(GetPVarInt(i,"Report") == 1 && IsPlayerConnected(i))
  186.         {
  187.             new string[128];
  188.             format(string,sizeof(string),"[REPORT-SYSTEM][OFFEN] Name: %s | ID: %i",Name(i), i);
  189.             SendClientMessage(playerid,weiß,string);
  190.         }
  191.     }
  192.     return 1;
  193. }
  194. ocmd:reporthilfe(playerid,params[])
  195. {
  196.     #pragma unused params
  197.     if(!IsPlayerAdmin(playerid))
  198.     {
  199.         SendClientMessage(playerid,weiß,"Report Hilfe: /report /rc");
  200.         return 1;
  201.     }
  202.     else
  203.     {
  204.         SendClientMessage(playerid,weiß,"Report Hilfe: /report /rc");
  205.         SendClientMessage(playerid,weiß,"Report Hilfe: /sreport /oreport /lreport /reports");
  206.         return 1;
  207.     }
  208. }
  209.  
  210. stock AdminNachricht(farbe,text[])
  211. {
  212.     for(new i = 0; i < MAX_PLAYERS; i++)
  213.     {
  214.         if(IsPlayerConnected(i) && IsPlayerAdmin(i))
  215.         {
  216.             SendClientMessage(i,farbe,text);
  217.         }
  218.     }
  219.     return 1;
  220. }
  221.  
  222. stock Name(playerid)
  223. {
  224.     new name[MAX_PLAYER_NAME];
  225.     GetPlayerName(playerid,name,sizeof(name));
  226.     return name;
  227. }
  228.  
  229. stock sscanf(string[], format[], {Float,_}:...)
  230. {
  231.     #if defined isnull
  232.         if (isnull(string))
  233.     #else
  234.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  235.     #endif
  236.         {
  237.             return format[0];
  238.         }
  239.     #pragma tabsize 4
  240.     new
  241.         formatPos = 0,
  242.         stringPos = 0,
  243.         paramPos = 2,
  244.         paramCount = numargs(),
  245.         delim = ' ';
  246.     while (string[stringPos] && string[stringPos] <= ' ')
  247.     {
  248.         stringPos++;
  249.     }
  250.     while (paramPos < paramCount && string[stringPos])
  251.     {
  252.         switch (format[formatPos++])
  253.         {
  254.             case '\0':
  255.             {
  256.                 return 0;
  257.             }
  258.             case 'i', 'd':
  259.             {
  260.                 new
  261.                     neg = 1,
  262.                     num = 0,
  263.                     ch = string[stringPos];
  264.                 if (ch == '-')
  265.                 {
  266.                     neg = -1;
  267.                     ch = string[++stringPos];
  268.                 }
  269.                 do
  270.                 {
  271.                     stringPos++;
  272.                     if ('0' <= ch <= '9')
  273.                     {
  274.                         num = (num * 10) + (ch - '0');
  275.                     }
  276.                     else
  277.                     {
  278.                         return -1;
  279.                     }
  280.                 }
  281.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  282.                 setarg(paramPos, 0, num * neg);
  283.             }
  284.             case 'h', 'x':
  285.             {
  286.                 new
  287.                     num = 0,
  288.                     ch = string[stringPos];
  289.                 do
  290.                 {
  291.                     stringPos++;
  292.                     switch (ch)
  293.                     {
  294.                         case 'x', 'X':
  295.                         {
  296.                             num = 0;
  297.                             continue;
  298.                         }
  299.                         case '0' .. '9':
  300.                         {
  301.                             num = (num << 4) | (ch - '0');
  302.                         }
  303.                         case 'a' .. 'f':
  304.                         {
  305.                             num = (num << 4) | (ch - ('a' - 10));
  306.                         }
  307.                         case 'A' .. 'F':
  308.                         {
  309.                             num = (num << 4) | (ch - ('A' - 10));
  310.                         }
  311.                         default:
  312.                         {
  313.                             return -1;
  314.                         }
  315.                     }
  316.                 }
  317.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  318.                 setarg(paramPos, 0, num);
  319.             }
  320.             case 'c':
  321.             {
  322.                 setarg(paramPos, 0, string[stringPos++]);
  323.             }
  324.             case 'f':
  325.             {
  326.  
  327.                 new changestr[16], changepos = 0, strpos = stringPos;
  328.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  329.                 {
  330.                     changestr[changepos++] = string[strpos++];
  331.                     }
  332.                 changestr[changepos] = '\0';
  333.                 setarg(paramPos,0,_:floatstr(changestr));
  334.             }
  335.             case 'p':
  336.             {
  337.                 delim = format[formatPos++];
  338.                 continue;
  339.             }
  340.             case '\'':
  341.             {
  342.                 new
  343.                     end = formatPos - 1,
  344.                     ch;
  345.                 while ((ch = format[++end]) && ch != '\'') {}
  346.                 if (!ch)
  347.                 {
  348.                     return -1;
  349.                 }
  350.                 format[end] = '\0';
  351.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  352.                 {
  353.                     if (format[end + 1])
  354.                     {
  355.                         return -1;
  356.                     }
  357.                     return 0;
  358.                 }
  359.                 format[end] = '\'';
  360.                 stringPos = ch + (end - formatPos);
  361.                 formatPos = end + 1;
  362.             }
  363.             case 'u':
  364.             {
  365.                 new
  366.                     end = stringPos - 1,
  367.                     id = 0,
  368.                     bool:num = true,
  369.                     ch;
  370.                 while ((ch = string[++end]) && ch != delim)
  371.                 {
  372.                     if (num)
  373.                     {
  374.                         if ('0' <= ch <= '9')
  375.                         {
  376.                             id = (id * 10) + (ch - '0');
  377.                         }
  378.                         else
  379.                         {
  380.                             num = false;
  381.                         }
  382.                     }
  383.                 }
  384.                 if (num && IsPlayerConnected(id))
  385.                 {
  386.                     setarg(paramPos, 0, id);
  387.                 }
  388.                 else
  389.                 {
  390.                     #if !defined foreach
  391.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  392.                         #define __SSCANF_FOREACH__
  393.                     #endif
  394.                     string[end] = '\0';
  395.                     num = false;
  396.                     new
  397.                         name[MAX_PLAYER_NAME];
  398.                     id = end - stringPos;
  399.                     foreach (Player, playerid)
  400.                     {
  401.                         GetPlayerName(playerid, name, sizeof (name));
  402.                         if (!strcmp(name, string[stringPos], true, id))
  403.                         {
  404.                             setarg(paramPos, 0, playerid);
  405.                             num = true;
  406.                             break;
  407.                         }
  408.                     }
  409.                     if (!num)
  410.                     {
  411.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  412.                     }
  413.                     string[end] = ch;
  414.                     #if defined __SSCANF_FOREACH__
  415.                         #undef foreach
  416.                         #undef __SSCANF_FOREACH__
  417.                     #endif
  418.                 }
  419.                 stringPos = end;
  420.             }
  421.             case 's', 'z':
  422.             {
  423.                 new
  424.                     i = 0,
  425.                     ch;
  426.                 if (format[formatPos])
  427.                 {
  428.                     while ((ch = string[stringPos++]) && ch != delim)
  429.                     {
  430.                         setarg(paramPos, i++, ch);
  431.                     }
  432.                     if (!i)
  433.                     {
  434.                         return -1;
  435.                     }
  436.                 }
  437.                 else
  438.                 {
  439.                     while ((ch = string[stringPos++]))
  440.                     {
  441.                         setarg(paramPos, i++, ch);
  442.                     }
  443.                 }
  444.                 stringPos--;
  445.                 setarg(paramPos, i, '\0');
  446.             }
  447.             default:
  448.             {
  449.                 continue;
  450.             }
  451.         }
  452.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  453.         {
  454.             stringPos++;
  455.         }
  456.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  457.         {
  458.             stringPos++;
  459.         }
  460.         paramPos++;
  461.     }
  462.     do
  463.     {
  464.         if ((delim = format[formatPos++]) > ' ')
  465.         {
  466.             if (delim == '\'')
  467.             {
  468.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  469.             }
  470.             else if (delim != 'z')
  471.             {
  472.                 return delim;
  473.             }
  474.         }
  475.     }
  476.     while (delim > ' ');
  477.     return 0;
  478. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement