GetPlayerPos help
#1

this is my /createjob command and i want to save in the database the position of the job i create,and for a reason,it saves like this in the database :

PosX -988927382
PosY -992693473
PosZ 1139789443

I mean this are invalid coordonates,why do they save like this

new string[64];
new Float:X,Float:Y,Float:Z;
mysql_format(mysql, szQuery, 256, "INSERT INTO `jobs` (`Name`) VALUES ('%e')", inputtext);
new Cache: result = mysql_query(mysql, szQuery);
new i = cache_insert_id();
PlayerInfo[playerid][pJobId] = i;
cache_delete(result);
format(string, sizeof(string), "Ai creat jobul cu numele {00ffff}%s", inputtext);
SendClientMessage(playerid, -1, string);
GetPlayerPos(playerid, X, Y, Z);

mysql_format(mysql, szQuery, 256, "UPDATE `jobs` SET `PosX` = '%d' WHERE `ID` = '%d'", X, PlayerInfo[playerid][pJobId]);
new Cache: result1 = mysql_query(mysql, szQuery);
cache_delete(result1);

mysql_format(mysql, szQuery, 256, "UPDATE `jobs` SET `PosY` = '%d' WHERE `ID` = '%d'", Y, PlayerInfo[playerid][pJobId]);
new Cache: result2 = mysql_query(mysql, szQuery);
cache_delete(result2);

mysql_format(mysql, szQuery, 256, "UPDATE `jobs` SET `PosZ` = '%d' WHERE `ID` = '%d'", Z, PlayerInfo[playerid][pJobId]);
new Cache: result3 = mysql_query(mysql, szQuery);
cache_delete(result3);
Reply
#2

You have to use float datatype instead of int datatype.

pawn Код:
mysql_format(mysql, szQuery, 256, "UPDATE `jobs` SET `PosX` = '%0.2f' , `PosY` = '%0.2f' , `PosZ` = '%0.2f' WHERE `ID` = '%d'", X, Y, Z, PlayerInfo[playerid][pJobId]);
mysql_query(mysql, szQuery);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)