Help with /nick
#1

When I try to change nick into other with illegal characters server don't change it.
I tried this:
pawn Code:
new CheckNick[MAX_PLAYER_NAME];
                SetPlayerName(playerid,NewNick);
               
                GetPlayerName(playerid,CheckNick,MAX_PLAYER_NAME);
                if(!strcmp(NewNick,CheckNick,true))
                    return SendClientMessage(playerid,red,"[SERVER]: Bad symbols in nickname!");
But this doesn't work, so how to make something like this, that player cant write /nick and nickname with bad symbols(!@#$%^&* etc.) ?
Reply
#2

SetPlayerName(playerid,NewNick);
GetPlayerName(playerid,CheckNick,MAX_PLAYER_NAME);

You're setting his nick, then seeing what it is?

CheckNick = NewNick
Reply
#3

Did you close server compile .pwn then make sure new.amx file is in gamemode then restart server?
Reply
#4

Quote:
Originally Posted by Weirdosport
SetPlayerName(playerid,NewNick);
GetPlayerName(playerid,CheckNick,MAX_PLAYER_NAME);

You're setting his nick, then seeing what it is?

CheckNick = NewNick
But if nickname have bad symbols(!@#$%^&*() etc.) server don't change it, so I think that nickname is old, not new.. Or I'm wrong ?
Reply
#5

Anyone?.. how to return 0 if player try to change nick into other with wrong symbols(!@#$%^&*...)??
Reply
#6

Is there any function to check is player name valid ?
Reply
#7

pawn Code:
InvalidNickCharacters(string[]) // By Gehaktbal
{
  for (new a = 0, b = strlen(string); a < b; a++)
  {
   switch(string[a])
   {
     case '=': return 0;
     case '!': return 0;
     case '@': return 0;
     case '#': return 0;
     case '$': return 0;
     case '%': return 0;
     case '^': return 0;
     case '&': return 0;
     case '*': return 0;
     case '(': return 0;
     case ')': return 0;
     case '/': return 0;
     case ':': return 0;
     case '-': return 0;
     case ';': return 0;
     case '+': return 0;
     case '<': return 0;
     case '>': return 0;
     case '?': return 0;
     case ',': return 0;
     case '.': return 0;
     case '`': return 0;
     case '~': return 0;
     case '}': return 0;
     case '{': return 0;
   }
  }
  return 1;
}
And then something like this:
pawn Code:
if("/nick" bla bla bla......)
{
   if(InvalidNickCharacters(newnick))
   {
     // Here your change nick code..
   }
   else
   {
     SendClientMessage(playerid, COLOR_RED, "Invalid nickname! use can only use A-Z a-z 0-9 [] or _");
   }
   return 1;
}
Reply
#8

What about " ?
case ' " ' cant be.
I know just how to add two " its like \"\", but how to add one " I dont know. How to do it ?
Reply
#9

Quote:
Originally Posted by Dreftas
What about " ?
case ' " ' cant be.
I know just how to add two " its like \"\", but how to add one " I dont know. How to do it ?
bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)