MySQL Save Bad pos
#1

Код:
        new query[512], Float:xpos, Float:ypos, Float:zpos;
	GetPlayerPos(playerid, xpos, ypos, zpos);
	mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Admin`=%d, `Frakcio`=%d, `Money`=%d,   `posX`=%f, `posY`=%f, `posZ`=%f,`Uj`=%d,`Munka`=%d,`Skin`=%d,`FSkin`=%d  WHERE `ID`=%d",\
	pInfo[playerid][Admin], pInfo[playerid][Frakcio], pInfo[playerid][Money], xpos, ypos, zpos, pInfo[playerid][Uj], pInfo[playerid][Munka], pInfo[playerid][Skin], pInfo[playerid][FSkin], pInfo[playerid][ID]);
	mysql_tquery(mysql, query, "", "");
And the load:

Код:
SetPlayerPos(playerid, pInfo[playerid][posX], pInfo[playerid][posZ], pInfo[playerid][posZ]+ 0.3);
Always set me to Blueberry farm in the air not 0,0,0 coodrinate
Reply
#2

Show your loading code. How do you load the info from the database?
And open up your mysql_log and check if there are any errors
Reply
#3

Код:
forward OnAccountRegister(playerid);
public OnAccountLoad(playerid)
{
 	pInfo[playerid][Admin] = cache_get_field_content_int(0, "Admin");
 	pInfo[playerid][Frakcio] = cache_get_field_content_int(0, "Frakcio");
 	pInfo[playerid][Money] = cache_get_field_content_int(0, "Money");
 	pInfo[playerid][posX] = cache_get_field_content_float(0, "PosX");
 	pInfo[playerid][posY] = cache_get_field_content_float(0, "PosY");
 	pInfo[playerid][posZ] = cache_get_field_content_float(0, "PosZ");
 	pInfo[playerid][Uj] = cache_get_field_content_int(0, "Uj");
 	pInfo[playerid][Munka] = cache_get_field_content_int(0, "Munka");
 	pInfo[playerid][Skin] = cache_get_field_content_int(0, "Skin");
 	pInfo[playerid][FSkin] = cache_get_field_content_int(0, "FSkin");
	SendClientMessage(playerid, -1, "Successfully logged in"); 
	return 1;
}
Код:
[14:56:10] [DEBUG] mysql_connect - host: "localhost", user: "root", database: "samp", password: "****", port: 3306, autoreconnect: true, pool_size: 2
[14:56:10] [DEBUG] CMySQLHandle::Create - creating new connection..
[14:56:10] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called
[14:56:10] [DEBUG] CMySQLHandle::Create - connection created (id: 1)
[14:56:10] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[14:56:10] [DEBUG] CMySQLConnection::Connect - connection was successful
[14:56:10] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[14:56:10] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[14:56:10] [DEBUG] mysql_errno - connection: 1
[14:56:10] [DEBUG] CMySQLConnection::Connect - connection was successful
[14:56:10] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[14:56:10] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[14:56:10] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[14:56:10] [DEBUG] CMySQLConnection::Connect - connection was successful
[14:56:10] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[14:56:10] [DEBUG] CMySQLConnection::Connect - connection was successful
[14:56:10] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[14:56:49] [DEBUG] mysql_format - connection: 1, len: 512, format: "SELECT `Password`, `ID` FROM `players` WHERE `Username` = '%e' LIMIT 1"
[14:56:49] [DEBUG] mysql_tquery - connection: 1, query: "SELECT `Password`, `ID` FROM `players` WHERE `Username` = 'Tom_C", callback: "OnAccountCheck", format: "i"
[14:56:49] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - starting query execution
[14:56:49] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - query was successfully executed within 4.914 milliseconds
[14:56:49] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[14:56:49] [DEBUG] Calling callback "OnAccountCheck"..
[14:56:50] [DEBUG] cache_get_data - connection: 1
[14:56:50] [DEBUG] cache_get_field_content - row: 0, field_name: "Password", connection: 1, max_len: 129
[14:56:50] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Password", data: "A6AFF08FDDD86792EA54AE3099C10A2107A0B75B35220608020BFDDFB72CA16C1CE19ECF22C3255741FAC1E5564EDAF1968455EF1BADFE8443B6174190B93287"
[14:56:50] [DEBUG] cache_get_field_content_int - row: 0, field_name: "ID", connection: 1
[14:56:50] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "ID", data: "1"
[14:56:50] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[14:57:00] [DEBUG] mysql_format - connection: 1, len: 512, format: "SELECT * FROM `players` WHERE `Username` = '%e' LIMIT 1"
[14:57:00] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `players` WHERE `Username` = 'Tom_Curt' LIMIT 1", callback: "OnAccountLoad", format: "i"
[14:57:00] [DEBUG] CMySQLQuery::Execute[OnAccountLoad] - starting query execution
[14:57:00] [DEBUG] CMySQLQuery::Execute[OnAccountLoad] - query was successfully executed within 0.688 milliseconds
[14:57:00] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[14:57:00] [DEBUG] Calling callback "OnAccountLoad"..
[14:57:00] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Admin", connection: 1
[14:57:00] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Admin", data: "3"
[14:57:00] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Frakcio", connection: 1
[14:57:00] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Frakcio", data: "0"
[14:57:00] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Money", connection: 1
[14:57:00] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Money", data: "123"
[14:57:00] [DEBUG] cache_get_field_content_float - row: 0, field_name: "PosX", connection: 1
[14:57:00] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "PosX", data: "-50.3895"
[14:57:00] [DEBUG] cache_get_field_content_float - row: 0, field_name: "PosY", connection: 1
[14:57:00] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "PosY", data: "3.24298"
[14:57:00] [DEBUG] cache_get_field_content_float - row: 0, field_name: "PosZ", connection: 1
[14:57:00] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "PosZ", data: "3.11719"
[14:57:00] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Uj", connection: 1
[14:57:00] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Uj", data: "1"
[14:57:00] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Munka", connection: 1
[14:57:00] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Munka", data: "1"
[14:57:00] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Skin", connection: 1
[14:57:00] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Skin", data: "23"
[14:57:00] [DEBUG] cache_get_field_content_int - row: 0, field_name: "FSkin", connection: 1
[14:57:00] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "FSkin", data: "288"
[14:57:00] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[14:57:07] [DEBUG] mysql_format - connection: 1, len: 512, format: "UPDATE `players` SET `Admin`=%d, `Frakcio`=%d, `Money`=%d, `posX`=%f, `posY`=%f, `posZ`=%f,`Uj`=%d,`Munka`=%d,`Skin`=%d,`FSkin`=..."
[14:57:07] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `players` SET `Admin`=3, `Frakcio`=0, `Money`=123, `posX`", callback: "(null)", format: "(null)"
[14:57:07] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[14:57:07] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 142.30 milliseconds
[14:57:07] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
Log about login in and exit after login
Reply
#4

Is that UPDATE query placed under on player disconnect? If yes, then read this:
Код:
GetPlayerPos:
This function is known to return unreliable values when used in OnPlayerDisconnect and OnPlayerRequestClass. This is because the player is not spawned. - From SA:MP Wiki
Reply
#5

Change mysql_format to format only. As you don't need to escape a string there because there would be nothing to inject.

pawn Код:
format(query, sizeof(query), "UPDATE `players` SET `Admin`=%d, `Frakcio`=%d, `Money`=%d,   `posX`=%f, `posY`=%f, `posZ`=%f,`Uj`=%d,`Munka`=%d,`Skin`=%d,`FSkin`=%d  WHERE `ID`=%d",\
    pInfo[playerid][Admin], pInfo[playerid][Frakcio], pInfo[playerid][Money], xpos, ypos, zpos, pInfo[playerid][Uj], pInfo[playerid][Munka], pInfo[playerid][Skin], pInfo[playerid][FSkin], pInfo[playerid][ID]);
mysql_format usually ignores the decimals. Like if you've got 1691.2412 it will be 1691.24. Happened to me before and fixed it with what I've said above.

Edit: I thought the coordinates saves but not correctly, disregard.
Reply
#6

Read the notes on the wiki page of either GetPlayerPos or OnPlayerDisconnect.
Reply
#7

I'm pretty sure field names are case-sensitive.
You're saving them as 'posX', 'posY' and 'posZ', but trying to read info from 'PosX', 'PosY', 'PosZ'.

Change this:
pawn Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Admin`=%d, `Frakcio`=%d, `Money`=%d,   `posX`=%f, `posY`=%f, `posZ`=%f,`Uj`=%d,`Munka`=%d,`Skin`=%d,`FSkin`=%d  WHERE `ID`=%d",\
    pInfo[playerid][Admin], pInfo[playerid][Frakcio], pInfo[playerid][Money], xpos, ypos, zpos, pInfo[playerid][Uj], pInfo[playerid][Munka], pInfo[playerid][Skin], pInfo[playerid][FSkin], pInfo[playerid][ID]);
With this:
pawn Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Admin`=%d, `Frakcio`=%d, `Money`=%d,   `PosX`=%f, `PosY`=%f, `PosZ`=%f,`Uj`=%d,`Munka`=%d,`Skin`=%d,`FSkin`=%d  WHERE `ID`=%d",\
    pInfo[playerid][Admin], pInfo[playerid][Frakcio], pInfo[playerid][Money], xpos, ypos, zpos, pInfo[playerid][Uj], pInfo[playerid][Munka], pInfo[playerid][Skin], pInfo[playerid][FSkin], pInfo[playerid][ID]);
Reply
#8

Quote:
Originally Posted by Vince
Посмотреть сообщение
Read the notes on the wiki page of either GetPlayerPos or OnPlayerDisconnect.
Yes is it under OnPlayerDisconnect what i able to do?
Reply
#9

MySQL Saved Pos:

X:-46.9965
Y:821.905
Z:32.4494

/save commandSAME PLACE)

X:-46.9965
Y:821.905
Z:32.4494

I have problem with the loading....


*Next time login pos

X:1949.1700
Y:9.1094
Z:3.5063
Reply
#10

Bump,pls help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)