Swearword Library Problem
#6

pawn Код:
#include <a_samp>
#include <sscanf2>
#include <zcmd>
//------------------------------------------------------------------------------
public OnPlayerText(playerid, text[])
{
    new string[128];
    new File:fh = fopen("swearwords.txt", io_read);
    while(fread(fh, string))
    {
        if(strfind(text, string, true) != -1)
        {
            SendClientMessage(playerid, -1, "Please Don't Swear.");
            fclose(fh);
            return 0;
        }
    }
    fclose(fh);
    return 1;
}
//------------------------------------------------------------------------------
CMD:addswearword(playerid, params[])
{
    new Swearword[60];
    if(sscanf(params, "s", Swearword)) return SendClientMessage(playerid, -1, "{F81414}COMMAND: {FFFFFF}/addswearword <swearword>");
    new str[60];
    new File:fh = fopen("swearwords.txt", io_read);
    while(fread(fh, str))
    {
        if(strcmp(str, Swearword, true) == 0)
        {
            SendClientMessage(playerid, -1, "This swearword already exists.");
            fclose(fh);
            return 1;
        }
    }
    fclose(fh);

    fh = fopen("swearwords.txt", io_append);
    format(str, sizeof(str), "%s\r\n", Swearword);
    fwrite(fh, str);
    fclose(fh);
    format(str,sizeof(str),"%s added swearword: '%s' to dictionary",GetName(playerid), Swearword);
    SendClientMessage(playerid,-1,string);
    return 1;
}

//------------------------------------------------------------------------------
stock GetName(playerid)
{
    new PlayerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
    return PlayerName;
}
//------------------------------------------------------------------------------
Hope this helps.
Reply


Messages In This Thread
Swearword Library Problem - by redreaper666 - 24.07.2013, 11:34
Re: Swearword Library Problem - by redreaper666 - 25.07.2013, 07:55
Re: Swearword Library Problem - by JimmyCh - 25.07.2013, 07:58
Re: Swearword Library Problem - by redreaper666 - 25.07.2013, 08:05
Re: Swearword Library Problem - by JimmyCh - 25.07.2013, 08:11
Re: Swearword Library Problem - by Threshold - 25.07.2013, 08:11
Re: Swearword Library Problem - by redreaper666 - 25.07.2013, 08:23
Re: Swearword Library Problem - by Threshold - 25.07.2013, 09:42
Re: Swearword Library Problem - by redreaper666 - 25.07.2013, 13:34

Forum Jump:


Users browsing this thread: 1 Guest(s)