Unaccpetable names
#1

Yeah, I was Wondering if i can Look for names and Kick The Players Names.

Here:

pawn Код:
new ForbiddenNames[][5] =
{
 "1", "2", "3", "4", "5"
};
Then On Player Connection....
pawn Код:
for(new i = 0; i < sizeof(ForbiddenNames); i ++ )
{
if(!strcmp(name, i, true))
{
SendClientMessage(playerid, 0xFF0000FF, "SERVER: Unacceptable Name");
SendClientMessage(playerid, 0xFF0000FF, "SERVER: You have Been Banned.");
Ban(playerid);

}
Am i Missing Something?
Bracket?
Reply
#2

ya, just one thing:
pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
for(new i = 0; i < sizeof(ForbiddenNames); i ++ )
{
if(!strcmp(name, i, true))
{
SendClientMessage(playerid, 0xFF0000FF, "SERVER: Unacceptable Name");
SendClientMessage(playerid, 0xFF0000FF, "SERVER: You have Been Banned.");
Ban(playerid);

}
Reply
#3

I declared the array as constant (constant variables are handled faster than normal variables)
pawn Код:
stock const ForbiddenNames[][] =
{
 "1", "2", "3", "4", "5"
};
You forgot the second closing bracket and the forbidden names in strcmp
pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
for(new i; i != sizeof(ForbiddenNames); i ++ )
{
    if(!strcmp(name, ForbiddenNames[i], true))
    {
        SendClientMessage(playerid, 0xFF0000FF, "SERVER: Unacceptable Name");
        SendClientMessage(playerid, 0xFF0000FF, "SERVER: You have Been Banned.");
        Ban(playerid);
        break;
    }
}
Reply
#4

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
I declared the array as constant (constant variables are handled faster than normal variables)
pawn Код:
stock const ForbiddenNames[][] =
{
 "1", "2", "3", "4", "5"
};
You forgot the second closing bracket and the forbidden names in strcmp
pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
for(new i; i != sizeof(ForbiddenNames); i ++ )
{
    if(!strcmp(name, ForbiddenNames[i], true))
    {
        SendClientMessage(playerid, 0xFF0000FF, "SERVER: Unacceptable Name");
        SendClientMessage(playerid, 0xFF0000FF, "SERVER: You have Been Banned.");
        Ban(playerid);
        break;
    }
}
Thanks, Nero.
Reply
#5

EDIT Not working:
line: 4276

pawn Код:
for(new i; i != sizeof(ForbiddenNames); i ++ )
Errors:
pawn Код:
CR.pwn(4276) : error 017: undefined symbol "ForbiddenNames"
CR.pwn(4276) : error 036: empty statement
CR.pwn(4276) : error 017: undefined symbol "i"
CR.pwn(4276) : fatal error 107: too many error messages on one line
Reply
#6

You deleted:
pawn Код:
stock const ForbiddenNames[][] =
{
    "1", "2", "3", "4", "5"
};
?
Put it back if you did!
Reply
#7

Quote:
Originally Posted by Mean
Посмотреть сообщение
You deleted:
pawn Код:
stock const ForbiddenNames[][] =
{
    "1", "2", "3", "4", "5"
};
?
Put it back if you did!
the wrong thing i did, was to add it at the end of the script, never mind i got it to work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)