SA-MP Forums Archive
Is it worth doing this? - 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)
+--- Thread: Is it worth doing this? (/showthread.php?tid=639202)



Is it worth doing this? - DuyDang2412 - 13.08.2017

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.


Re: Is it worth doing this? - X337 - 13.08.2017

Nope, because it's impossible.


Re: Is it worth doing this? - Zeth - 13.08.2017

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


Re: Is it worth doing this? - DuyDang2412 - 13.08.2017

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



Re: Is it worth doing this? - Kane - 13.08.2017

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


Re: Is it worth doing this? - Paulice - 13.08.2017

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.


Re: Is it worth doing this? - DuyDang2412 - 13.08.2017

Thank you, I understood.


Re: Is it worth doing this? - Beckett - 13.08.2017

Код:
[[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.


Re: Is it worth doing this? - DuyDang2412 - 13.08.2017

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.