BIG PROBLEM - I GIVE REP ( 2 players can connect on the same account )
#1

I have a huge problem. I maked a clan sistem which allows players putting a tag infront of the name , e.g : [Oz]Paul , [Oz] = clan tag.
Now , the biggest problem is that 2 players can connect on the same account , one with the name Paul , and the second with the name [Oz]Paul and this is a huge bug. How to restrictionate this?
My enum clan's sistem:
pawn Код:
enum clanE
{
    cClanName[64],
    cClanMOTD[128],
    cClanRankName1[32],
    cClanRankName2[32],
    cClanRankName3[32],
    cClanRankName4[32],
    cClanRankName5[32],
    cClanRankName6[32],
    cClanRankName7[32],
    cClanTag[32],
    cClanTagType,
}
Putting the tag
pawn Код:
case 0:
                {
                    format(string,256,"%s%s",clanVariables[playerVariables[playerid][pClan]][cClanTag],playerVariables[playerid][pNormalName]);
                    SetPlayerName(playerid, string);
                    format(string,256,"Nickname changed to: %s",string);
                    SCM(playerid,COLOR_WHITE,string);
                }
                case 1:
                {
                    format(string,256,"%s%s",playerVariables[playerid][pNormalName],clanVariables[playerVariables[playerid][pClan]][cClanTag]);
                    SetPlayerName(playerid, string);
                    format(string,256,"Nickname changed to: %s",string);
                    SCM(playerid,COLOR_WHITE,string);
                }
                case 2:
                {
                    format(string,256,"%s",playerVariables[playerid][pNormalName]);
                    SetPlayerName(playerid, string);
                    format(string,256,"Nickname changed to: %s",string);
                    SCM(playerid,COLOR_WHITE,string);
                }
pawn Код:
if(playerVariables[extraid][pClan] >= 1)
        {
                    if(playerVariables[extraid][pClanTagType] == 0)
                    {
                        format(string,256,"%s",playerVariables[extraid][pNormalName]);
                        SetPlayerName(extraid, string);
                    }
                    else if(playerVariables[extraid][pClanTagType] == 1)
                    {
                        format(string,256,"%s%s",clanVariables[playerVariables[extraid][pClan]][cClanTag],playerVariables[extraid][pNormalName]);
                        SetPlayerName(extraid, string);
                    }
                    else if(playerVariables[extraid][pClanTagType] == 2)
                    {
                        format(string,256,"%s%s",playerVariables[extraid][pNormalName],clanVariables[playerVariables[extraid][pClan]][cClanTag]);
                        SetPlayerName(extraid, string);
                    }
        }
Reply
#2

If you're using MySQL, update the player's username in database with the new name of the player.
And if you're using an INI based saving system, change the file name with frename function.
Reply
#3

Quote:
Originally Posted by biker122
Посмотреть сообщение
If you're using MySQL, update the player's username in database with the new name of the player.
And if you're using an INI based saving system, change the file name with frename function.
Not such a good idea, the clients would have to login with their full name including the clan tag which would cause inconvenience. Plus someone could make a new account with the original name; and when the original person gets uninvited or resigns from the clan the accounts would clash.

The actual best way is to store the person's original name upon the player connecting, and then define that name as connected. When a new player connects check if the new player's name is the same as the clan member's original name from the variable you just put when the original person connected. When the original person disconnects remove their name from the string to not cause any problems when the original person wants to reconnect.
Reply
#4

It sounds easy but i don't know how to do what Danish said.
When you connect to the server ( and you are logged in ) you could put the tag if you want, if you not it's not needed to put it , however the player wants , but the problem is that the sistem couldn't recognize that [Oz]Paul is Paul , and then 2 can connect on the same account..
And i am using Mysql.
I need an example , more details. thanks.
Reply
#5

Untested, may not work at all:

pawn Код:
new pOriginalName[MAX_PLAYERS][MAX_PLAYER_NAME];
forward KickTimer(playerid);

public OnPlayerConnect(playerid)
{
    new name[MAX_PLAYER_NAME] = GetPlayerName(playerid, name, sizeof(name));
    for(new i = 0; i < MAX_PLAYERS; i ++)
    {
        if(strcmp(pOriginalName[i], name, true) == 0)
        {
            SendClientMessage(playerid, -1, "The name you logged in with is already connected under a clan owner's name.");
            SetTimerEx("KickTimer", 1000, false, "i", playerid);
            return 1;
        }
    }
    pOriginalName[playerid] = name;
    return 1;
}

public KickTimer(playerid)
{
    Kick(playerid);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    strmid(pOriginalName[playerid], "", 0, strlen(""));
    return 1;
}
It doesn't require MySQL at all.
Reply
#6

I tried but no i can't fix it ! UP !!!!
Reply
#7

If I understand , you want to change nickname of somebody and nobody can use the old nickname ?
So if it's this , you can save the old nickname in a database and at the connection check if the name is the same as one of the list , if the name is writed so kick the player .

Sorry for bad english
Reply
#8

Quote:
Originally Posted by DiamantEspace18
Посмотреть сообщение
If I understand , you want to change nickname of somebody and nobody can use the old nickname ?
So if it's this , you can save the old nickname in a database and at the connection check if the name is the same as one of the list , if the name is writed so kick the player .

Sorry for bad english
Player 1: [OG]Test , where [OG] = clan tag
Player 2: Test , without clan tag.
If player 1 is connected on the server, player 2 can connect too and this is my bug. The same account tricking connection.
UP!
Reply
#9

So Both of them will have different names one with clan tag and the other without the clan tag but with the same name and both of them have the same score? is that your problem? it means that there is something wrong with the mysql , Did you change the name of the player from the database after he joins/creats clan and add a nametag? if you didn't then show me your Mysql Info
Reply
#10

Quote:
Originally Posted by Eth
Посмотреть сообщение
So Both of them will have different names one with clan tag and the other without the clan tag but with the same name and both of them have the same score? is that your problem? it means that there is something wrong with the mysql , Did you change the name of the player from the database after he joins/creats clan and add a nametag? if you didn't then show me your Mysql Info
Yes that is my problem , i wil put tomorrow here a pawn text script with the tag system , player can put the tag only from the game. If he connects with the tag infront of his name the account isn't registered and it puts the player to register.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)