SA-MP Forums Archive
Master account system issue with double logins. - 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: Master account system issue with double logins. (/showthread.php?tid=665736)



Master account system issue with double logins. - Stefhan - 14.04.2019

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"



Re: Master account system issue with double logins. - Boarden - 14.04.2019

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



Re: Master account system issue with double logins. - Stefhan - 14.04.2019

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.