Problem[bad words]
#1

so if a person says Fu** you it applys this anim..how do i do it ?
ApplyAnimation(playerid,"PED","fucku",4.0,0,0,0,0, 0);
Reply
#2

Use strfind under OnPlayerText.

https://sampwiki.blast.hk/wiki/OnPlayerText
https://sampwiki.blast.hk/wiki/strfind

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(strfind(text, "fuck you", true) != -1 || strfind(text, "fuck u", true) != -1) ApplyAnimation(playerid,"PED","fucku",4.0,0,0,0,0, 0);
    return 1;
}
(will work for 'fuck you' and 'fuck u'). However, I think you need to alter the animation options a bit.
Reply
#3

could it not show the word on the screen just to apply anim?
Reply
#4

Yes, if you return 0 under OnPlayerText it will not send the chat:

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(strfind(text, "fuck you", true) != -1 || strfind(text, "fuck u", true) != -1)
    {
        ApplyAnimation(playerid,"PED","fucku",4.0,0,0,0,0, 0);
        return 0;
    }
    return 1;
}
Reply
#5

nervermind thanks![rep becuase you were fast]!
Reply
#6

You could use an array of bad words:

pawn Код:
new gBadWords[][] = {
"fuck",
"shit",
"bitch"
// etc.
};
public OnPlayerText(playerid, text[])
{
    for(new i=0; i<sizeof(gBadWords); i++)
    {
        if(strfind(text, gBadWords[i], true) != -1)
        {
            ApplyAnimation(playerid,"PED","fucku",4.0,0,0,0,0, 0);
            return 0;
        }
    }
    return 1;
}
Not tested/compiled, let me know if it has any errors.
Reply
#7

i did like this so the anim doesent go in car like weird..
PHP код:
for(new i=0i<sizeof(gBadWords); i++)
                {
                if(
strfind(textgBadWords[i], true) != -1)
                {
                if(
IsPlayerInAnyVehicle(playerid))
                {
                
ApplyAnimation(playerid,"PED","fucku",4.0,0,0,0,00);
                return 
0;
                }
                } 
Reply
#8

yeah fixed thx
Reply
#9

You shouldn't put the check inside the loop, it will be called x times, it only needs to be called once.

pawn Код:
if(GetPlayerState(playerid) == 1) // onfoot
{
    for(new i=0; i<sizeof(gBadWords); i++)
    {
        if(strfind(text, gBadWords[i], true) != -1)
        {
            ApplyAnimation(playerid,"PED","fucku",4.0,0,0,0,0, 0);
            return 0;
        }
    }
}
Also, please use [pawn] tags instead of php. And learn to indent.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)