forbidden names
#1

(( I've used the search button but didn't work ))
https://sampforum.blast.hk/showthread.php?tid=161145
I saw it but it didn't work.
Reply
#2

Can you tell what do you really need? a forbidden name list or what?
Reply
#3

Forbidden name list.
Reply
#4

For example ?
Reply
#5

Код:
new InvalidNames[][20] =
{
	"loser","admin"
};

new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
   
for(new cnt = 0; cnt < sizeof(InvalidNames); cnt++)
{
	if(strfind(name, InvalidNames[cnt], true) != -1)
	{
		// Do what you want to do
		return 1;
	}
}
Here you go,
I didnt test it, but it should work.
Reply
#6

@Roel : You should create your array with a dynamic size

PHP код:

new InvalidNames[][20] = 
{
   
"bitch""noob""rage""ass" // You can add as many words as you want
};
public 
OnPlayerText(playeridtext[])
{
   for(new 
fw 0fw sizeof(InvalidNames); fw++)
   {
      if(
strfind(textInvalidNames[fw], true) != -1)
      {
         new 
replacement[20], replacement1[20], pos[2];
         
pos[0] = strfind(textInvalidNames[fw], true);
         
pos[1] = strfind(text' 'truepos[0]);
         
strmid(replacementtextpos[0], pos[1]);
         
strdel(textpos[0], pos[1]);
         for(new 
0strlen(replacement); i++)
         {
             if(
replacement[i] != '*'replacement[i] = '*';
          }
          
strins(textreplacementpos[0]);
      }
      return 
0;

It should work.
Reply
#7

Why OnPlayerText?
Reply
#8

Sh*t, didn't read "names" but "words".

Anyway, he just have to replace text[] by the reference of GetPlayerName and OnPlayerText by OnPlayerConnect.

It's not a hard work
Reply
#9

Quote:
Originally Posted by S4t3K
Посмотреть сообщение
@Roel : You should create your array with a dynamic size

PHP код:

new InvalidNames[][20] = 
{
   
"bitch""noob""rage""ass" // You can add as many words as you want
};
public 
OnPlayerText(playeridtext[])
{
   for(new 
fw 0fw sizeof(InvalidNames); fw++)
   {
      if(
strfind(textInvalidNames[fw], true) != -1)
      {
         new 
replacement[20], replacement1[20], pos[2];
         
pos[0] = strfind(textInvalidNames[fw], true);
         
pos[1] = strfind(text' 'truepos[0]);
         
strmid(replacementtextpos[0], pos[1]);
         
strdel(textpos[0], pos[1]);
         for(new 
0strlen(replacement); i++)
         {
             if(
replacement[i] != '*'replacement[i] = '*';
          }
          
strins(textreplacementpos[0]);
      }
      return 
0;

It should work.
Yes well you can remove the 2 indeed,
not sure why you had to copy this and add the onplayertext code with it, but whatever.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)