Problem[bad words] -
Dan_Barocu - 22.04.2012
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);
Re: Problem[bad words] -
MP2 - 22.04.2012
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.
Re: Problem[bad words] -
Dan_Barocu - 22.04.2012
could it not show the word on the screen just to apply anim?
Re: Problem[bad words] -
MP2 - 22.04.2012
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;
}
Re: Problem[bad words] -
Dan_Barocu - 22.04.2012
nervermind thanks![rep becuase you were fast]!
Re: Problem[bad words] -
MP2 - 22.04.2012
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.
Re: Problem[bad words] -
Dan_Barocu - 22.04.2012
i did like this so the anim doesent go in car like weird..
PHP код:
for(new i=0; i<sizeof(gBadWords); i++)
{
if(strfind(text, gBadWords[i], true) != -1)
{
if(IsPlayerInAnyVehicle(playerid))
{
ApplyAnimation(playerid,"PED","fucku",4.0,0,0,0,0, 0);
return 0;
}
}
Re: Problem[bad words] -
Dan_Barocu - 22.04.2012
yeah fixed
thx
Re: Problem[bad words] -
MP2 - 22.04.2012
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.