Need help with my gamemode
#1

I need some help with my gamemode, it is MySQL and has 2,500 lines. The Login/Register system is broke, plus it doesn't save the account to the database. I've tried looking for the problem, but can't find anything. If you could help, please post or PM me. Thank you
Reply
#2

what's version mysql plugin ?

show me login/register code and onplayerdisconnect
Reply
#3

MySQL R39

pawn Код:
forward AccountExists(playerid); // Checks if the master account is already registered.
public AccountExists(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        new str[128];
        format(str, sizeof(str), "SELECT `mID` FROM `MasterAccount` WHERE `mID` = '%s'", PlayerName(playerid));
        mysql_query(gHandle, str);
        if(cache_num_rows() >=1)
        {
            return true;
        }
    }
    return false;
}

forward MasterAccountLogin(playerid, password[]); // Login to an existing master account.
public MasterAccountLogin(playerid, password[])
{
    if(IsPlayerConnected(playerid))
    {
        if(AccountExists(playerid))
        {
            if(strlen(password) >= 1 && strlen(password) <= 20)
            {
                if(MasterAccount[playerid][mLoggedIn])
                {
                    new rows, fields;
                    new value[128];
                    new query[128];
                    format(query, sizeof(query), "SELECT * FROM `MasterAccount` WHERE `username` = '%s' AND `mPassword` = '%s'", MasterAccount[playerid][mOriginalUsername] , MasterAccount[playerid][mPassword]);
                    cache_get_data(rows, fields);
                    if(rows >=1)
                    {
                        SetPlayerColor(playerid, COLOR_LIGHTGREEN);
                        MasterAccount[playerid][mLoggedIn] = true;
                        cache_get_field_content(0, "password", MasterAccount[playerid][mPassword], 20);
                        cache_get_field_content(0, "email_address", MasterAccount[playerid][mEmailAddress], 30);
                        cache_get_field_content(0, "ip_address", MasterAccount[playerid][mOld_IP], 20);
                        cache_get_field_content(0, "super_admin", value, 5); MasterAccount[playerid][mSuperAdmin] = strval(value);
                        cache_get_field_content(0, "id", value, 15); MasterAccount[playerid][mID] = strval(value);
                        ShowMenuDialog(playerid);
                        printf("Password: %s, Email Address: %s, Last IP Used: %s, Super Admin: %d, ID: %d.", MasterAccount[playerid][mPassword],  MasterAccount[playerid][mEmailAddress],  MasterAccount[playerid][mOld_IP], MasterAccount[playerid][mSuperAdmin], MasterAccount[playerid][mID]);
                        return true;
                    }
                    else
                    {
                        SetPVarInt(playerid, "LOGIN_ATTEMPTS", GetPVarInt(playerid, "LOGIN_ATTEMPTS") + 1);
                        switch(GetPVarInt(playerid, "LOGIN_ATTEMPTS"))
                        {
                            case 1: ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Master Account - Login","The password you entered is incorrect.","Login","Cancel");
                            case 2: ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Master Account - Login","The password you entered is incorrect.","Login","Cancel");
                            case 3: ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Master Account - Login","The password you entered is incorrect.","Login","Cancel");
                            case 4: Kick(playerid);
                        }
                    }
                }
            }
            else
            {
                ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Master Account - Login","Account already registered, please enter your password to continue.","Login","Cancel");
            }
        }
    }
    return false;
}

