Jujuv icon

[SA:MP | FS] Censure-Facile

Jujuv | PRO | 03/08/13 03:30:01 PM UTC | 0 ⭐ | 234 👁️ | Never ⏰ | []
Pawn |

4.72 KB

|

None

|

0 👍

/

0 👎

#define FILTERSCRIPT
 
#include <a_samp>
#include <dini>
 
#define FILE "censsure.conf"
#define COLOR_RED 0xFFF82C0E
#define COLOR_GREEN 0x73DA16FF
 
enum
{
        MAIN_MENU,
        EDIT_INPUT,
        ADD_INPUT,
        VIEW_INPUT,
        EDIT_INPUT_WORD
        
}
 
main()
{}
 
stock GetLine(ID)
{
        new line[10];
        format(line, sizeof(line), "Word_%d", ID);
        
        return line;
}
 
stock check(text[])
{
    new total = dini_Int(FILE, "Total");
    new line[10];
    if(total)
    {
        for(new i = 0; i <= total; i++)
        {
            line = GetLine(i);
            if(strfind(text, dini_Get(FILE, line), true) != -1)
            {return 1;}
        }
    }
    return 0;
}
 
stock AddWord(playerid, newWord[])
{
        new total = dini_Int(FILE, "Total");
        total++;
        dini_IntSet(FILE, "Total", total);
                        
        new line[10];
        line = GetLine(total);
                        
                        
        dini_Set(FILE, line, newWord);
                        
        new msg[250];
        format(msg, sizeof(msg), "Le mot \"%s\" a bien été ajouté à la liste des mots censsurés.Son ID est %d.", newWord, total);
        SendClientMessage(playerid, COLOR_GREEN, msg);      
}
 
stock EditWord(playerid, wordID, newWord[])
{
            new total = dini_Int(FILE, "Total");
    
            if(wordID <= total && wordID > 0)
            {
                    new  line[10], oldWord[DINI_MAX_STRING], msg[250];
                        
                    line = GetLine(wordID);
                    oldWord = dini_Get(FILE, line);
                    dini_Set(FILE, line, newWord);
                    
                    format(msg, sizeof(msg), "Le mot ID %d (anciennement \"%s\") a bien été remplaé par \"%s\"", wordID, oldWord, newWord);
                    SendClientMessage(playerid, COLOR_GREEN, msg);
            }
            else { SendClientMessage(playerid, COLOR_RED, "ID Invalide !"); }
}
 
stock VieWord(playerid, ID)
{
                new total = dini_Int(FILE, "Total");
                
                if(ID <= total && ID > 0)
                {
                        new word[DINI_MAX_STRING], line[10], msg[250];
                        
                        line = GetLine(ID);
                        
                        word = dini_Get(FILE, line);
                        
                        
                        format(msg, sizeof(msg), "Le mot ID %d est \"%s\"", ID, word);
                        SendClientMessage(playerid, COLOR_GREEN, msg);
                }
                else { SendClientMessage(playerid, COLOR_RED, "ID Invalide !"); }
}
public OnFilterScriptInit()
{
    
    print("\n--------------------------------------");
    print("Le FS Censsure-Facile de Jujuv a été chargé");
    print("--------------------------------------\n");
    
    if(!dini_Exists(FILE))
    {
        dini_Create(FILE);
        dini_IntSet(FILE, "Total", 0);
        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);
    }
    return 1;
}
 
public OnFilterScriptExit()
{
    
    print("\n--------------------------------------");
    print("Le FS Censsure-Facile de Jujuv a été désactivé");
    print("--------------------------------------\n");
    
    return 1;
}
 
public OnPlayerCommandText(playerid, cmdtext[])
{
        if(!strcmp(cmdtext, "/censsure") && IsPlayerAdmin(playerid))
        {
                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");
                return 1;
        }
        
        return 0;
}
 
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{   
    if(!response) { return 1; }
    
    switch(dialogid)
        {
                case MAIN_MENU:
                    {
                            switch(listitem)
                                {
                                        case 0:
                                            {
                                                ShowPlayerDialog(playerid, VIEW_INPUT, DIALOG_STYLE_INPUT, "Censsure-Facile", "Veuillez renseignez l'ID du mot censsuré à consulter", "Ok", "Annuler");
                                                return 1;
                                            }
                                        case 1:
                                            {
                                                ShowPlayerDialog(playerid, ADD_INPUT, DIALOG_STYLE_INPUT, "Censsure-Facile", "Tapez le mot à ajouter", "Ok", "Annuler");
                                                return 1;
                                            }
                                        case 2:
                                            {
                                                ShowPlayerDialog(playerid, EDIT_INPUT, DIALOG_STYLE_INPUT, "Censsure-Facile", "Veuillez renseignez l'ID du mot à modifier", "Ok", "Annuler");
                                                return 1;
                                            }
                                }
                    }
                    
                case VIEW_INPUT:
                    {
                        VieWord(playerid, strval(inputtext));
                        return 1;
                    }
                case ADD_INPUT:
                    {
                        AddWord(playerid, inputtext);
                        return 1;
                    }
                case EDIT_INPUT:
                    {
                        SetPVarInt(playerid, "EditWordID", strval(inputtext));
                        ShowPlayerDialog(playerid, EDIT_INPUT_WORD, DIALOG_STYLE_INPUT, "Censsure-Facile", "Tapez le nouveau mot", "Ok", "Annuler");
                        return 1;
                    }
                case EDIT_INPUT_WORD:
                    {
                            EditWord(playerid, GetPVarInt(playerid, "EditWordID"), inputtext);
                            return 1;
                    }
            
        }
    return 0;
}
 
public OnPlayerText(playerid, text[])
{
    if(check(text))
    { 
        SendClientMessage(playerid, COLOR_RED, "Ce mot est interdis sur le serveur !");
        return 0;
    }
    
    return 1;
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