SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 13/08/2017, 02:59 AM   #1
DuyDang2412
Big Clucker
 
Join Date: Feb 2017
Posts: 126
Reputation: 2
Default Is it worth doing this?

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 Code:
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.
DuyDang2412 is offline   Reply With Quote
Old 13/08/2017, 03:25 AM   #2
X337
Gangsta
 
Join Date: Sep 2014
Location: Indonesia
Posts: 823
Reputation: 176
Default Re: Is it worth doing this?

Nope, because it's impossible.
__________________
viva la sa-mp

X337 is online now   Reply With Quote
Old 13/08/2017, 03:40 AM   #3
Debjit
Little Clucker
 
Join Date: Feb 2017
Posts: 14
Reputation: 2
Default Re: Is it worth doing this?

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


Soon to be on Hosted TAB
Debjit is offline   Reply With Quote
Old 13/08/2017, 05:18 AM   #4
DuyDang2412
Big Clucker
 
Join Date: Feb 2017
Posts: 126
Reputation: 2
Default Re: Is it worth doing this?

Quote:
Originally Posted by X337 View Post
Nope, because it's impossible.
Why is it impossible??

Quote:
Originally Posted by Debjit View Post
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 Code:
    ResetCharacter(playerid); 
    
ClearChat(playerid); 
    
gCharacterLogged[playerid] = false
    
TogglePlayerSpectating(playerid1);  
    
SetPVarInt(playerid"FirstConnection"1); 
    
CreateCharacterNameTag(playerid); 
    
CreateCharacterTextDraws(playerid); 
    
BlacklistCheck(playerid); 
    
RemoveObjects(playerid); 
DuyDang2412 is offline   Reply With Quote
Old 13/08/2017, 06:01 AM   #5
Arthur Kane
Gangsta
 
Join Date: Sep 2012
Posts: 642
Reputation: 26
Default Re: Is it worth doing this?

It's impossible like he said .. the server would deny entry if it's a duplicate name.
Arthur Kane is offline   Reply With Quote
Old 13/08/2017, 06:15 AM   #6
Paulice
Huge Clucker
 
Paulice's Avatar
 
Join Date: Jul 2017
Posts: 243
Reputation: 29
Default Re: Is it worth doing this?

Quote:
Originally Posted by DuyDang2412 View Post
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 Code:
    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.
Paulice is offline   Reply With Quote
Old 13/08/2017, 08:31 AM   #7
DuyDang2412
Big Clucker
 
Join Date: Feb 2017
Posts: 126
Reputation: 2
Default Re: Is it worth doing this?

Thank you, I understood.
DuyDang2412 is offline   Reply With Quote
Old 13/08/2017, 11:31 AM   #8
DaniceMcHarley
High-roller
 
DaniceMcHarley's Avatar
 
Join Date: Feb 2012
Posts: 1,684
Reputation: 83
Default Re: Is it worth doing this?

Code:
[[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.
DaniceMcHarley is offline   Reply With Quote
Old 13/08/2017, 11:58 AM   #9
DuyDang2412
Big Clucker
 
Join Date: Feb 2017
Posts: 126
Reputation: 2
Default Re: Is it worth doing this?

Quote:
Originally Posted by DaniceMcHarley View Post
Code:
[[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.
DuyDang2412 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Was it all worth it? Dairyll General 31 12/11/2014 02:20 AM
Worth doing or not? ross8839 Everything and Nothing 22 17/01/2013 02:55 PM
How much is my PC worth? Harold Everything and Nothing 11 07/05/2012 07:45 PM
How much is this worth? robert4049 Everything and Nothing 15 03/09/2010 09:48 PM


All times are GMT. The time now is 11:47 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.