Advertisement
Jujuv

[SA:MP | FS] Censure-Facile

Mar 8th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.72 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4. #include <dini>
  5.  
  6. #define FILE "censsure.conf"
  7. #define COLOR_RED 0xFFF82C0E
  8. #define COLOR_GREEN 0x73DA16FF
  9.  
  10. enum
  11. {
  12.         MAIN_MENU,
  13.         EDIT_INPUT,
  14.         ADD_INPUT,
  15.         VIEW_INPUT,
  16.         EDIT_INPUT_WORD
  17.        
  18. }
  19.  
  20. main()
  21. {}
  22.  
  23. stock GetLine(ID)
  24. {
  25.         new line[10];
  26.         format(line, sizeof(line), "Word_%d", ID);
  27.        
  28.         return line;
  29. }
  30.  
  31. stock check(text[])
  32. {
  33.     new total = dini_Int(FILE, "Total");
  34.     new line[10];
  35.     if(total)
  36.     {
  37.         for(new i = 0; i <= total; i++)
  38.         {
  39.             line = GetLine(i);
  40.             if(strfind(text, dini_Get(FILE, line), true) != -1)
  41.             {return 1;}
  42.         }
  43.     }
  44.     return 0;
  45. }
  46.  
  47. stock AddWord(playerid, newWord[])
  48. {
  49.         new total = dini_Int(FILE, "Total");
  50.         total++;
  51.         dini_IntSet(FILE, "Total", total);
  52.                        
  53.         new line[10];
  54.         line = GetLine(total);
  55.                        
  56.                        
  57.         dini_Set(FILE, line, newWord);
  58.                        
  59.         new msg[250];
  60.         format(msg, sizeof(msg), "Le mot \"%s\" a bien été ajouté à la liste des mots censsurés.Son ID est %d.", newWord, total);
  61.         SendClientMessage(playerid, COLOR_GREEN, msg);     
  62. }
  63.  
  64. stock EditWord(playerid, wordID, newWord[])
  65. {
  66.             new total = dini_Int(FILE, "Total");
  67.    
  68.             if(wordID <= total && wordID > 0)
  69.             {
  70.                     new  line[10], oldWord[DINI_MAX_STRING], msg[250];
  71.                        
  72.                     line = GetLine(wordID);
  73.                     oldWord = dini_Get(FILE, line);
  74.                     dini_Set(FILE, line, newWord);
  75.                    
  76.                     format(msg, sizeof(msg), "Le mot ID %d (anciennement \"%s\") a bien été remplaé par \"%s\"", wordID, oldWord, newWord);
  77.                     SendClientMessage(playerid, COLOR_GREEN, msg);
  78.             }
  79.             else { SendClientMessage(playerid, COLOR_RED, "ID Invalide !"); }
  80. }
  81.  
  82. stock VieWord(playerid, ID)
  83. {
  84.                 new total = dini_Int(FILE, "Total");
  85.                
  86.                 if(ID <= total && ID > 0)
  87.                 {
  88.                         new word[DINI_MAX_STRING], line[10], msg[250];
  89.                        
  90.                         line = GetLine(ID);
  91.                        
  92.                         word = dini_Get(FILE, line);
  93.                        
  94.                        
  95.                         format(msg, sizeof(msg), "Le mot ID %d est \"%s\"", ID, word);
  96.                         SendClientMessage(playerid, COLOR_GREEN, msg);
  97.                 }
  98.                 else { SendClientMessage(playerid, COLOR_RED, "ID Invalide !"); }
  99. }
  100. public OnFilterScriptInit()
  101. {
  102.    
  103.     print("\n--------------------------------------");
  104.     print("Le FS Censsure-Facile de Jujuv a été chargé");
  105.     print("--------------------------------------\n");
  106.    
  107.     if(!dini_Exists(FILE))
  108.     {
  109.         dini_Create(FILE);
  110.         dini_IntSet(FILE, "Total", 0);
  111.         printf("[Censsure-Facile] Aucun fichier de configuration n'a été trouvé par Censsure-Facile.\nUn fichier vierge a été crée sous le nom suivant: %s",FILE);
  112.     }
  113.     return 1;
  114. }
  115.  
  116. public OnFilterScriptExit()
  117. {
  118.    
  119.     print("\n--------------------------------------");
  120.     print("Le FS Censsure-Facile de Jujuv a été désactivé");
  121.     print("--------------------------------------\n");
  122.    
  123.     return 1;
  124. }
  125.  
  126. public OnPlayerCommandText(playerid, cmdtext[])
  127. {
  128.         if(!strcmp(cmdtext, "/censsure") && IsPlayerAdmin(playerid))
  129.         {
  130.                 ShowPlayerDialog(playerid, MAIN_MENU, DIALOG_STYLE_LIST, "Censsure-Facile", "Consulter un mot via son ID\nAjouter un mot\nEditer un mot via son ID", "Ok", "Annuler");
  131.                 return 1;
  132.         }
  133.        
  134.         return 0;
  135. }
  136.  
  137. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  138. {  
  139.     if(!response) { return 1; }
  140.    
  141.     switch(dialogid)
  142.         {
  143.                 case MAIN_MENU:
  144.                     {
  145.                             switch(listitem)
  146.                                 {
  147.                                         case 0:
  148.                                             {
  149.                                                 ShowPlayerDialog(playerid, VIEW_INPUT, DIALOG_STYLE_INPUT, "Censsure-Facile", "Veuillez renseignez l'ID du mot censsuré à consulter", "Ok", "Annuler");
  150.                                                 return 1;
  151.                                             }
  152.                                         case 1:
  153.                                             {
  154.                                                 ShowPlayerDialog(playerid, ADD_INPUT, DIALOG_STYLE_INPUT, "Censsure-Facile", "Tapez le mot à ajouter", "Ok", "Annuler");
  155.                                                 return 1;
  156.                                             }
  157.                                         case 2:
  158.                                             {
  159.                                                 ShowPlayerDialog(playerid, EDIT_INPUT, DIALOG_STYLE_INPUT, "Censsure-Facile", "Veuillez renseignez l'ID du mot à modifier", "Ok", "Annuler");
  160.                                                 return 1;
  161.                                             }
  162.                                 }
  163.                     }
  164.                    
  165.                 case VIEW_INPUT:
  166.                     {
  167.                         VieWord(playerid, strval(inputtext));
  168.                         return 1;
  169.                     }
  170.                 case ADD_INPUT:
  171.                     {
  172.                         AddWord(playerid, inputtext);
  173.                         return 1;
  174.                     }
  175.                 case EDIT_INPUT:
  176.                     {
  177.                         SetPVarInt(playerid, "EditWordID", strval(inputtext));
  178.                         ShowPlayerDialog(playerid, EDIT_INPUT_WORD, DIALOG_STYLE_INPUT, "Censsure-Facile", "Tapez le nouveau mot", "Ok", "Annuler");
  179.                         return 1;
  180.                     }
  181.                 case EDIT_INPUT_WORD:
  182.                     {
  183.                             EditWord(playerid, GetPVarInt(playerid, "EditWordID"), inputtext);
  184.                             return 1;
  185.                     }
  186.            
  187.         }
  188.     return 0;
  189. }
  190.  
  191. public OnPlayerText(playerid, text[])
  192. {
  193.     if(check(text))
  194.     {
  195.         SendClientMessage(playerid, COLOR_RED, "Ce mot est interdis sur le serveur !");
  196.         return 0;
  197.     }
  198.    
  199.     return 1;
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement