Extract Problem! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Extract Problem! (
/showthread.php?tid=590715)
Extract Problem! -
norton2 - 03.10.2015
Not extract information correctly form database!
Код HTML:
mysql_format(MySQLCon, query, sizeof(query), "SELECT * FROM `players` WHERE `user` = '%e' LIMIT 1", GetName(playerid));
mysql_tquery(MySQLCon, query, "OnPlayerLogin", "i", playerid);
Код HTML:
forward OnPlayerLogin(playerid);
public OnPlayerLogin(playerid)
{
// bla bla bla
pInfo[playerid][pFpunish] = cache_get_field_content_int(0, "Fpunish");
return 1;
}
DEBUG:
Код HTML:
printf("DEBUG: %d", pInfo[playerid][pFpunish]);
DEBUG: 1
pInfo[playerid][pFpunish] in database is 0, not 1.
Re: Extract Problem! -
norton2 - 03.10.2015
Bump!
Re: Extract Problem! -
x3378 - 03.10.2015
The error could be when she makes the query.
You do a query and calls the function with Tquery but never checked if the query return data.
Try.
PHP код:
forward OnPlayerLogin(playerid);
public OnPlayerLogin(playerid)
{
if(cache_num_rows() != 0) // This will check if the query return data.
{
pInfo[playerid][pFpunish] = cache_get_field_content_int(0, "Fpunish");
}
return 1;
}
Re: Extract Problem! -
norton2 - 03.10.2015
x3378 not work your version of script...
Re: Extract Problem! -
Thomaske - 03.10.2015
Try this:
PHP код:
mysql_format(MySQLCon, query, sizeof(query), "SELECT * FROM `players` WHERE `user` = '%d' LIMIT 1", GetName(playerid));
mysql_tquery(MySQLCon, query, "OnPlayerLogin", "i", playerid);
It should work now.
Re: Extract Problem! -
Lordzy - 03.10.2015
Is "pFpunish" a boolean type variable? If so, add "!!" before "cache_get_field_content_int" function.
pawn Код:
pInfo[playerid][pFpunish] = !!cache_get_field_content_int(0, "pFpunish", MySQLCon);
Re: Extract Problem! -
norton2 - 03.10.2015
"pFpunish" is not boolean variable.
Код HTML:
enum PlayerInfo
{
pFpunish, pWarns //.... etc
}
new pInfo[MAX_PLAYERS][PlayerInfo];
Re: Extract Problem! -
Lordzy - 03.10.2015
Debug cache_get_field_content_int(0, "pFpunish", MySQLCon); using printf function and see what's it's value. I've encountered something similar like this while using "BIT" datatype for my column, currently MySQL plugin don't support BIT datatype.
Re: Extract Problem! -
norton2 - 03.10.2015
The problem happens and other variables. It changes value...
Exemple:
"pInfo[playerid][pLeader]" the server -> pLeader = 8.
"pLeader" in database -> pLeader = 1.
Correctly is 1!
Re: Extract Problem! -
Vince - 03.10.2015
You may have a buffer overflow somewhere. Run crashtdetect. Also check the debug logs.