Master accounts
#1

Hello. I'm attempting to make a master account system, but i'm stuck on how I could do this.

How am I able check which account a user has selected on OnDialogResponse? I have been trying things for about an hour. Sorry I have no code, i'm on my phone.

Thanks!
Reply
#2

what explain this a little better not understanding
Reply
#3

Right. When a user logs onto their master account, they get a list of their accounts. What I wanna know is, how could I find out which account they have selected so I can set their nane to that account name.
Reply
#4

i would start with defining PLAYER_PROFILE_NAME[10][MAX_PLAYER_NAME];
and then experiment with saving the actual account into a seperate directory (like "Babul/ArmsDealer", "Babul/Hitman" (lol) etc.. once your stats got saved into the profile, strcmp the inputtext[] in the dialogresponse after filling it with the profile directories names. the inputtext will contain (first/part of) the profile, so it should be easy to select one to load the profile from..
i did something similar in my object editor, so the idea will work out.
Reply
#5

Should of mentioned earlier, i'm using a MySQL database
Reply
#6

well in the first place if the list pulled up the name y don't u use that same method in choosing set the player name to the item choosen tried that yet?
Reply
#7

Eh.. Why would I send another query?
Reply
#8

I don't see a point in loading all of the characters and storing the data. What if someone has 10 characters? Odds are, they aren't going to use them all! Just make it so it loads the data for the character they want to play on.

However, obviously, you need to load the username's so you can let the player pick one!

Some pseudo-type code I just now wrote up. It in no way works as is, but it should give you a head start!

pawn Код:
enum eCharactersEnum
{
    cID,
    cUsername,
    cDOB,
    cSkin,
    cMoney
   
    // etc, etc, etc
};

new
    pCharacters[MAX_PLAYERS][eCharactersEnum]
;

mysql_function_query(connectionHandle, "SELECT `username` FROM `playerCharacters` WHERE `masteraccountID` = 1291", true, "loadAccounts", "d", playerid); // after master-account authentication or something

new
    loadedCharUsernames[MAX_PLAYERS][MAX_CHARACTERS][MAX_PLAYER_NAME]
;

public loadAccounts(playerid)
{
    new
        rows,
        fields
    ;
   
    cache_get_data(rows, fields);
   
    if(rows > 0)
    {
        new
            szMainString[1000]
        ;
       
        for(new i = 0; i < rows; i++)
        {
            cache_get_row(0, 0, szUsername);
           
            strcat(szMainString, szUsername);
            strcat(szMainString, "\n");
           
            loadedCharUsernames[playerid][i] = szUsername; // obviously won't work, but you get the point: store the username in the var, the i corresponds with the "listitem" number on the dialog
        }
       
        ShowPlayerDialog(playerid, DIALOG_LIST_CHARACTERS, DIALOG_STYLE_LIST, "Select a character to play on...", szMainString, "Select", "");
    }
    return 1;
}

public OnDialogResponse(...)
{
    if(dialogid == DIALOG_LIST_CHARACTERS)
    {
        mysql_function_query(connectionHandle, "SELECT * FROM `playerCharacters` WHERE `cID` = loadedCharUsernames[playerid][listitem]", true, "loadCharacter", "d", playerid);
    }
    return 0;
}

public loadCharacter(playerid)
{
    new
        rows,
        fields
    ;
   
    cache_get_data(rows, fields);
   
    if(rows == 1)
    {
        new
            temp[30]
        ;
       
        // load the data, store it in the character enum       
        cache_get_row(0, 0, temp); pCharacters[playerid][cID] = strval(temp);
        // .......
    }
    return 1;
}
Reply
#9

Aha! That's ehat I wanted to know! I had a feeling you'd be able to help me, i'll try it when I next do some scripting ( probably later on today! ) and post back the results.
Reply
#10

Sounds good. I have complete faith that it would work!

You can feel free to PM me at anytime if you need help with anything. I don't extend that offer to many people...

Lemme' know how it goes!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)