i need help to change player name format
#1

Hello, I am working in my RP server and need help ,how to change the name format to let the player register with format Firstname_Lastname
,thanks
Reply
#2

This can help you put these codes in OnPlayerConnect or after register or any thing you want :

PHP код:
            new sendername[MAX_PLAYER_NAME];
            
GetPlayerName(playeridsendernamesizeof(sendername));
            new 
namestring strfind(sendername"_"true);
            if(
namestring == -1)
            {
                
SendClientMessage(playeridCOLOR_YELLOW"Your name must be in the Firstname_Lastname format - Please re-log with a name such as Amir_AB");
                
Kick(playerid);
                return 
1;
            } 
Reply
#3

It work well but when I login with wrong format it didn't say ""login with right format Firstname_Lastname " it kick the player without telling him anything
Reply
#4

You have to set a timer.
pawn Код:
new sendername[MAX_PLAYER_NAME];
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new namestring = strfind(sendername, "_", true);
            if(namestring == -1)
            {
                SendClientMessage(playerid, COLOR_YELLOW, "Your name must be in the Firstname_Lastname format - Please re-log with a name such as Amir_AB");
                SetTimerEx("KickPlayer", 500, false "i", playerid);
                return 1;
            }
            forward KickPlayer (playerid)
            public KickPlayer (playerid)
            {
                  Kick(playerid);
            }
Reply
#5

I should put the timer before Amir's code ? Or just replace it with amir's code ?
Reply
#6

I have used amirab's code. Just replace the old one with this.
Reply
#7

it make errors
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : error 001: expected token: ",", but found "-string-"
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : warning 215: expression has no effect
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : warning 215: expression has no effect
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : error 001: expected token: ";", but found ")"
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : error 029: invalid expression, assumed zero
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : fatal error 107: too many error messages on one line
Reply
#8

it make errors when i put the timer
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : error 001: expected token: ",", but found "-string-"
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : warning 215: expression has no effect
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : warning 215: expression has no effect
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : error 001: expected token: ";", but found ")"
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : error 029: invalid expression, assumed zero
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : fatal error 107: too many error messages on one line
Reply
#9

pawn Код:
forward KickPlayer (playerid);
Reply
#10

Quote:
Originally Posted by IbeatS
Посмотреть сообщение
it make errors when i put the timer
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : error 001: expected token: ",", but found "-string-"
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : warning 215: expression has no effect
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : warning 215: expression has no effect
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : error 001: expected token: ";", but found ")"
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : error 029: invalid expression, assumed zero
C:\Users\Hossam\Downloads\Compressed\Italy Mafia Vers6\pawno\mafia02.pwn(5342) : fatal error 107: too many error messages on one line
No double posts.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)