25.07.2013, 08:11
(
Последний раз редактировалось Threshold; 25.07.2013 в 09:43.
)
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;
}
//------------------------------------------------------------------------------