small help
#1

i have this function

Код:
antiswear(text[])
{
   if((strlen(text) < 3))
   {
     new chatswear,len;
     for(new cs = 0; cs < MAX_WORDS; cs++)
     {
         //check if the word is offensive
         chatswear = strfind(text, swear[cs], true);
         if(chatswear > -1)
         {
             len = strlen(swear[cs]);
             if(len < 3) break;
             for(new y = 1; y < len; y++)
             {
                text[y] = '*'; //chatswear+y
	     }
         }
     }
   }
   return text;
}
and this under OnPlayerText

Код:
for(new s = 0; s < strlen(text); s++)
	    text[s] = tolower(text[s]);
	    antiswear(text);
	    if(gTeam[playerid] != 100 && gTeam[playerid] != 101 && VIP[playerid] == 0) format(strtext, sizeof(strtext), "%s [%d]: %s", PlayerName(playerid), playerid, text);
	    if(gTeam[playerid] != 100 && gTeam[playerid] != 101 && VIP[playerid] != 0 && GetPVarInt(playerid,"undercover") == 1) format(strtext, sizeof(strtext), "%s [%d]: %s", PlayerName(playerid), playerid, text);
	    else if(gTeam[playerid] != 100 && gTeam[playerid] != 101 && VIP[playerid] != 0 && GetPVarInt(playerid,"undercover") == 0) format(strtext, sizeof(strtext), "VIP %s [%d]: %s", PlayerName(playerid), playerid, text);
     	else if(gTeam[playerid] == 100 || gTeam[playerid] == 101) format(strtext, sizeof(strtext), ">> CLANWAR << %s [%d]: %s", PlayerName(playerid), playerid, text);
but the text does'nt return in the formatted text given above..
Reply
#2

text = antiswear(text);

probably would help!
Reply
#3

Код:
for(new ss = 0; ss < strlen(text); ss++)
	    {
		text[ss] = antiswear(text[ss]);
	    }

>> Error (7187) : error 006: must be assigned to an array
Reply
#4

Works fine for me

PHP код:
public OnPlayerText(playeridtext[])
{
    for(new 
index 0index strlen(text); index++)
    {
        
text[index] = tolower(text[index]);
    }

Reply
#5

doesnt work

my edited code
Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '@')
    {
		 text[1] = antiswear(text[1]); // bfchat with anti swear
         new string[128];
		 format(string, sizeof(string), "BF_CHAT %s [%d]: %s", PlayerName(playerid),playerid,text[1]);
	     SendClientMessage(playerid,0xFF8C00FF,string);
		 //printf(string);
    }
    else
    {
       for(new s = 0; s < strlen(text); s++)
	    text[s] = tolower(text[s]);
       for(new j = 0; j < strlen(text); j++)
        text[j] = antiswear(text[j]);
	}
    return 0;
}
still doesnt work

my edited function
Код:
antiswear(text[])
{
     new chatswear,len;
     for(new cs = 0; cs < MAX_WORDS; cs++)
     {
         //check if the word is offensive
         chatswear = strfind(text, swear[cs], true);
         if(chatswear > -1)
         {
             len = strlen(swear[cs]);
             if(len < 3) break;
             for(new y = 1; y < len; y++)
             {
                text[y] = '*'; //chatswear+y
	     }
         }
     }
}
Reply
#6

PHP код:
format(textsizeof(text), antiswear(text)); 
Reply
#7

@ luicy i've tried that, i have problem with my function help me with that...
Код:
antiswear(text[])
{
   {
     new chatswear,len;
     for(new cs = 0; cs < MAX_WORDS; cs++)
     {
         //check if the word is offensive
         chatswear = strfind(text, swear[cs], true);
         if(chatswear > -1)
         {
             len = strlen(swear[cs]);
             if(len < 3) break;
             for(new y = 1; y < len; y++)
             {
                text[y] = '*'; //chatswear+y
		     }
         }
     }
   }
return 0;
}
after luicy's suggestion

Код:
if(text[0] == '@')
    {
		
         new string[128];
		 format(string, sizeof(string), "BF_CHAT %s [%d]: %s", PlayerName(playerid),playerid,antiswear(text[1]));
	     SendClientMessage(playerid,0xFF8C00FF,string);
		
    }
Reply
#8

-bump- the above post is my latest code edit still doesn't work .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)