Returning formatted text -
speed258 - 07.02.2014
Guys I'am out of ideas and anyway is possible using R35 mysql plungin to return formatted text?
EX:
Код:
mysql_format(dbhandle, querys, sizeof(querys), "SELECT * FROM `table` WHERE Winner = '1');
mysql_tquery(dbhandle, querys, "LoadWinner", "", );
public LoadWinner()
{
new msg[50];
new test[50];
//some code
and here
return format(test, 50, "%s", msg);
}
And my code work or not?
Re: Returning formatted text -
PowerPC603 - 07.02.2014
First of all, a public function cannot return strings.
Second, you're trying to return a function instead of a string (format doesn't return anything, so you'll be returning nothing as well).
Third, that public function is a callback which was called by the MySQL plugin.
You would return a string to that plugin, not to your script.
The only thing you should return in a plugin-callback, is the value 1.
This value will notify the plugin to flush the data in the cache that was put there as a result of the query.
Returning something else would cause memory leaks in the plugin as the data isn't flushed.
Re: Returning formatted text -
FireCat - 07.02.2014
As the opposite of Java, C does not allow the 'format' function to be returned as a value in public functions.
The thing you could do would be:
- Make that public function a stock
- Format the string as you are using a normal function.
- Then do "return msg;"
pawn Код:
stock LoadWinner()
{
new msg[50];
new test[50];
//some code
//and here
format(test, 50, "%s", msg);
return msg;
}
PS: That code makes no sense.
As the 'msg' variable is NULL, and you're formatting a string with a NULL value.