Issue with MySQL
#3

I don't see the point of saving passwords as they're only created once and never change script wise.


I reset all the PlayerInfo variables at OnPlayerConnect, is OnPlayerDisconnect neccessary as well?


This is from the function at OnPlayerConnect (I didn't copy it all as there is quite some stuff there regarding showing textdraws, sending messages, and resetting variables.
[pawn]

GetPlayerIp(playerid, IP[playerid], 16);
GetPlayerName(playerid, Name[playerid], 24);
mysql_format(mysql, query, sizeof(query),"SELECT `Password`, `ID` FROM `users` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);

pawn Код:
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
    new rows, fields;
    cache_get_data(rows, fields, mysql);
    if(rows)
    {
        cache_get_field_content(0, "Password", PlayerInfo[playerid][pPass], mysql, 129);
        PlayerInfo[playerid][pID] = cache_get_field_content_int(0, "ID");
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Crazy Street Wars", "{FFFFFF}Welcome back to {F81414}Crazy Street Wars.{FFFFFF}\nType in your password below to login.", "Login", "Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Crazy Street Wars", "{FFFFFF} Welcome to {F81414}Crazy Street Wars!{FFFFFF}\nType in your desired password below to register. ", "Register", "Quit");
    }
    return 1;
}

pawn Код:
forward OnAccountLoad(playerid);
public OnAccountLoad(playerid)
{
    PlayerInfo[playerid][pMoney] = cache_get_field_content_int(0, "Money");
    PlayerInfo[playerid][pAdmin] = cache_get_field_content_int(0, "Admin");
    PlayerInfo[playerid][pVip] = cache_get_field_content_int(0, "Vip");
    PlayerInfo[playerid][pKills] = cache_get_field_content_int(0, "Kills");
    PlayerInfo[playerid][pDeaths] = cache_get_field_content_int(0, "Deaths");
    PlayerInfo[playerid][pScore] = cache_get_field_content_int(0, "Score");
    PlayerInfo[playerid][pRank] = cache_get_field_content_int(0, "Rank");
    PlayerInfo[playerid][pBanned] = cache_get_field_content_int(0, "Banned");
    PlayerInfo[playerid][pWarns] = cache_get_field_content_int(0, "Warns");
    PlayerInfo[playerid][pVW] = cache_get_field_content_int(0, "VW");
    PlayerInfo[playerid][pInt] = cache_get_field_content_int(0, "Interior");
    PlayerInfo[playerid][pMin] = cache_get_field_content_int(0, "Min");
    PlayerInfo[playerid][pHour] = cache_get_field_content_int(0, "Hours");
    PlayerInfo[playerid][pPM] = cache_get_field_content_int(0, "PM");
    PlayerInfo[playerid][pColor] = cache_get_field_content_int(0, "Color");
    PlayerInfo[playerid][pTurfs] = cache_get_field_content_int(0, "Turfs");
    PlayerInfo[playerid][pClan] = cache_get_field_content_int(0, "Clan");
    PlayerInfo[playerid][pClRank] = cache_get_field_content_int(0, "ClRank");
    PlayerInfo[playerid][pClLeader] = cache_get_field_content_int(0, "ClLeader");
    PlayerInfo[playerid][pInvited] = cache_get_field_content_int(0, "Invited");
    PlayerInfo[playerid][pInviting] = cache_get_field_content_int(0, "Inviting");
    return 1;


I also noticed that I forgot to reset pID and pPass variables at the time this was posted, however resetting them at OnPlayerConnect did not help. In case you need anything else, feel free to say so.
Reply


Messages In This Thread
Issue with MySQL - by DraconianGamer - 22.02.2015, 21:40
Re: Issue with MySQL - by PowerPC603 - 22.02.2015, 23:46
Re: Issue with MySQL - by DraconianGamer - 23.02.2015, 21:33
Re: Issue with MySQL - by PowerPC603 - 23.02.2015, 21:44

Forum Jump:


Users browsing this thread: 1 Guest(s)