MySQL Register
#1

Alright, if I set the posx, posy, posz and posa values to all 0's, it makes my account in the database and spawns me in blueberry (as default):

pawn Код:
format(query, sizeof(query), "INSERT INTO playerdata (user, password, score, money, level, vip, kma, rank, kills, deaths, muted, jailed, frozen, mutedtimes, jailedtimes, frozentimes, banned, bannedby, logins, posx, posy, posz, posa, IP) VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', 0, 0, 0, 0, 0, '%s')", pname, passwordstring, Bannedby, IP);
mysql_query(query);
But if I change them to:

pawn Код:
format(query, sizeof(query), "INSERT INTO playerdata (user, password, score, money, level, vip, kma, rank, kills, deaths, muted, jailed, frozen, mutedtimes, jailedtimes, frozentimes, banned, bannedby, logins, posx, posy, posz, posa, IP) VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', 0, 225.1871, -67.3481, 1.4171, 289.2094, '%s')", pname, passwordstring, Bannedby, IP);
mysql_query(query);
It doesn't make my account in the database.
Reply
#2

Do you set default values in your SQL database at all?
Reply
#3

Make sure these 4 columns
Код:
posx, posy, posz, posa
Are of datatype float.
Reply
#4

Yeah, they are under float
Reply
#5

pawn Код:
mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
    mysql_query("CREATE TABLE IF NOT EXISTS playerdata(user VARCHAR(24), password VARCHAR(40), score INT(20), money INT(20), level INT(20), vip INT(20), kma INT(20), rank INT(20), kills INT(20), deaths INT(20), muted INT(20), jailed INT(20), frozen INT(20), mutedtimes INT(20), jailedtimes INT(20), frozentimes INT(20), banned INT(20), bannedby VARCHAR(24), logins INT(20), posx float(20), posy float(20), posz float(20), posa float(20), IP VARCHAR(15) )");
    mysql_debug(1);
Reply
#6

Can you try changing the format function to this?

pawn Код:
format(query, sizeof(query), "INSERT INTO playerdata (user, password, score, money, level, vip, kma, rank, kills, deaths, muted, jailed, frozen, mutedtimes, jailedtimes, frozentimes, banned, bannedby, logins, posx, posy, posz, posa, IP) VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', 0, 225, -67, 1, 289, '%s')", pname, passwordstring, Bannedby, IP);
Reply
#7

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
Can you try changing the format function to this?

pawn Код:
format(query, sizeof(query), "INSERT INTO playerdata (user, password, score, money, level, vip, kma, rank, kills, deaths, muted, jailed, frozen, mutedtimes, jailedtimes, frozentimes, banned, bannedby, logins, posx, posy, posz, posa, IP) VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', 0, 225, -67, 1, 289, '%s')", pname, passwordstring, Bannedby, IP);
Yeah that works except the angle :/
Is there any way I can make it the way I've done? :P
Reply
#8

Quote:
Originally Posted by AphexCCFC
Посмотреть сообщение
Yeah that works except the angle :/
Is there any way I can make it the way I've done? :P
That's very weird. Show me the code where you are spawning the player and changing it's position and angle.

Edit: Found the problem. Increase the size of your query array.
Reply
#9

Here it is, it can't be wrong, it must be to do with what I posted up there ^^ because it doesn't create a column for my account at all in the database upon register if I use the normal position floats, but it does if I don't add .'s to the float.

