PDA

View Full Version : forbidden names


TheSimpleGuy
07/05/2014, 06:40 AM
(( I've used the search button but didn't work ))
http://forum.sa-mp.com/showthread.php?t=161145
I saw it but it didn't work.

Beckett
07/05/2014, 08:09 AM
Can you tell what do you really need? a forbidden name list or what?

TheSimpleGuy
07/05/2014, 08:18 AM
Forbidden name list.

Laure
07/05/2014, 08:21 AM
For example ?

Roel
07/05/2014, 09:08 AM
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.

S4t3K
07/05/2014, 09:23 AM
@Roel : You should create your array with a dynamic size



new InvalidNames[][20] =
{
"bitch", "noob", "rage", "ass" // You can add as many words as you want
};

public OnPlayerText(playerid, text[])
{
for(new fw = 0; fw < sizeof(InvalidNames); fw++)
{
if(strfind(text, InvalidNames[fw], true) != -1)
{
new replacement[20], replacement1[20], pos[2];
pos[0] = strfind(text, InvalidNames[fw], true);
pos[1] = strfind(text, ' ', true, pos[0]);
strmid(replacement, text, pos[0], pos[1]);
strdel(text, pos[0], pos[1]);
for(new i = 0; i < strlen(replacement); i++)
{
if(replacement[i] != '*') replacement[i] = '*';
}
strins(text, replacement, pos[0]);
}
return 0;
}

It should work.

TheSimpleGuy
07/05/2014, 09:25 AM
Why OnPlayerText?

S4t3K
07/05/2014, 09:27 AM
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 ;)

Roel
07/05/2014, 09:27 AM
@Roel : You should create your array with a dynamic size



new InvalidNames[][20] =
{
"bitch", "noob", "rage", "ass" // You can add as many words as you want
};

public OnPlayerText(playerid, text[])
{
for(new fw = 0; fw < sizeof(InvalidNames); fw++)
{
if(strfind(text, InvalidNames[fw], true) != -1)
{
new replacement[20], replacement1[20], pos[2];
pos[0] = strfind(text, InvalidNames[fw], true);
pos[1] = strfind(text, ' ', true, pos[0]);
strmid(replacement, text, pos[0], pos[1]);
strdel(text, pos[0], pos[1]);
for(new i = 0; i < strlen(replacement); i++)
{
if(replacement[i] != '*') replacement[i] = '*';
}
strins(text, replacement, pos[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.