[Plugin] [REL]SAMP-MySQL v0.15 - SAMP 0.3 supported!!! corrected version uploaded...
#61

English :
Hello, I do not speak very much English, but what I can speak, say to him(her) that I have a complete server, but I it need to be able rise like to my host and to light it from the page or some conections at least, Thank you my msn elangel20043@hotmail.com, they Thanks you from before ^^

Espaсol :
Hola, no hablo mucho ingles, pero lo que puedo hablar, le digo que tengo un server completo, pero necesito saber como subirlo a mi host y prenderlo desde la pagina o algunas conecciones por lo menos, Gracias mi msn elangel20043@hotmail.com, les agradesco desde antes ^^
Reply
#62

hi all, i downloaded the files and none of then have the " samp_mysql_get_field(): ", i guess this function would be usefeull for me, what do i have to do, i am new in mysql and i am breaking my head with that...



thanks you all...
Reply
#63

The same problem. In a file a_sampmysql.inc there is no declaration samp_mysql_get_field ()
compiler does not find this function.

Moreover I have added in a_sampmysql.inc a line: native samp_mysql_get_field (field [], value []); expecting that it has been lost:
Код:
/* SA:MP MySQL Functions */

#if defined _sampmysql_included
	#endinput
#endif
#define _sampmysql_included
#pragma library lgw
native samp_mysql_connect(server[], user[], password[]);
native samp_mysql_select_db(db[]);
native samp_mysql_query(query[]);
native samp_mysql_store_result();
native samp_mysql_fetch_row(line[]);
native samp_mysql_get_field(field[], value[]); // <-- this added
native samp_mysql_num_rows();
native samp_mysql_num_fields();
native samp_mysql_ping();
native samp_mysql_real_escape_string(src[], dest[]);
native samp_mysql_free_result();
native samp_mysql_strtok(dest[], separator[], src[]);
native samp_mysql_close();
Then compilation is successful also a script is successfully connected to a database and makes query, but
on samp_mysql_get_field the server crashes.
How to solve this?

(sorry by my bad english)
Reply
#64

Dont use samp_mysql_free_result();
Reply
#65

Quote:
Originally Posted by Bardokas
Dont use samp_mysql_free_result();
Doesn't help