pawn Код:
stock MySQL_Login(playerid)
{
    new query[300], pname[24], savingstring[20];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT score, money, level, vip, kma, rank, kills, deaths, muted, jailed, frozen, mutedtimes, jailedtimes, frozentimes, banned, bannedby, logins, posx, posy, posz, posa FROM playerdata WHERE user = '%s'", pname);
    mysql_query(query);
    mysql_store_result();
    while(mysql_fetch_row_format(query,"|"))
    {
        mysql_fetch_field_row(savingstring, "score"); SetPlayerScore(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "money"); MoneyGiven[playerid] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "level"); PlayerInfo[playerid][pLevel] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "vip"); PlayerInfo[playerid][pVIP] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "kma"); PlayerInfo[playerid][pKMA] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "rank"); PlayerInfo[playerid][pRank] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "kills"); PlayerInfo[playerid][pKills] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "deaths"); PlayerInfo[playerid][pDeaths] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "muted"); PlayerInfo[playerid][pMuted] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "jailed"); PlayerInfo[playerid][pJailed] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "frozen"); PlayerInfo[playerid][pFrozen] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "mutedtimes"); PlayerInfo[playerid][pMutedTimes] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "jailedtimes"); PlayerInfo[playerid][pJailedTimes] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "frozentimes"); PlayerInfo[playerid][pFrozenTimes] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "banned"); PlayerInfo[playerid][pBanned] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "bannedby"); PlayerInfo[playerid][pBannedBy] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "logins"); PlayerInfo[playerid][pLogins] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "posx"); PlayerInfo[playerid][pPosX] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "posy"); PlayerInfo[playerid][pPosY] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "posz"); PlayerInfo[playerid][pPosZ] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "posa"); PlayerInfo[playerid][pPosA] = strval(savingstring);
    }
    mysql_free_result();
    JustLogged[playerid] = 1;
    Logged[playerid] = 1;
    PlayerInfo[playerid][pLogins]++;
    SetSpawnInfo(playerid, 1, 115, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ], 0, 0, 0, 0, 0, 0, 0);
    SetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
    SetPlayerFacingAngle(playerid, PlayerInfo[playerid][pPosA]);
    SpawnPlayer(playerid);
    return 1;
}
Reply
#10

Quote:
Originally Posted by AphexCCFC
Посмотреть сообщение
Here it is, it can't be wrong, it must be to do with what I posted up there ^^ because it doesn't create a column for my account at all in the database upon register if I use the normal position floats, but it does if I don't add .'s to the float.

pawn Код:
stock MySQL_Login(playerid)
{
    new query[300], pname[24], savingstring[20];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT score, money, level, vip, kma, rank, kills, deaths, muted, jailed, frozen, mutedtimes, jailedtimes, frozentimes, banned, bannedby, logins, posx, posy, posz, posa FROM playerdata WHERE user = '%s'", pname);
    mysql_query(query);
    mysql_store_result();
    while(mysql_fetch_row_format(query,"|"))
    {
        mysql_fetch_field_row(savingstring, "score"); SetPlayerScore(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "money"); MoneyGiven[playerid] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "level"); PlayerInfo[playerid][pLevel] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "vip"); PlayerInfo[playerid][pVIP] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "kma"); PlayerInfo[playerid][pKMA] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "rank"); PlayerInfo[playerid][pRank] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "kills"); PlayerInfo[playerid][pKills] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "deaths"); PlayerInfo[playerid][pDeaths] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "muted"); PlayerInfo[playerid][pMuted] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "jailed"); PlayerInfo[playerid][pJailed] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "frozen"); PlayerInfo[playerid][pFrozen] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "mutedtimes"); PlayerInfo[playerid][pMutedTimes] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "jailedtimes"); PlayerInfo[playerid][pJailedTimes] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "frozentimes"); PlayerInfo[playerid][pFrozenTimes] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "banned"); PlayerInfo[playerid][pBanned] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "bannedby"); PlayerInfo[playerid][pBannedBy] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "logins"); PlayerInfo[playerid][pLogins] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "posx"); PlayerInfo[playerid][pPosX] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "posy"); PlayerInfo[playerid][pPosY] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "posz"); PlayerInfo[playerid][pPosZ] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "posa"); PlayerInfo[playerid][pPosA] = strval(savingstring);
    }
    mysql_free_result();
    JustLogged[playerid] = 1;
    Logged[playerid] = 1;
    PlayerInfo[playerid][pLogins]++;
    SetSpawnInfo(playerid, 1, 115, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ], 0, 0, 0, 0, 0, 0, 0);
    SetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
    SetPlayerFacingAngle(playerid, PlayerInfo[playerid][pPosA]);
    SpawnPlayer(playerid);
    return 1;
}
Have you tried increasing the size of your query array? The one which is inserting.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)