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], 60, nome);
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(playerid, Account[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(playerid, name, sizeof(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(inputtextt, sizeof(inputtextt), "%s", inputtext);
format(string, 128, "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.