gstyle to blueg - 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: gstyle to blueg (
/showthread.php?tid=583468)
gstyle to blueg -
Erno. - 28.07.2015
Hi guys I'm updeteing from gstyle to blueg and I have one question in gstyle there's a function
Код:
mysql_free_result( );
But in blueg I can't find anything something like that, help please
Re: gstyle to blueg -
PaulDinam - 28.07.2015
That's because you have to use the cache feature in BlueG's plugin.
https://sampforum.blast.hk/showthread.php?tid=337810
Re: gstyle to blueg -
Erno. - 28.07.2015
Could you show one example in my situation?
Re: gstyle to blueg -
PaulDinam - 28.07.2015
Reading a player:
pawn Код:
public OnPlayerConnect(playerid)
{
mysql_format(dbHandle, query, sizeof(query), "SELECT * FROM `users` WHERE `username` = '%s' LIMIT 1", Player[playerid][Name]);
mysql_tquery(dbHandle, query, "OnPlayerLoad", "i", playerid);
}
forward OnPlayerLoad(playerid);
public OnPlayerLoad(playerid)
{
// cache_num_rows() returns whether there's been a result or not so you can do the following:
if(cache_num_rows()) {
// User exists
// cache_get_field_content_int(0, "columnname"); = retrieves an INT value from the database
// cache_get_field_content_float(0, "columnname"); = retrieves a FLOAT value from the database
// cache_get_field_content(0, "columnname", destinationvar, dbHandle, maxsize); = retrieves a STRING from the database
} else {
// No user found in the database
}
return 1;
}
Getting multiple data rows at once:
pawn Код:
public OnGameModeInit()
{
mysql_format(dbHandle, query, sizeof(query), "SELECT * FROM `vehicles` LIMIT %d", MAX_DYNAMIC_VEHS);
mysql_tquery(dbHandle, query, "OnObjectsLoad");
}
forward OnObjectsLoad();
public OnObjectsLoad()
{
// cache_num_rows() returns whether there's been a result or not so you can do the following:
// Now we can run through a loop to retrieve all rows database
for(new i = 0; i < cache_num_rows(); i++)
{
// Make sure you use the 'i' variable as it always incerements in the loop in order to read from the rows
// User exists
// cache_get_field_content_int(i, "columnname"); = retrieves an INT value from the database
// cache_get_field_content_float(i, "columnname"); = retrieves a FLOAT value from the database
// cache_get_field_content(i, "columnname", destinationvar, dbHandle, maxsize); = retrieves a STRING from the database
}
return 1;
}
Re: gstyle to blueg -
sjames - 28.07.2015
You don't need mysql_free_result( ); in BlueG.
Re: gstyle to blueg -
Erno. - 28.07.2015
@PaulDinam Thanks for help but I asked for sample of my situation mysql_free_result( ); how I should replace this one in blueG with cache?
Re: gstyle to blueg -
sjames - 28.07.2015
Quote:
Originally Posted by sjames
You don't need mysql_free_result( ); in BlueG.
|
Read this? You dont need to replace it with anything.
Re: gstyle to blueg -
Erno. - 28.07.2015
Quote:
Originally Posted by sjames
Read this? You dont need to replace it with anything.
|
Thanks it worked, one more question how about this mysql_store_result( ); should I delete this too?
Re: gstyle to blueg -
PaulDinam - 28.07.2015
You don't need it, cache does the work.