Is it worth doing this?
#1

Hello guys, is it worth checking if there is another player has the same name with the player who is connecting to the server?
PHP код:
public OnPlayerConnect(playerid)
{
    foreach(new 
iPlayer)
    {
        if(
== playerid) continue;
        if(!
strcmp(GetPlayerNameEx(playerid), GetPlayerNameEx(i)))
        {
            
System_Scm(playerid"There is another player online with this username"TYPE_ERROR);
            
Kick(playerid);
            return 
1;
        }
    }
    
ResetCharacter(playerid);
    
ClearChat(playerid);
    
gCharacterLogged[playerid] = false;
    
TogglePlayerSpectating(playerid1); 
    
SetPVarInt(playerid"FirstConnection"1);
    
CreateCharacterNameTag(playerid);
    
CreateCharacterTextDraws(playerid);
    
BlacklistCheck(playerid);
    
RemoveObjects(playerid);
    return 
1;

Please help me, thanks in advanced.
Reply
#2

Nope, because it's impossible.
Reply
#3

Well, this is already there by default in SA-MP, so no need to check it again.
Reply
#4

Quote:
Originally Posted by X337
Посмотреть сообщение
Nope, because it's impossible.
Why is it impossible??

Quote:
Originally Posted by Debjit
Посмотреть сообщение
Well, this is already there by default in SA-MP, so no need to check it again.
I knew this but I don't know if the default one will check player's name before running my code? I mean run these:
PHP код:
    ResetCharacter(playerid); 
    
ClearChat(playerid); 
    
gCharacterLogged[playerid] = false
    
TogglePlayerSpectating(playerid1);  
    
SetPVarInt(playerid"FirstConnection"1); 
    
CreateCharacterNameTag(playerid); 
    
CreateCharacterTextDraws(playerid); 
    
BlacklistCheck(playerid); 
    
RemoveObjects(playerid); 
Reply
#5

It's impossible like he said .. the server would deny entry if it's a duplicate name.
Reply
#6

Quote:
Originally Posted by DuyDang2412
Посмотреть сообщение
Why is it impossible??


I knew this but I don't know if the default one will check player's name before running my code? I mean run these:
PHP код:
    ResetCharacter(playerid); 
    
ClearChat(playerid); 
    
gCharacterLogged[playerid] = false
    
TogglePlayerSpectating(playerid1);  
    
SetPVarInt(playerid"FirstConnection"1); 
    
CreateCharacterNameTag(playerid); 
    
CreateCharacterTextDraws(playerid); 
    
BlacklistCheck(playerid); 
    
RemoveObjects(playerid); 
That code will not execute. No connection is made with the server.
Reply
#7

Thank you, I understood.
Reply
#8

Код:
[[14:19:12] CONNECTION REJECTED: Unacceptable NickName

[14:19:12] Please choose another nick between and 3-20 characters

[14:19:12] Please use only a-z, A-Z, 0-9

[14:19:12] Maybe someone on the server with your nickname
This is what happens when you connect with a duplicate name.
Reply
#9

Quote:
Originally Posted by DaniceMcHarley
Посмотреть сообщение
Код:
[[14:19:12] CONNECTION REJECTED: Unacceptable NickName

[14:19:12] Please choose another nick between and 3-20 characters

[14:19:12] Please use only a-z, A-Z, 0-9

[14:19:12] Maybe someone on the server with your nickname
This is what happens when you connect with a duplicate name.
Ok! Thanks mate.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)