SA-MP Forums Archive
Help with /nick - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with /nick (/showthread.php?tid=80634)



Help with /nick - Dreftas - 05.06.2009

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.) ?


Re: Help with /nick - Weirdosport - 05.06.2009

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

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

CheckNick = NewNick


Re: Help with /nick - Mr_Finnigan - 05.06.2009

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


Re: Help with /nick - Dreftas - 05.06.2009

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 ?


Re: Help with /nick - Dreftas - 05.06.2009

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


Re: Help with /nick - Dreftas - 05.06.2009

Is there any function to check is player name valid ?


Re: Help with /nick - Andom - 05.06.2009

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;
}



Re: Help with /nick - Dreftas - 05.06.2009

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 ?


Re: Help with /nick - Dreftas - 05.06.2009

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