01.06.2015, 08:52
Hey there.
This code is really pissing me off, and I keep getting wrong result no matter what I do.
I'm trying to load data from the database and everything loads fine, my MySQL logs says it's loaded. But when I try to display the data in-game, through strings, some of the information is incorrect.
How it looks in-game:

This is what it's supposed to display:

And this is the database structure:

Here's my code:
And here is my MySQL log:
What am I doing wrong? I'm using StrickenKid's plugin.
Please help me out here, I'll do anything in return.
Thanks a lot in advance.
This code is really pissing me off, and I keep getting wrong result no matter what I do.
I'm trying to load data from the database and everything loads fine, my MySQL logs says it's loaded. But when I try to display the data in-game, through strings, some of the information is incorrect.
How it looks in-game:

This is what it's supposed to display:

And this is the database structure:

Here's my code:
Код:
// Enums
enum PlayerData
{
pID,
pName[512],
pPassword[512],
pAdminLevel,
pMoney,
pSkin,
Float:pHealth,
Float:pArmour
};
new Player[MAX_PLAYERS][PlayerData];
// Loading from database
stock LoadDatabase(playerid)
{
new query[512], health[64], armour[64];
format(query, sizeof(query), "SELECT * FROM `samp_users` WHERE `pName` = '%s' LIMIT 1", GetName(playerid));
mysql_query(query);
mysql_store_result();
if(mysql_fetch_row(query))
{
mysql_fetch_field("pID", Player[playerid][pID]);
mysql_fetch_field("pName", Player[playerid][pName]);
mysql_fetch_field("pPassword", Player[playerid][pPassword]);
mysql_fetch_field("pAdminLevel", Player[playerid][pAdminLevel]);
mysql_fetch_field("pMoney", Player[playerid][pMoney]);
mysql_fetch_field("pSkin", Player[playerid][pSkin]);
mysql_fetch_field("pHealth", health); Player[playerid][pHealth] = floatstr(health);
mysql_fetch_field("pArmour", armour); Player[playerid][pArmour] = floatstr(armour);
}
mysql_free_result();
return 1;
}
// Displaying the data
stock DebugSQL(playerid)
{
new string[512];
format(string, sizeof(string), "[DEBUG] ID: %i, Name: %s, Admin: %s, Money: %s, Skin: %s, Health: %f, Armour: %f",
Player[playerid][pID],
Player[playerid][pName],
Player[playerid][pAdminLevel],
Player[playerid][pMoney],
Player[playerid][pSkin],
Player[playerid][pHealth],
Player[playerid][pArmour]);
SendClientMessage(playerid, COLOR_WHITE, string);
return 1;
}
Код:
[Mon Jun 01 10:46:10 2015] ------------------------- [Mon Jun 01 10:46:10 2015] Logging Started [Mon Jun 01 10:46:10 2015] ------------------------- [Mon Jun 01 10:46:10 2015] Function: mysql_init executed with result: "0". [Mon Jun 01 10:46:11 2015] Connected (0) to root @ 127.0.0.1 via TCP/IP. [Mon Jun 01 10:46:11 2015] MySQL Server Version 5.6.24. [Mon Jun 01 10:46:37 2015] Function: mysql_query executed: "SELECT * FROM `samp_users` WHERE `pName` = 'Michael_Puglisi' LIMIT 1" with result: "0". [Mon Jun 01 10:46:37 2015] Function: mysql_store_result executed with result: "1" [Mon Jun 01 10:46:37 2015] Function: mysql_fetch_row executed with result: "12|Michael_Puglisi|344907E89B981CAF221D05F597EB57A6AF408F15F4DD7895BBD1B96A2938EC24A7DCF23ACB94ECE0B6D7B0640358BC56BDB448194B9305311AFF038A834A079F|0|50056|29|3332.153564 -481.794494 3332.153564|99|10|". [Mon Jun 01 10:46:37 2015] Function: mysql_fetch_field executed. [Mon Jun 01 10:46:37 2015] Function: mysql_fetch_field executed. [Mon Jun 01 10:46:37 2015] Function: mysql_fetch_field executed. [Mon Jun 01 10:46:37 2015] Function: mysql_fetch_field executed. [Mon Jun 01 10:46:37 2015] Function: mysql_fetch_field executed. [Mon Jun 01 10:46:37 2015] Function: mysql_fetch_field executed. [Mon Jun 01 10:46:37 2015] Function: mysql_fetch_field executed. [Mon Jun 01 10:46:37 2015] Function: mysql_fetch_field executed. [Mon Jun 01 10:46:37 2015] Function: mysql_free_result executed. [Mon Jun 01 10:46:37 2015] Function: mysql_free_result executed.
Please help me out here, I'll do anything in return.
Thanks a lot in advance.



