Swearword Library Problem -
redreaper666 - 24.07.2013
Hi there as im trying to make an very usefull filterscript i might need some help by fixing a mistake i cant find.
I get no Errors no Warnings nothing so please take a look.
Код:
#include <a_samp>
#include <sscanf2>
#include <zcmd>
//------------------------------------------------------------------------------
public OnPlayerText(playerid, text[])
{
new string[128];
new Swearword[128];
new File:fh;
new str[64];
fh = fopen( "swearwords.txt", io_read );
fread(fh, str);
format(string,sizeof(string),"%s",Swearword);
if(strfind(str,text) == 1)
{
SendClientMessage(playerid, -1, "PLEASE DON'T SWEAR");
fclose(fh);
return 0;
}
fclose(fh);
return 1;
}
//------------------------------------------------------------------------------
CMD:addswearword(playerid, params[])
{
new string[128];
new Swearword[128];
new Swearwordtext[128];
new File:fh;
if(sscanf(params, "s", Swearword)) return SendClientMessage(playerid, -1, "{F81414}COMMAND: {FFFFFF}addswearword <swearword>");
{
new str[64];
fh = fopen( "swearwords.txt", io_read );
fread(fh, str);
format(string,sizeof(string),"%s",Swearword);
if(strfind(str,string) == 0)
{
fclose(fh);
return SendClientMessage(playerid,-1,"It's already there!");
}
else if(strfind(str,string) == 1)
{
fh = fopen( "swearwords.txt", io_append );
format(Swearwordtext,sizeof(Swearwordtext),"%s,",Swearword);
fwrite(fh,Swearwordtext);
fwrite( fh, "\n" );
fclose(fh);
format(string,sizeof(string),"%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;
}
//------------------------------------------------------------------------------
Thanks
Re: Swearword Library Problem -
redreaper666 - 25.07.2013
Bump
Re: Swearword Library Problem -
JimmyCh - 25.07.2013
It's not loading anything? Sorry but wouldn't it be easier to save them in a .txt file? Why .pwn?
Maybe that's your problem? Or can you please explain briefly what's your problem so we know how to help you
Re: Swearword Library Problem -
redreaper666 - 25.07.2013
In the (now .txt file) the words are listed like this:
word,
word,
word,
newword,
The thing is since i put the lines in that checks if the word already exists in the list it says unknown cmd for me ingame.
I tried using a normal .txt file now.
Nothing has changed. its just saying Unknown CMD ingame as before.
Re: Swearword Library Problem -
JimmyCh - 25.07.2013
I'm not much of a genius in scripting but:
pawn Код:
if(strfind(str,string) == 0)
{
return SendClientMessage(playerid,-1,"It's already there!");
}
Doesn't this check if the word is there, if it's not it sends that message?
pawn Код:
if(strfind(str,string) == 0)
Again, sorry but I'm not sure about this so maybe if I get an answer on this, I might be able to help you out.
Re: Swearword Library Problem -
Threshold - 25.07.2013
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.
Re: Swearword Library Problem -
redreaper666 - 25.07.2013
Well now it works partly. Thanks for that so far

I can add words now again but i still can add one word multiple times which means that it aint correctly reading each word and searching for a double

Also it aint detecting the words onplayertext.
Re: Swearword Library Problem -
Threshold - 25.07.2013
Sorry, I have my 'ignorecase' set up wrong... change 'false' to 'true', my bad.
I have updated the above code just in case you're not sure what I'm talking about. So please see my previous post.
Re: Swearword Library Problem -
redreaper666 - 25.07.2013
Yea i changed that already before but still same effect.
It somehow aint reading the words.
However thanks for trying i guess the function is bugged somehow.