21.01.2010, 15:54
pawn Код:
stock Cenzura(string[],word[],destch='*')
{
new start_index=(-1),
end_index=(-1);
start_index=strfind(string,word,true);
if(start_index==(-1)) return false;
end_index=(start_index+strlen(word));
for( ; start_index<end_index; start_index++) string[start_index]=destch;
return true;
}
pawn Код:
new string[32]="testing the function";
Cenzura(string,"testing",'Ч'); -> output: ЧЧЧЧЧЧЧ the function
Filterscript
pawn Код:
#include <a_samp>
#define MAX_LEN 32
#define MAX_ENTRY 120
#define SOURCE "cenzura.txt"
static Cenzuralt_Szo[MAX_ENTRY][MAX_LEN];
public OnFilterScriptInit() {
if(!fexist(SOURCE)) return false;
new File:myFile,
line[MAX_LEN],
index=0;
myFile=fopen(SOURCE,filemode:io_read);
while(fread(myFile,line,sizeof line) && (index != MAX_ENTRY)) {
if(strlen(line)>MAX_LEN) continue;
StripNewLine(line);
strmid(Cenzuralt_Szo[index],line,0,strlen(line),sizeof line);
index++;
}
return true;
}
public OnPlayerText(playerid,text[])
{
for(new i=0; i<MAX_ENTRY; i++) if(!Cenzuralt_Szo[i][0]) continue;else Cenzura(text,Cenzuralt_Szo[i]);
return true;
}
stock StripNewLine(str[]) // ysi-misc.own
{
new
l = strlen(str);
while (l-- && str[l] <= ' ') str[l] = '\0';
}
stock Cenzura(string[],word[],destch='*')
{
new start_index=(-1),
end_index=(-1);
start_index=strfind(string,word,true);
if(start_index==(-1)) return false;
end_index=(start_index+strlen(word));
for( ; start_index<end_index; start_index++) string[start_index]=destch;
return true;
}
Код:
gay shit fuck