forward MasterAccountRegister(playerid); // Register a new Master Account if name not already in use.
public MasterAccountRegister(playerid)
{
    if(!AccountExists(playerid))
    {
        new Query[300];
        mysql_format(0, Query, sizeof (Query), "INSERT INTO Master (username,password,email_address,ip_address,super_admin,old_ip) VALUES ('%e' , '%e', '%e', '%e', 0, 'UNKNOWN')", PlayerName(playerid), GetPVarStringEx(playerid, "TEMP_PASSWORD"), GetPVarStringEx(playerid, "TEMP_EMAIL"), GetPlayerIPEx(playerid));
        mysql_tquery(0, Query, "", "");
        DeletePVar(playerid,"TEMP_EMAIL");
        DeletePVar(playerid,"TEMP_PASSWORD");
        return true;
    }
    return false;
}
forward ShowMenuDialog(playerid);
public ShowMenuDialog(playerid)
{
    new count = 0;   // , CharacterName[MAX_PLAYER_NAME];
    format(MasterAccount[playerid][mCharacterString], 128, ""); // Resetting Character list string, because reading text from list is impossible.
    if(MasterAccount[playerid][mLoggedIn])
    {
        new str[128];
        format(str, sizeof(str), "SELECT * FROM `PlayerCharacter` WHERE ( `owner_id` = '%d' )", MasterAccount[playerid][mID]);
        mysql_query(1, str);
        if(cache_num_rows() >=1)
        {
            ShowPlayerDialog(playerid, DIALOG_MAIN_MENU, DIALOG_STYLE_LIST, "Main Menu - Character Selection", "No characters available.", "Spawn", "Options");
        }
        for(new a;a<count;a++)
        {
            new test[128];
            cache_get_field_content(0, "name", test);  //CharacterName, MAX_PLAYER_NAME);
            format( MasterAccount[playerid][mCharacterString], 128, "%s\n  ", MasterAccount[playerid][mCharacterString]); /*RemoveUnderScore(CharacterName)*//*%s*/
            //db_next_row(qresult);
        }
        if(strlen(MasterAccount[playerid][mCharacterString]) >= 1) { ShowPlayerDialog(playerid, DIALOG_MAIN_MENU, DIALOG_STYLE_LIST, "Main Menu - Character Selection", MasterAccount[playerid][mCharacterString], "Spawn", "Options"); }
    }
}
public OnPlayerConnect(playerid)
{
    new query[128];
    GetPlayerName(playerid, Player_Name[playerid], MAX_PLAYER_NAME);
    GetPlayerIp(playerid, Player_Ip[playerid], 16);
    mysql_format(1, query, sizeof(query),"SELECT `mPassword`, `ID` FROM `MainAccount` WHERE `mOriginalUsername` = '%e' LIMIT 1", Player_Name[playerid]);
   
    mysql_tquery(1, query, "OnAccountCheck", "i", playerid);
 
    // -------------------------- [ RESETTING VARIABLES ] ----------------------------
    ResetPlayerCharacterVariables(playerid);
    ResetMasterAccountVariables(playerid);

    //-----------------------------[STARTUP CAMERA POS]-------------------------------
    SetPlayerColor(playerid, COLOR_DARKGREY);
    SetPlayerCameraPos(playerid, 2126.0251,1283.9984,63.0858);
    SetPlayerCameraLookAt(playerid,92178.8748,1285.5367,39.5399);

    if(AccountExists(playerid))
    {
        ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Master Account - Login","Account already registered, please enter your password to continue.","Login","Cancel");
    }
    else
    {
        ShowPlayerDialog(playerid,DIALOG_REGISTER_PASSWORD,DIALOG_STYLE_INPUT,"Master Account Registration - Step One","Password:\n( No more or less than 20 characters )","Continue","Cancel");
    }
    ClearScreen(playerid);
    SendClientMessage(playerid, COLOR_WHITE, "Welcome!");
    return 1;
}
forward StartTimer(playerid);
public StartTimer(playerid)
{
    new Text:JoinText;
    new joinmsg[256];
    if(MasterAccount[playerid][mLoggedIn] && Character[playerid][cAdminLevel] >= 1)
    {
        format(joinmsg, sizeof(joinmsg), "%s has joined the Server. {FFFFFF}IP: -To be done- ID: %d.", RemoveUnderScore(playerid), playerid);  /*{FFFFFF}IP: %s   GetIP(playerid), */
        SendToAdmins(COLOR_RED, joinmsg, 0);
        SendToAdmins(COLOR_RED, joinmsg, 1);
    }
    TextDrawHideForPlayer(playerid, JoinText);
    // if(Player[playerid][RegistrationStep] == 0)
    {
        if(Character[playerid][SpawnPoint] == 1) //North Caravan Park
        {
            TogglePlayerSpectating(playerid, false);
            if(Character[playerid][ClothesUsed] == 1)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes1], 765.9069,361.9311,20.8550,174.3097, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
            else if(Character[playerid][ClothesUsed] == 2)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes2], 765.9069,361.9311,20.8550,174.3097, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
            else if(Character[playerid][ClothesUsed] == 3)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes3], 765.9069,361.9311,20.8550,174.3097, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                if(Character[playerid][Faction] == 3)
                {
                    GivePlayerWeapon(playerid, 43, 20);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
        }
        else if(Character[playerid][SpawnPoint] == 2) //Blueberry Caravan Park
        {
            TogglePlayerSpectating(playerid, false);
            if(Character[playerid][ClothesUsed] == 1)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes1], 252.1177,-310.5331,1.5836,52.7107, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
            else if(Character[playerid][ClothesUsed] == 2)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes2], 252.1177,-310.5331,1.5836,52.7107, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
            else if(Character[playerid][ClothesUsed] == 3)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes3], 252.1177,-310.5331,1.5836,52.7107, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
            SetPlayerVirtualWorld(playerid, 0);
        }
        else if(Character[playerid][SpawnPoint] == 3) //Palomino Creek Caravan Park
        {
            TogglePlayerSpectating(playerid, false);
            if(Character[playerid][ClothesUsed] == 1)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes1], 2266.2488,27.3444,26.4328,4.8782, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                SetPlayerVirtualWorld(playerid, 0);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
            else if(Character[playerid][ClothesUsed] == 2)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes2], 2266.2488,27.3444,26.4328,4.8782, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                SetPlayerVirtualWorld(playerid, 0);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
            else if(Character[playerid][ClothesUsed] == 3)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes3], 2266.2488,27.3444,26.4328,4.8782, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
               
                SetPlayerVirtualWorld(playerid, 0);
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
        }
        else if(Character[playerid][SpawnPoint] == 4) //Montgomery Caravan Park
        {
            TogglePlayerSpectating(playerid, false);
            if(Character[playerid][ClothesUsed] == 1)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes1], 1284.0914,168.3455,20.4620,354.0366, 0, 0, 0, 0, 0, 0);
                SetPlayerVirtualWorld(playerid, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
            else if(Character[playerid][ClothesUsed] == 2)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes2], 1284.0914,168.3455,20.4620,354.0366, 0, 0, 0, 0, 0, 0);
                SetPlayerVirtualWorld(playerid, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
            else if(Character[playerid][ClothesUsed] == 3)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes3], 1284.0914,168.3455,20.4620,354.0366, 0, 0, 0, 0, 0, 0);
                SetPlayerVirtualWorld(playerid, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
        }
        else if(Character[playerid][SpawnPoint] == 5) //Owned Home
        {
            TogglePlayerSpectating(playerid, false);
            if(Character[playerid][ClothesUsed] == 1)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes1], Houses[Character[playerid][HouseKey]][HouseExteriorX], Houses[Character[playerid][HouseKey]][HouseExteriorY], Houses[Character[playerid][HouseKey]][HouseExteriorZ], 90.0, 0, 0, 0, 0, 0, 0);
                SetPlayerVirtualWorld(playerid, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
            else if(Character[playerid][ClothesUsed] == 2)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes2], Houses[Character[playerid][HouseKey]][HouseExteriorX], Houses[Character[playerid][HouseKey]][HouseExteriorY], Houses[Character[playerid][HouseKey]][HouseExteriorZ], 90.0, 0, 0, 0, 0, 0, 0);
                SetPlayerVirtualWorld(playerid, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
            else if(Character[playerid][ClothesUsed] == 3)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes3], Houses[Character[playerid][HouseKey]][HouseExteriorX], Houses[Character[playerid][HouseKey]][HouseExteriorY], Houses[Character[playerid][HouseKey]][HouseExteriorZ], 90.0, 0, 0, 0, 0, 0, 0);
                SetPlayerVirtualWorld(playerid, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
        }
        else if(Character[playerid][SpawnPoint] == 6) //Faction Spawn
        {
            TogglePlayerSpectating(playerid, false);
            if(Character[playerid][ClothesUsed] == 1)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes1], Factions[Character[playerid][Faction]][fSpawnX], Factions[Character[playerid][Faction]][fSpawnY], Factions[Character[playerid][Faction]][fSpawnZ], Factions[Character[playerid][Faction]][fSpawnA], 0, 0, 0, 0, 0, 0);
                SetPlayerVirtualWorld(playerid, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
            else if(Character[playerid][ClothesUsed] == 2)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes2], Factions[Character[playerid][Faction]][fSpawnX], Factions[Character[playerid][Faction]][fSpawnY], Factions[Character[playerid][Faction]][fSpawnZ], Factions[Character[playerid][Faction]][fSpawnA], 0, 0, 0, 0, 0, 0);
                SetPlayerVirtualWorld(playerid, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
            else if(Character[playerid][ClothesUsed] == 3)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes3], Factions[Character[playerid][Faction]][fSpawnX], Factions[Character[playerid][Faction]][fSpawnY], Factions[Character[playerid][Faction]][fSpawnZ], Factions[Character[playerid][Faction]][fSpawnA], 0, 0, 0, 0, 0, 0);
                SetPlayerVirtualWorld(playerid, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
        }
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}
Reply
#4

