stock LoadStats(playerid)
{
new pName[24],Query[800];
GetPlayerName(playerid,pName,24);
format(Query, sizeof(Query), "SELECT * FROM `Users` WHERE `Username` = '%s' ", pName);
mysql_query(Query);
mysql_store_result();
mysql_fetch_row_format(Query, "|");
sscanf(Query, "e<p<|>s[32]s[32]dddddfffddds[128]dddddddddddddddddddddddddddddddddddddddddddds[10]s[20]ddd>", PInfo[playerid]);
mysql_free_result();
return 1;
}
[11:37:39] CMySQLHandler::FetchRow() - Return: Jari_Johnson|password|5000|6|1|0|0|0|0|0|0|1|0|email@example.com|21|240|0|0|0|0|100|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0||127.0.0.1|3|2|2013 [11:37:39] >> mysql_free_result( Connection handle: 1 )
stock LoadVehicles()
{
new Query[256], count;
for(new i; i < MAX_VEHICLES; i++)
{
format(Query, sizeof(Query), "SELECT * From Vehicles WHERE ID = %d", i);
print(Query);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows())
if(mysql_fetch_row_format(Query, "|"))
{
sscanf(Query, "iiffff", vData[i][vehID], vData[i][vehModel], vData[i][XPos], vData[i][YPos], vData[i][ZPos], vData[i][Angle]);
CreateVehicle(vData[i][vehModel], vData[i][XPos], vData[i][YPos], vData[i][ZPos], vData[i][Angle], random(126), random(126), 60);
printf("%d %d %f %f %f %f", vData[vehID], vData[i][vehModel], vData[i][XPos], vData[i][YPos], vData[i][ZPos], vData[i][Angle]);
mysql_free_result();
count ++;
}
}
printf("%d vehicles were loaded from the database. ", count);
}
[13:59:11] SELECT * From Vehicles WHERE ID = 1 [13:59:11] 0 0 0.000000 0.000000 0.000000 0.000000 [13:59:11] SELECT * From Vehicles WHERE ID = 2 [13:59:11] 0 0 0.000000 0.000000 0.000000 0.000000 [13:59:11] SELECT * From Vehicles WHERE ID = 3 [13:59:11] 0 0 0.000000 0.000000 0.000000 0.000000 [13:59:11] SELECT * From Vehicles WHERE ID = 4 [13:59:11] 0 0 0.000000 0.000000 0.000000 0.000000 |
[14:06:30] CMySQLHandler::Query(SELECT * From Vehicles WHERE ID = 1) - Successfully executed. [14:06:30] >> mysql_store_result( Connection handle: 1 ) [14:06:30] CMySQLHandler::StoreResult() - Result was stored. [14:06:30] >> mysql_num_rows( Connection handle: 1 ) [14:06:30] CMySQLHandler::NumRows() - Returned 1 row(s) [14:06:30] >> mysql_fetch_row_format( Connection handle: 1 ) [14:06:30] CMySQLHandler::FetchRow() - Return: 1|411|4.64056|6.1187|2.86991|52.5 [14:06:30] >> mysql_free_result( Connection handle: 1 ) [14:06:30] CMySQLHandler::FreeResult() - Result was successfully free'd. [14:06:30] >> mysql_query( Connection handle: 1 ) [14:06:30] CMySQLHandler::Query(SELECT * From Vehicles WHERE ID = 2) - Successfully executed. [14:06:30] >> mysql_store_result( Connection handle: 1 ) [14:06:30] CMySQLHandler::StoreResult() - Result was stored. [14:06:30] >> mysql_num_rows( Connection handle: 1 ) [14:06:30] CMySQLHandler::NumRows() - Returned 1 row(s) [14:06:30] >> mysql_fetch_row_format( Connection handle: 1 ) [14:06:30] CMySQLHandler::FetchRow() - Return: 2|411|8.7544|2.96196|2.8367|52.4999 [14:06:30] >> mysql_free_result( Connection handle: 1 ) [14:06:30] CMySQLHandler::FreeResult() - Result was successfully free'd. [14:06:30] >> mysql_query( Connection handle: 1 ) [14:06:30] CMySQLHandler::Query(SELECT * From Vehicles WHERE ID = 3) - Successfully executed. [14:06:30] >> mysql_store_result( Connection handle: 1 ) [14:06:30] CMySQLHandler::StoreResult() - Result was stored. [14:06:30] >> mysql_num_rows( Connection handle: 1 ) [14:06:30] CMySQLHandler::NumRows() - Returned 1 row(s) [14:06:30] >> mysql_fetch_row_format( Connection handle: 1 ) [14:06:30] CMySQLHandler::FetchRow() - Return: 3|411|15.1183|-1.9213|2.84453|52.5 [14:06:30] >> mysql_free_result( Connection handle: 1 ) [14:06:30] CMySQLHandler::FreeResult() - Result was successfully free'd. [14:06:30] >> mysql_query( Connection handle: 1 ) [14:06:30] CMySQLHandler::Query(SELECT * From Vehicles WHERE ID = 4) - Successfully executed. [14:06:30] >> mysql_store_result( Connection handle: 1 ) [14:06:30] CMySQLHandler::StoreResult() - Result was stored. [14:06:30] >> mysql_num_rows( Connection handle: 1 ) [14:06:30] CMySQLHandler::NumRows() - Returned 1 row(s) [14:06:30] >> mysql_fetch_row_format( Connection handle: 1 ) [14:06:30] CMySQLHandler::FetchRow() - Return: 4|411|23.3501|-8.2377|2.84427|52.4999 [14:06:30] >> mysql_free_result( Connection handle: 1 ) [14:06:30] CMySQLHandler::FreeResult() - Result was successfully free'd. |
Oh well, I feel stupid now. But now it works perfectly - thanks. And sorry OP for hijacking your thread and good luck with fixing your script.
|
new pName[24],Query[1000];
GetPlayerName(playerid,pName,24);
format(Query, sizeof(Query), "SELECT * FROM `Users` WHERE `Username` = '%s' ",pName);
mysql_query(Query);
mysql_store_result();
mysql_fetch_row_format(Query);
sscanf(Query, "e<p<|>s[32]>", PInfo[playerid]);
mysql_free_result();
new pName[24],Query[1000];
GetPlayerName(playerid,pName,24);
format(Query, sizeof(Query), "SELECT * FROM `Users` WHERE `Username` = '%s' ",pName);
mysql_query(Query);
mysql_store_result();
mysql_fetch_row_format(Query);
sscanf(Query, "e<p<|>>", PInfo[playerid]);
mysql_free_result();
That's because the "s" is the last parameter so is treated differently - add a space after it to change that.
|
new pName[24],Query[1000];
GetPlayerName(playerid,pName,24);
format(Query, sizeof(Query), "SELECT * FROM `Users` WHERE `Username` = '%s' ",pName);
mysql_query(Query);
mysql_store_result();
mysql_fetch_row_format(Query, "|");
sscanf(Query, "e<p<|>s[128]s[128]dddddfffddds[128]dddddddddddddddddddddddddddddddddddddddddddds[10]s[20]ddd>", PInfo[playerid]);
mysql_free_result();
Did you increase the size of the corresponding items in the enum? And that's not a minimal example like I asked for.
|