SA-MP Forums Archive
small help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: small help (/showthread.php?tid=626841)



small help - DetoNater - 21.01.2017

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..


Re: small help - czop1223 - 21.01.2017

text = antiswear(text);

probably would help!


Re: small help - DetoNater - 21.01.2017

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

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



Re: small help - BiosMarcel - 21.01.2017

Works fine for me

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




Re: small help - DetoNater - 21.01.2017

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
	     }
         }
     }
}



Re: small help - Luicy. - 21.01.2017

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



Re: small help - DetoNater - 21.01.2017

@ 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);
		
    }



Re: small help - DetoNater - 21.01.2017

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