Master account system issue with double logins.
#1

So I have made a master account system. (You login with Stefhan, then pick a character e.g Sean Johnson and your name is set to it.)

This causes other players to be able to connect with Stefhan and even though he is already online, you can join and spawn with another or the same character, because the name isn't taken. Obviously this isn't ment to happen.

How do I prevent this? I put this on OnPlayerConnect but it doesn't work and gives me this error.

PHP Code:
public OnPlayerConnect(playerid)
{
    foreach(new 
i:Player)
    {
        new 
name[MAX_PLAYER_NAME];
        
GetPlayerName(playeridnamesizeof(name));
        if(
Account[i][Username] == name)
        {
            
SendClientMessage(playeridCOLOR_ERROR"Someone is already connected with this account.") && SendClientMessage(playeridCOLOR_INFO"Please login with a different username.");
            
SetTimerEx("KickTimer"200false"i"playerid);
        }
    }
    return 
1;

PHP Code:
error 033: array must be indexed (variable "name"
Reply
#2

Try this, use strcmp to compare strings instead of "==".

Code:
if(strcmp(Account[i][Username], name, true) == 0)
{
	SendClientMessage(playerid, COLOR_ERROR, "Someone is already connected with this account.") && SendClientMessage(playerid, COLOR_INFO, "Please login with a different username.");
	SetTimerEx("KickTimer", 200, false, "i", playerid); 
}
Reply
#3

Quote:
Originally Posted by Boarden
View Post
Try this, use strcmp to compare strings instead of "==".

Code:
if(strcmp(Account[i][Username], name, true) == 0)
{
	SendClientMessage(playerid, COLOR_ERROR, "Someone is already connected with this account.") && SendClientMessage(playerid, COLOR_INFO, "Please login with a different username.");
	SetTimerEx("KickTimer", 200, false, "i", playerid); 
}
Hi, thanks a lot for trying to help.

It compiles now, but it still doesn't work. I just get kicked when I join, regardless of if someone is already connected.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)