My code:
Код:
public OnGameModeInit()
{
new res = samp_mysql_connect("localhost", ####, ####);
res = samp_mysql_select_db("modbase");
printf("%d",res);
new str[128];
format(str, 128, "SELECT * FROM users WHERE nick='%s'", "vovo4ka");
printf(str);
samp_mysql_query(str);
samp_mysql_store_result();
new line[1024];
new field[128];
printf("%d ", samp_mysql_num_rows());
samp_mysql_fetch_row(line);
samp_mysql_get_field("level", field);
printf("%s ", field);
}
Output screen:

and crash
Reply
#66

Try format(str, 128, "SELECT level FROM users WHERE nick='%s'", "vovo4ka");
Dont use * instead fields name. Maybe it will help. And level isnt null?
Reply
#67

always FETCH ROW before you GET FIELD. Else server crashes
Reply
#68

Quote:
Originally Posted by [M2S
moe ]
always FETCH ROW before you GET FIELD. Else server crashes
He does it:
Quote:

samp_mysql_fetch_row(line);
samp_mysql_get_field("level", field);

Reply
#69

Quote:
Originally Posted by Bardokas
Try format(str, 128, "SELECT level FROM users WHERE nick='%s'", "vovo4ka");
Dont use * instead fields name. Maybe it will help. And level isnt null?
level not NULL

I think a problem in a_sampmysql.inc
Function samp_mysql_get_field is not declared. Somebody can show yours a_sampmysql.inc where samp_mysql_get_field works correctly?
Reply
#70

Quote:
Originally Posted by Bardokas
Dont use * instead fields name. Maybe it will help.
It's helped!
Also I correctly modify the a_sampmysql.inc where have been skipped navite samp_mysql_get_field (field [], value []);
Thanks!

But there is a new: if to use samp_mysql_get_field with different field names that it the server crash too

Код:
public LoadUser(userid,playerid)
{
new line[1024];
new field[32];
new tmp;
format(line, 128, "SELECT money, level, specID FROM users WHERE id='%d'", userid);
printf(line);
samp_mysql_query(line);
samp_mysql_store_result();
new rows=samp_mysql_num_rows();
if (rows==1)
 {
 samp_mysql_fetch_row(line);


 samp_mysql_get_field("money",field);
 tmp=strval(field);
 PLAYERS[playerid][money]=tmp;
 PLAYERS[playerid][moneytmp]=-1;
 SetPlayerMoney(playerid,tmp);


 samp_mysql_get_field("level",field);
 tmp=strval(field);
 PLAYERS[playerid][lev]=tmp;


 samp_mysql_get_field("specID",field);
 tmp=strval(field);
 PLAYERS[playerid][specid]=tmp;
 }
Reply
#71

Quote:
Originally Posted by Syg
Hi,

Concerning the memory leak, I discovered it myself with the first version of this plugin and corrected it.
That memory leak is a common one, you allocate memory in a function and return the allocated memory. It's up to the caller to free it. It's very easy to forget to free this memory (that cannot be freed in the called function).

And that's exactly what the pcCreateAndFillStringFromCell function does (szDest = new char[nLen+1].
This means that each time you call this function you must call delete on the returned pointer :

Example :
static cell AMX_NATIVE_CALL n_samp_mysql_query( AMX* amx, cell* params )
{
int retval;
const char *query;
query=pcCreateAndFillStringFromCell(amx, params[1]);
retval=mysql_query(&connexion, query); //mysql_query returns 0 if success
delete query; // <--- FREE MEMORY ALLOCATED BY pcCreateAndFillStringFromCell AFTER IT IS USED
if(!retval)
{
return 1;
}
else
{
logprintf("Error in mysql_query: %s",mysql_error(&connexion));
return 0;
}
}

And for the samp_mysql_strtok function uses the pcCreateAndFillStringFromCell function. So it is normal that Bardokas example uses so much memory.

++
Syg
I will please give mefor your pluginof that fix bug
Reply
#72

I'm making an admin script with SA MP MySQL plugin. The old version (v0.1), didn't work good (It crashed a lot), i thought the new version (v0.13) works better, but it isn't the best too. With the old version i could reload my script, but with the new version i can't do that. Is anybody know about a new plugin version or libmysql.dll, which working stable? What libmysql.dll is good? I copied that from mysql server folder next to samp-server.exe.
Example:
- I use this to load admin commands from database, and when i reload my fs it crashes
Код:
public OnFilterScriptInit() {
	#if defined SQL_HOST
		print("+------------------------+");
		print("|  mySQL Admin Script  |");
		print("|      by      |");
		print("|    [HuN]Peti    |");
		print("+------------------------+");
		samp_mysql_connect(SQL_HOST, SQL_USER, SQL_PASS);
		if(samp_mysql_ping()==0) {
			printf("[SQLAdmin] Connection to database is alive!");
		} else {
			printf("[SQLAdmin] Can't connect to database with host: %s", SQL_HOST);
		}
		samp_mysql_select_db(SQL_DB);
		NullAllVariables();
		printf("[SQLAdmin] Loading Admin Commands' accesses...");     <==
		LoadCmdAccesses();
		printf("[SQLAdmin] Creating Timers...");
		SetTimer("CheckPings", 5000, true);
		printf("[SQLAdmin] Creating Menus...");
		CreateMenus();
		printf("[SQLAdmin] Loading Configs...");
		LoadConfigs();
		printf("[SQLAdmin] Loading Forbidden Names...");
		LoadForbidNames();
	#endif
}
new CmdAccesses[MAX_CMDS][cmdEnum];
stock LoadCmdAccesses() {
	new line[256], field[128], i=0;
	CheckSQLConnection();
	samp_mysql_query("SELECT * FROM cmds"); // Fields: Level, CMD
	samp_mysql_store_result();
	while(samp_mysql_fetch_row(line)) {
		samp_mysql_strtok(field, "|", line);
		CmdAccesses[i][LvLNeed] = strval(field);
		samp_mysql_strtok(field, "|", "");
		format(CmdAccesses[i][CMD], 256, field);
		i++;
	}
	samp_mysql_free_result();
	return false;
}
Please, help me!

Sorry, for my bad english, but i'm from Hungary .
Reply
#73

Dont use samp_mysql_free_result();
Reply
#74

Quote:
Originally Posted by Bardokas
Dont use samp_mysql_free_result();
Thanks, it works! But when i doing a query, the memory usage is growing.
No?
After all queries do i delete that command?
Reply
#75

Then no more rows left, samp_mysql_fetch_row does mysql_free_result.
You need use samp_mysql_free_result(), then get only one row.
Reply
#76

The situation is increasingly better. Before this, i used samp_mysql_free_result() after all queries. I do not have to make this according to these. Thanks.
Reply
#77

n00bie questions:
What's the role of the MySQL plugin on a server?
Do you need to download the MySQL program from the MySQL Site to use the plugin?


Reply
#78

Hi, again!
I had problem with samp_mysql_free_result(). But now, i've got again...
My memory usage is growing, and then my server crashes...

When I start the server, it uses 8 000 kb, and 1-2 hour later it's using 40 000 - 50 000 kb...
What can i do?
Please, help!
Reply
#79

i use gamemode Modertopia-Role Play,but the memory leak of Mem Usage be down sporadically but VMSize increase all the time (when walk,used command) but if do not anything MemUsage and VMSize be motionless.

Screen Shot:

Reply
#80

Quote:
Originally Posted by [DSK
Lazlow ]
n00bie questions:
What's the role of the MySQL plugin on a server?
Do you need to download the MySQL program from the MySQL Site to use the plugin?
Anybody ?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)