Problem with mysql pos saving... :( -
Vvolk - 11.05.2011
I have a problem: I want to save players position then he disconnect and i made the code , but pos doesn't save. There is my code:
Код:
public OnPlayerDisconnect( playerid, reason )
{
new pos[64],pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
new Float:pos1,Float:pos2,Float:pos3;
if ( Logged[ playerid ] )
{
format(pos,sizeof(pos),"UPDATE `"TABLENAME"` SET `Position`='%d,%i,%s' WHERE (`Name` = '%s')",pos1,pos2,pos3,pName);
mysql_query(pos);
}
return 1;
}
I tried to change this: format(pos,sizeof(pos),"UPDATE `"TABLENAME"` SET `Position`='%d,%i,%s' WHERE (`Name` = '%s')",pos1,pos2,pos3,pName); to this:
Код:
format(pos,sizeof(pos),"UPDATE `"TABLENAME"` SET `Position`='%d' WHERE (`Name` = '%s')",GetPlayerPos(playerid,pos1,pos2,pos3),pName);
And i tried to change this so much times but it doesn't work

Please help me somebody. I will be very gratefuul.
Re: Problem with mysql pos saving... :( -
Sascha - 11.05.2011
pawn Код:
new Float:pos1, Float:pos2, Float:pos3;
if(Logged[playerid])
{
GetPlayerPos(playerid, pos1, pos2, pos3);
format(pos, sizeof(pos), "UPDATE `TABLENAME` SET `Position`='%f, %f, %f' WHERE `Name`='%s')", pos1, pos2, pos3, name);
Re: Problem with mysql pos saving... :( -
Vvolk - 11.05.2011
It doesn't work
Re: Problem with mysql pos saving... :( -
black_dota - 11.05.2011
PHP код:
public OnPlayerDisconnect( playerid, reason )
{
new pos[128],pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
new Float:pos1,Float:pos2,Float:pos3;
if(Logged[playerid])
{
format(pos,sizeof(pos),"UPDATE `"TABLENAME"` SET `Position`='%f,%f,%f' WHERE (`Name` = '%s')",pos1,pos2,pos3,pName);
mysql_query(pos);
}
return 1;
}
Re: Problem with mysql pos saving... :( -
Vvolk - 11.05.2011
Doesn't work
Re: Problem with mysql pos saving... :( -
Mean - 11.05.2011
Make sure you change the tablename...
Also, I think Sascha's version should work without the ")" at the end, delete it, so it will look like:
pawn Код:
format(pos, sizeof(pos), "UPDATE `TABLENAME` SET `Position` = '%f, %f, %f' WHERE `Name`='%s'", pos1, pos2, pos3, name)
If not, create more fields, with: posX, posY, posZ
So:
pawn Код:
format( pos, sizeof pos, "UPDATE `TABLENAME` SET `posX` = '%f', `posY` = '%f', `posZ` = '%f' WHERE `Name` = '%s'", pos1, pos2, pos3, name )
Also, check if the pos is already saved, if not, you need to use INSERT INTO.
And make sure you do GetPlayerPos( playerid, pos1, pos2, pos3 ); and then format the query.
EDIT: Also a 64 cell string isn't enough for this query... You need approx 140 cell string for this.
So change
pawn Код:
new pos[64],pName[MAX_PLAYER_NAME];
to
pawn Код:
new pos[ 140 ], pName[ MAX_PLAYER_NAME ];