SA-MP Forums Archive
forbidden names - 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: forbidden names (/showthread.php?tid=511729)



forbidden names - TheSimpleGuy - 07.05.2014

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


Re: forbidden names - Beckett - 07.05.2014

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


Re: forbidden names - TheSimpleGuy - 07.05.2014

Forbidden name list.


Re: forbidden names - Laure - 07.05.2014

For example ?


Re: forbidden names - Roel - 07.05.2014

Код:
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.


Re : forbidden names - S4t3K - 07.05.2014

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


Re: forbidden names - TheSimpleGuy - 07.05.2014

Why OnPlayerText?


Re : forbidden names - S4t3K - 07.05.2014

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


Re: Re : forbidden names - Roel - 07.05.2014

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.