Not inserting all data into mysql database. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Not inserting all data into mysql database. (
/showthread.php?tid=441411)
Not inserting all data into mysql database. -
reckst4r - 02.06.2013
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;
}
Re: Not inserting all data into mysql database. -
Vince - 02.06.2013
Check the order of your variables. You're inserting pname somewhere it isn't supposed to be.
Re: Not inserting all data into mysql database. -
reckst4r - 02.06.2013
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"
Re: Not inserting all data into mysql database. -
Scenario - 02.06.2013
You probably have those fields set to INT in the database. Change them to FLOAT.
Re: Not inserting all data into mysql database. -
reckst4r - 02.06.2013
I actually had to change the INT in the script to FLOAT