Advertisement
Guest User

Dynamisches Reportsystem by Azure & Easy

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