If you want save character / account, just put a Save code in OnPlayerDisconnect

Example

pawn Код:
forward CharacterSave(playerid)
public CharacterSave(playerid)
{
    new query[512];
    mysql_format(gHandle, query, sizeof(query), "UPDATE PlayerCharacter SET `name` = '%e', `level` = %d WHERE `owner_id` = %d", MasterAccount[playerid][mCharacterName], MasterAccount[playerid][mCharacterLevel], MasterAccount[playerid][mID]);
    mysql_query(gHandle, query);
    printf("Save Character : %s, Account ID: %d", MasterAccount[playerid][mCharacterName], MasterAccount[playerid][mID]);
}

public OnPlayerDisconnect(playerid, reason)
{
    CharacterSave(playerid);
    return 1;
}
Reply
#5

My login system is broke.
Reply
#6

Show me OnDialogResponse
Reply
#7

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER_PASSWORD:
        {
            if(response)
            {
                if(strlen(inputtext) >= 1 && strlen(inputtext) <= 20)
                {
                    SetPVarString(playerid,"TEMP_PASSWORD",inputtext);
                    ShowPlayerDialog(playerid,DIALOG_REGISTER_EMAIL,DIALOG_STYLE_INPUT,"Master Account Registration - Step Two","Email Address:\n( No more or less than 25 characters )","Finish","Cancel");
                }
                else
                {
                    ShowPlayerDialog(playerid,DIALOG_REGISTER_PASSWORD,DIALOG_STYLE_PASSWORD,"Master Account Registration - Step One","Password:\n( No more or less than 20 characters )","Continue","Cancel");
                }
            }
            else
            {
                Kick(playerid);
            }
        }
        case DIALOG_REGISTER_EMAIL:
        {
            if(response)
            {
                if(strlen(inputtext) >= 1 && strlen(inputtext) <= 30)
                {
                    SetPVarString(playerid,"TEMP_EMAIL",inputtext);
                    if(MasterAccountRegister(playerid))
                    {
                        ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Master Account - Login","Account already registered, please enter your password to continue.","Login","Cancel");
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_RED, "ERROR.");
                        Kick(playerid);
                    }
                }
                else
                {
                    ShowPlayerDialog(playerid,DIALOG_REGISTER_EMAIL,DIALOG_STYLE_INPUT,"Master Account Registration - Step Two","Email Address:\n( No more or less than 25 characters )","Finish","Cancel");
                }
            }
            else
            {
                Kick(playerid);
            }
        }
        case DIALOG_LOGIN:
        {
            if(response)
            {
                MasterAccountLogin(playerid, inputtext);
            }
        }
        case DIALOG_MAIN_MENU:
        {
            if(response)
            {
                new count = PlayerCharacterCount(playerid);
                if(count == 0)
                {
                    SendClientMessage(playerid, COLOR_WHITE, "[I:] No characters available to spawn with.");
                    ShowMenuDialog(playerid);
                }
                else
                {
                    LoadCharacter(playerid, InsertPlayerUnderscoreString(GetMenuDialogCharacterOrder(playerid, listitem+1)));
                }
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOG_MAIN_MENU_OPTIONS, DIALOG_STYLE_LIST, "Main Menu - Options", "Create New Character\nDelete Character\nChange Password\nDisconnect", "Continue", "Go Back");
            }
        }
        case DIALOG_MAIN_MENU_OPTIONS:
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0: // Create New Character
                    {
                        if(PlayerCharacterCount(playerid) < MAX_CHARACTER_SLOTS)
                        {
                            ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CREATE_CHARACTER_NAME,DIALOG_STYLE_INPUT,"Master Account - New Character","What do you want your character to be called?\n(Firstname Lastname format).","Continue","Go Back");
                        }
                        else
                        {
                            ShowMenuDialog(playerid);
                            SendClientMessage(playerid, COLOR_RED, "[I:] You have exceeded your character limit, and cannot create anymore.");
                        }
                    }
                    case 1: // Delete Character
                    {
                        ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHARACTER_DELETE,DIALOG_STYLE_INPUT,"Master Account - Delete Character","What is the name of the character you wish to delete?\nYou will not be able to recover it after it has been deleted!\n(Firstname Lastname format)","Delete","Go Back");
                    }
                    case 2: // Change Password
                    {
                        ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHANGE_PASSWORD,DIALOG_STYLE_INPUT,"Master Account - Change Password","Type your new desired password:","Change","Go Back");
                    }
                    case 3: // Disconnect
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "[I:] You have safely disconnected.");
                        Kick(playerid);
                    }
                }
            }
            else
            {
                ShowMenuDialog(playerid);
            }
        }
        case DIALOG_MAIN_MENU_CHARACTER_DELETE:
        {
            if(response)
            {
                if(strlen(inputtext) >= 1)
                {
                    if(CharacterExists(inputtext))
                    {
                        new escapedstring[50];
                        mysql_real_escape_string(InsertPlayerUnderscoreString(inputtext), escapedstring);
                        if(PlayerOwnsCharacter_Name(playerid, escapedstring))
                        {
                            new query[128];
                            format(query, sizeof(query), "DELETE FROM `Character` WHERE `cName` = '%s'", InsertPlayerUnderscoreString(inputtext)); //(InsertPlayerUnderscoreString(inputtext) //2464
                           
                            format(query, sizeof(query), "[I:] You have successfully deleted character: %s.", inputtext);
                            SendClientMessage(playerid, COLOR_YELLOW, query);
                            ShowMenuDialog(playerid);
                        }
                        else
                        {
                            ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHARACTER_DELETE,DIALOG_STYLE_INPUT,"Master Account - Delete Character","What is the name of the character you wish to delete?\nYou will not be able to recover it after it has been deleted!\n(Firstname Lastname format)","Delete","Go Back");
                        }
                    }
                    else
                    {
                         ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHARACTER_DELETE,DIALOG_STYLE_INPUT,"Master Account - Delete Character","What is the name of the character you wish to delete?\nYou will not be able to recover it after it has been deleted!\n(Firstname Lastname format)","Delete","Go Back");
                    }
                }
                else
                {
                     ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHARACTER_DELETE,DIALOG_STYLE_INPUT,"Master Account - Delete Character","What is the name of the character you wish to delete?\nYou will not be able to recover it after it has been deleted!\n(Firstname Lastname format)","Delete","Go Back");
                }
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOG_MAIN_MENU_OPTIONS, DIALOG_STYLE_LIST, "Main Menu - Options", "Create New Character\nDelete Character\nChange Password\nDisconnect", "Continue", "Go Back");
            }
        }
        case DIALOG_MAIN_MENU_CREATE_CHARACTER_NAME:
        {
            new firstname[MAX_PLAYER_NAME], lastname[MAX_PLAYER_NAME];
            if(response)
            {
                if(strlen(inputtext) >= 1 && strlen(inputtext) <= MAX_PLAYER_NAME)
                {
                    if(!CharacterExists(InsertPlayerUnderscoreString(inputtext)))
                    {
                        if(RPName(InsertPlayerUnderscoreString(inputtext), firstname, lastname))
                        {
                            SetPVarString(playerid,"TEMP_C_NAME",InsertPlayerUnderscoreString(inputtext)); //2501
                        }
                        else
                        {
                            ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CREATE_CHARACTER_NAME,DIALOG_STYLE_INPUT,"Master Account - New Character","The character name you entered is not a valid roleplay name.\n(Firstname Lastname format).","Continue","Go Back");
                        }
                    }
                    else
                    {
                        ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CREATE_CHARACTER_NAME,DIALOG_STYLE_INPUT,"Master Account - New Character","A character with that name is already registered, please choose another name.\n(Firstname Lastname format).","Continue","Go Back");
                    }
                }
                else
                {
                    ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CREATE_CHARACTER_NAME,DIALOG_STYLE_INPUT,"Master Account - New Character","What do you want your character to be called?\n(Firstname Lastname format).","Continue","Go Back");
                }
                CreateCharacter(playerid, inputtext, Character[playerid][cCash], Character[playerid][cBank], Character[playerid][cSkin]),
                GetPVarStringEx(playerid, "TEMP_C_NAME"),
               
               
                DeletePVar(playerid, "TEMP_C_NAME");
                ShowMenuDialog(playerid);
                SpawnPlayer(playerid);
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOG_MAIN_MENU, DIALOG_STYLE_LIST, "Master Account - New Character","What do you want your character to be called?\n(Firstname Lastname format).","Continue","Go Back");
            }   // Go back.
        }
    } //2540
    return 1;
}
Reply
#8

why you check member loggedin when they don't login yet ?


function MasterAccountLogin
line : if(MasterAccount[playerid][mLoggedIn])

And why you need function AccountsExits when you already have this line in OnPlayerConnect

Quote:

mysql_format(1, query, sizeof(query),"SELECT `mPassword`, `ID` FROM `MainAccount` WHERE `mOriginalUsername` = '%e' LIMIT 1", Player_Name[playerid]);

mysql_tquery(1, query, "OnAccountCheck", "i", playerid);

Reply
#9

Can you show where?
Reply
#10

https://www.youtube.com/watch?v=4TWiajHFrR4&feature

That's what happens when I try and log in.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)