Mysql Not saving player pos
#1

Why doesnt this code save my player position?
Код:
stock SaveStats(playerid)
{
	new query[256];
	new Float:x, Float:y, Float:z;
	GetPlayerPos(playerid, x, y, z);
	PlayerInfo[playerid][PosX] = x;
	PlayerInfo[playerid][PosY] = y;
	PlayerInfo[playerid][PosZ] = z;
	format(query, sizeof(query), "UPDATE playerdata SET Cash=%i PosX=%f AND PosY=%f AND PosZ=%f WHERE Name='%s'", PlayerInfo[playerid][Cash], PlayerInfo[playerid][PosX], PlayerInfo[playerid][PosX], PlayerInfo[playerid][PosX], GetName(playerid));
	mysql_query(query);
	printf("Player Saved");
	return 1;
}
Anyone?
Will +Rep
Reply
#2

Looking at your query, you have set PosX 3 times instead of X, Y then Z, try this:

Код:
stock SaveStats(playerid)
{
	new query[256];
	new Float:x, Float:y, Float:z;
	GetPlayerPos(playerid, x, y, z);
	PlayerInfo[playerid][PosX] = x;
	PlayerInfo[playerid][PosY] = y;
	PlayerInfo[playerid][PosZ] = z;
	format(query, sizeof(query), "UPDATE playerdata SET Cash=%i PosX=%f AND PosY=%f AND PosZ=%f WHERE Name='%s'", PlayerInfo[playerid][Cash], PlayerInfo[playerid][PosX], PlayerInfo[playerid][PosY], PlayerInfo[playerid][PosZ], GetName(playerid));
	mysql_query(query);
	printf("Player Saved");
	return 1;
}
Reply
#3

Why do this
pawn Код:
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
PlayerInfo[playerid][PosX] = x;
PlayerInfo[playerid][PosY] = y;
PlayerInfo[playerid][PosZ] = z;
when you can just do this?

pawn Код:
GetPlayerPos(playerid, PlayerInfo[playerid][PosX], PlayerInfo[playerid][PosY], PlayerInfo[playerid][PosZ]);
Reply
#4

MP2 is right.You can save lines xD....
You can do the same for angle ...
Reply
#5

Quote:
Originally Posted by JeremyPeterson
Посмотреть сообщение
MP2 is right.You can save lines xD....
You can do the same for angle ...
It's not so much about saving lines (but doing it my way would save you time, which is more important). It's simply unnecessary and a waste of resources (granted, practically nothing, but still).
Reply
#6

It still isnt saving, when they register they spawn at unity station in LS and I INSERT the co-ordinates there, but it doesnt update it with their new co-ordinates when they logoff
Reply
#7

Wonder why no one realized that the query is simply wrong. The keyword AND is reserved for conditionals (i.e. the WHERE clause). Also use commas between fields.

PHP код:
UPDATE playerdata SET Cash=%iPosX=%fPosY=%fPosZ=%f WHERE Name='%s' 
Reply
#8

Thank you so much. Fixed
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)