SA-MP Forums Archive
mysql coordinat save problem - 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: mysql coordinat save problem (/showthread.php?tid=518538)



mysql coordinat save problem - Symbiosis - 10.06.2014

I have roleplay server i want save my positions.X and Y pos saves but Z pos is saves 0.

Here is my onplayer disconnect code

Код:
new Float:ax,Float:ay,Float:az;
GetPlayerPos(playerid,ax,ay,az);
PlayerInfo[playerid][PosX] = ax;
PlayerInfo[playerid][PosY] = ay;
PlayerInfo[playerid][PosZ] = az;
Update(playerid, PosXx);
Update(playerid, PosYx);
Update(playerid, PosZx);
here is my update functions posz code

Код:
case PosZx:
{
format(var, sizeof(var), "UPDATE `players` SET `posZ`='%f' WHERE `username`='%s'", PlayerInfo[playerid][PosZ], playerName);
mysql_query(handle ,var);
}



Re: mysql coordinat save problem - BroZeus - 10.06.2014

use %1f instead of %f in format line


Re: mysql coordinat save problem - Symbiosis - 10.06.2014

still saves z position 0


Re: mysql coordinat save problem - KtotheYle - 10.06.2014

Try making it `posz` = %f instead of `posz` = '%f'

So it would be
pawn Код:
case PosZx:
{
format(var, sizeof(var), "UPDATE `players` SET `posZ`=%f WHERE `username`='%s'", PlayerInfo[playerid][PosZ], playerName);
mysql_query(handle ,var);
}
Also make sure that the case is correct, cause the function may not even be ran.


Re: mysql coordinat save problem - Symbiosis - 10.06.2014

still saves 0 x and y coordinates saves successfully but z saves 0


Re: mysql coordinat save problem - KtotheYle - 10.06.2014

Which MySQL are you using? Is the mysql_query the same as the x and y?


Re: mysql coordinat save problem - Symbiosis - 10.06.2014

Код:
case PosXx:
{
format(var, sizeof(var), "UPDATE `players` SET `posX`=%f WHERE `username`='%s'", PlayerInfo[playerid][PosX], playerName);
mysql_query(handle ,var);
}

case PosYx:
{
format(var, sizeof(var), "UPDATE `players` SET `posY`=%f WHERE `username`='%s'", PlayerInfo[playerid][PosY], playerName);
mysql_query(handle ,var);
}

case PosZx:
{
format(var, sizeof(var), "UPDATE `players` SET `posZ`=%f WHERE `username`='%s'", PlayerInfo[playerid][PosZ], playerName);
mysql_query(handle ,var);
}



Re: mysql coordinat save problem - KtotheYle - 10.06.2014

Try doing something like this, put your x, y, and z saving all in the same format, you should be able to.


Re: mysql coordinat save problem - Symbiosis - 10.06.2014

Quote:
Originally Posted by KtotheYle
Посмотреть сообщение
Try doing something like this, put your x, y, and z saving all in the same format, you should be able to.
still same

Код:
case savepos:
{
format(var, sizeof(var), "UPDATE `players` SET `posX`='%f',`posY`='%f',`posZ`='%f' WHERE `username`='%s'", PlayerInfo[playerid][PosX],PlayerInfo[playerid][PosY],PlayerInfo[playerid][PosZ],playerName);
mysql_query(handle ,var);
}



Re: mysql coordinat save problem - Symbiosis - 10.06.2014

solved