Not inserting all data into mysql database.
#1

Hi. I'm trying to make my gamemode save player coordinates when they leave. When a player leaves, it saves everything BUT the coordinates. I tried checking if it actually got the coordinates, and it does. I used format & printf to print the coordinates, and it does indeed print the coordinates. In the MySQL database, I've tried using INT & Float datatypes, but neither of those worked.

pawn Код:
public OnPlayerDisconnect(playerid, reason)
    {
        if(Logged[playerid] == 1)
        {
            new Float:x, Float:y, Float:z, Float:a;
            GetPlayerPos(playerid, x, y, z);
            GetPlayerFacingAngle(playerid, a);
            new money = GetPlayerMoney(playerid);
            new query[300], pname[24], string[35];
            GetPlayerName(playerid, pname, 24);
            format(query, sizeof(query), "UPDATE `playerdata` SET money='%d', vip='%d', posx='%i', posy='%i', posz='%i', posa='%i' WHERE user='%s'",
            money,
            PlayerInfo[playerid][pVip],
            pname,
            x,
            y,
            z,
            a,
            pname);
            mysql_query(query);
            format(string,sizeof(string),"%i, %i, %i, %i",x,y,z,a);
            print(string);
        }
        return 1;
    }
Reply
#2

Check the order of your variables. You're inserting pname somewhere it isn't supposed to be.
Reply
#3

God dammit, I always do that.. I always make a small mistake, but I can never spot it. Thanks though.

EDIT: Though.. It inserts the coordinates now, but it doesn't add any decimal. For example: "1129730000"
Reply
#4

You probably have those fields set to INT in the database. Change them to FLOAT.
Reply
#5

I actually had to change the INT in the script to FLOAT
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)