Having trouble with an SQLite account system that I'm working on
#1

Thanks for the help. Converting to MySQL since there is far more support and tutorials there (ironically it isn't native to SA-MP but oh well).
Reply
#2

Your INSERT query doesn't look to me like it would've been formatted correctly, try printing the value of "query" after you format it (in the register function).

Edit: By the way, you know SQL databases support default values right? So you wouldn't need to fill in any of those columns if you set default values in the table beforehand. Any row inserted then without specifying the value of a column will just default to that value, so all you would need to insert in your case would be the IP, name and password.
Reply
#3

Sorry about the delayed reply, I've been away from home.

On Topic:
So I changed the registration script around a little and it doesn't seem to be working at all. I also made a few changes to the overall GM.
  • Ditched the 'ShowLoginScreen' and 'ShowRegisterScreen' functions for the regular 'ShowPlayerDialog' so I can do more "personalized" responses.
  • (Not that it matters or anything) Prevented spawning without logging in/registering.
Here is the semi-updated script (Now with bug checking :P)...
pawn Код:
stock RegisterPlayer(playerid, password[])
{
    new
        query[2048],
        DBResult:queryResult,
        playerIP[24],
        hashpass[129],
        string[128]
    ;

    WP_Hash(hashpass, sizeof(hashpass), password);
    GetPlayerIp(playerid, playerIP, sizeof(playerIP));

    format(query, sizeof(query), "INSERT INTO `"TABLE_NAME"` (`Password`, `PlayerIP`, `Money`, `BankMoney`) VALUES ('%s', '%s', 7500, 5000) WHERE Username = '%s'", hashpass, playerIP, PlayerName(playerid));
    printf("Success: %s", query);
    queryResult = db_query(serverDB, query);
    db_free_result(queryResult);

    GivePlayerMoney(playerid, (7500 - GetPlayerMoney(playerid)));
    PlayerInfo[playerid][BankMoney] = 5000;
    PlayerInfo[playerid][AdminLevel] = 0;
    PlayerInfo[playerid][RegularPlayer] = 0;
    PlayerInfo[playerid][SavedWantedLevel] = 0;
    PlayerInfo[playerid][SavedJailTime] = 0;
    PlayerInfo[playerid][RobRank] = 0;
    PlayerInfo[playerid][RapeRank] = 0;
    PlayerInfo[playerid][DrugDealerRank] = 0;
    PlayerInfo[playerid][GunDealerRank] = 0;
    PlayerInfo[playerid][HitmanRank] = 0;
    PlayerInfo[playerid][MedicRank] = 0;
    PlayerInfo[playerid][MechanicRank] = 0;
    PlayerInfo[playerid][BountyHunterRank] = 0;
    PlayerInfo[playerid][KidnapperRank] = 0;
    PlayerInfo[playerid][TerroristRank] = 0;
    PlayerInfo[playerid][HasBriefcase] = 0;
    PlayerInfo[playerid][BriefcaseMoney] = 0;
    PlayerInfo[playerid][BriefcaseC4] = 0;
    PlayerInfo[playerid][BriefcaseWeaponSlot1] = 0;
    PlayerInfo[playerid][BriefcaseWeaponAmmoSlot1] = 0;
    PlayerInfo[playerid][BriefcaseWeaponSlot2] = 0;
    PlayerInfo[playerid][BriefcaseWeaponAmmoSlot2] = 0;
    PlayerInfo[playerid][BriefcaseWeaponSlot3] = 0;
    PlayerInfo[playerid][BriefcaseWeaponAmmoSlot3] = 0;
    PlayerInfo[playerid][CanUseSWAT] = 0;
    PlayerInfo[playerid][CanUseFBI] = 0;
    PlayerInfo[playerid][CanUseArmy] = 0;
    PlayerInfo[playerid][Tazes] = 0;
    PlayerInfo[playerid][Cuffs] = 0;
    PlayerInfo[playerid][Arrests] = 0;
    PlayerInfo[playerid][SWATRank] = 0;
    PlayerInfo[playerid][FBIRank] = 0;
    PlayerInfo[playerid][ArmyRank] = 0;
    PlayerInfo[playerid][GrottiOwner] = 0;
    PlayerInfo[playerid][WangCarsOwner] = 0;
    PlayerInfo[playerid][OttosAutosOwner] = 0;
    PlayerInfo[playerid][AutobahnOwner] = 0;
    PlayerInfo[playerid][AerobahnOwner] = 0;
    PlayerInfo[playerid][HydrobahnOwner] = 0;
    PlayerInfo[playerid][LSDrugHouseOwner] = 0;
    PlayerInfo[playerid][SFDrugHouseOwner] = 0;
    PlayerInfo[playerid][LVDrugHouseOwner] = 0;

    printf("Hashed: %s Output: %s", password, hashpass);

    if(!PlayerHasAccount(playerid))
    {
        SendClientMessage(playerid, COLOR_WHITE, "{FF0000}ERROR: {FFFFFF}Your account was not created. Please contact an {33CCFF}Administrator {FFFFFF}regarding this matter right away!");
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registration Required", "This server requires that you register an account before playing.\n{FF0000}ERROR: {A9C4E4}Your account was not created.", "Register", "Quit");
    }
    else
    {
        format(string, sizeof(string), "You have successfully registered on [SArcr] using the password: {33CCFF}%s", password);
        SendClientMessage(playerid, COLOR_WHITE, string);
        SendClientMessage(playerid, COLOR_WHITE, "Now, simply log in to confirm.");
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Authentication Required", "Congratulations, you have successfully registered on [SArcr]!\nBefore playing you must login\nPlease enter your password in the box below.", "Login", "Quit");
    }
   
    /*format(string, sizeof(string), "You have successfully registered on [SArcr] using the password: {33CCFF}%s", password);
    SendClientMessage(playerid, COLOR_WHITE, string);
    SendClientMessage(playerid, COLOR_WHITE, "Now, simply log in to confirm.");
    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Authentication Required", "Congratulations, you have successfully registered on [SArcr]!\nBefore playing you must login\nPlease enter your password in the box below.", "Login", "Quit");*/

}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)