SA-MP Forums Archive
GetPlayerPos help - 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: GetPlayerPos help (/showthread.php?tid=664697)



GetPlayerPos help - bosmania - 08.03.2019

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);


Re: GetPlayerPos help - UFF - 08.03.2019

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);