SA-MP Forums Archive
Check name. - 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: Check name. (/showthread.php?tid=624144)



Check name. - SukMathcuck - 11.12.2016

Quote:

Verify that player is already logged in with the same account name and kick.

Hello community, I have a problem, I'm doing a gamemode from scratch and I would like to know how I can check if the player is already online, for example, player 1 first entered the server, and his name was saved in the function:

PHP код:
format(PlayerData[playerid][pConta], 60nome); 
Okay, so he needs to pick a character he has on that account, and picking it out is the name of his character:

PHP код:
SetPlayerName(playeridAccount[playerid][pPersonagem1]); 
Thus, the account function is stored the name of his account, and player 2 entered the server with the same name, but there is a problem the name of player 1 was defined for the name of the character he created.

How can I do this verification?

What I got:

PHP код:
    new name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    
    if(
name == PlayerData[playerid][pConta])
    {
       
SendClientMessage(playerid, -1"Essa conta jб estб online e vocк foi kickado.");
       return 
Kick(playerid);
    } 



Re: Check name. - CantBeJohn - 11.12.2016

Here's a question, when a player logs in and creates a character within the account: you're saving that character's data in a file, correct?

If so, all you have to do to avoid someone else creating the same character name is to check if the file exists where ever you're saving player data.


Re: Check name. - SukMathcuck - 11.12.2016

Quote:
Originally Posted by CantBeJohn
Посмотреть сообщение
Here's a question, when a player logs in and creates a character within the account: you're saving that character's data in a file, correct?

If so, all you have to do to avoid someone else creating the same character name is to check if the file exists where ever you're saving player data.
Correct, but I do not know the quality of the use, to verify the name of the player. I'm looking for a base.


Re: Check name. - CantBeJohn - 12.12.2016

Quote:
Originally Posted by SukMathcuck
Посмотреть сообщение
Correct, but I do not know the quality of the use, to verify the name of the player. I'm looking for a base.
Well, I'm assuming you're allowing players to type out the character names they wish to create. So, in that case you can do this under the dialog that's doing that:

PHP код:
new inputtextt[MAX_PLAYER_NAME], string[128];
format(inputtexttsizeof(inputtextt), "%s"inputtext);
format(string128"Users/%s.ini"inputtextt);
if(
fexist(string)) return SendClientMessage(playerid, -1"[SERVER]: That character is already registered!");
else
{
   
// Your code for creation a new character.

You could use that as a base, although make sure you change the path, I'm only assuming all your users are being saved under "Users".


Re: Check name. - SukMathcuck - 12.12.2016

Tranks.