Problem: mysql command that causes crash.
#1

Hi,
I happen to have the following problem, which causes crash when multiple users are connected to the server, but when no one except me, use the command works.


Command:

Код:
CMD:vermiembrosfacc(playerid, params[])
{
    if(pInfo[playerid][jAdminXLEP] <= 4) return SCM(playerid, COLOR_GRAD, "Necesitas ser administrador nivel 5 para usar este comando.");
    if(sscanf(params, "i", params[0])) return SCM(playerid, COLOR_LABELS, "Modo de uso: /vermiembrosfacc [ID facciуn]"), SCM(playerid, -1, "{FFFF00}[ID Facciones] {A6F06F}1: {FFFFFF}ASR {A6F06F}2: {FFFFFF}CMA {A6F06F}3: {FFFFFF}CIH {A6F06F}4: {FFFFFF}SAEM");
    if(params[0] < 1 || params[0] > 4) return SCM(playerid, COLOR_GRAD, "Sуlo es vбlida la ID 1 y 4, colocar sуlo /vermiembrosfacc para saber las IDґs.");
    if(params[0] == 1) mysql_tquery(mysql, "SELECT * FROM `usuarios`", "MiembrosFaccion", "ii", 1, playerid);
    if(params[0] == 2) mysql_tquery(mysql, "SELECT * FROM `usuarios`", "MiembrosFaccion", "ii", 2, playerid);
    if(params[0] == 3) mysql_tquery(mysql, "SELECT * FROM `usuarios`", "MiembrosFaccion", "ii", 3, playerid);
	if(params[0] == 4) mysql_tquery(mysql, "SELECT * FROM `usuarios`", "MiembrosFaccion", "ii", 4, playerid);
	PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
	return 1;
}
Function " MiembrosFaccion ".

Код:
funcion:MiembrosFaccion(id, playerid)
{
	if(id == 1)
	{
	    if(cache_num_rows() != 0) {
     		new faccionid, rango, cadena[64], cantidad = 0, username[MAX_PLAYER_NAME];
		   	for(new i = 0; i < cache_num_rows(); i++) {
		   	    cache_get_field_content(i, "Nombre", username, mysql, 24);
      			faccionid = cache_get_field_content_int(i, "Faccion");
		        rango = cache_get_field_content_int(i, "Rango");
          		if(faccionid == ASR) {
		           	format(cadena, sizeof(cadena), "{FFFF00}[Facciуn ASR] {FFFFFF}%s Rango: [%i/8]", username, rango);
		            SCM(playerid, -1, cadena);
		            cantidad++;
		        }
	 	    }
	 	    if(cantidad == 0) SCM(playerid, COLOR_GRAD, "No hay miembros en la facciуn.");
		}
	}
 	if(id == 2)
	{
	    if(cache_num_rows() != 0) {
     		new faccionid, rango, cadena[64], cantidad = 0, username[MAX_PLAYER_NAME];
		   	for(new i = 0; i < cache_num_rows(); i++) {
		   	    cache_get_field_content(i, "Nombre", username, mysql, 24);
      			faccionid = cache_get_field_content_int(i, "Faccion");
		        rango = cache_get_field_content_int(i, "Rango");
          		if(faccionid == CMA) {
		           	format(cadena, sizeof(cadena), "{FFFF00}[Facciуn CMA] {FFFFFF}%s Rango: [%i/8]", username, rango);
		            SCM(playerid, -1, cadena);
		            cantidad++;
		        }
	 	    }
	 	    if(cantidad == 0) SCM(playerid, COLOR_GRAD, "No hay miembros en la facciуn.");
		}
	}
 	if(id == 3)
	{
	    if(cache_num_rows() != 0) {
     		new faccionid, rango, cadena[64], cantidad = 0, username[MAX_PLAYER_NAME];
		   	for(new i = 0; i < cache_num_rows(); i++) {
		   	    cache_get_field_content(i, "Nombre", username, mysql, 24);
      			faccionid = cache_get_field_content_int(i, "Faccion");
		        rango = cache_get_field_content_int(i, "Rango");
          		if(faccionid == CIH) {
		           	format(cadena, sizeof(cadena), "{FFFF00}[Facciуn CIH] {FFFFFF}%s Rango: [%i/8]", username, rango);
		            SCM(playerid, -1, cadena);
		            cantidad++;
		        }
	 	    }
	 	    if(cantidad == 0) SCM(playerid, COLOR_GRAD, "No hay miembros en la facciуn.");
		}
	}
 	if(id == 4)
	{
	    if(cache_num_rows() != 0) {
     		new faccionid, rango, cadena[64], cantidad = 0, username[MAX_PLAYER_NAME];
		   	for(new i = 0; i < cache_num_rows(); i++) {
		   	    cache_get_field_content(i, "Nombre", username, mysql, 24);
      			faccionid = cache_get_field_content_int(i, "Faccion");
		        rango = cache_get_field_content_int(i, "Rango");
          		if(faccionid == SAEM) {
		           	format(cadena, sizeof(cadena), "{FFFF00}[Facciуn SAEM] {FFFFFF}%s Rango: [%i/8]", username, rango);
		            SCM(playerid, -1, cadena);
		            cantidad++;
		        }
	 	    }
	 	    if(cantidad == 0) SCM(playerid, COLOR_GRAD, "No hay miembros en la facciуn.");
		}
	}
	return 1;
}
Clarify, in mysql log did not throw any error, but the log server I get the following:

Код:
[01:11:25] [debug] Server crashed due to an unknown error
[01:11:25] [debug] Native backtrace:
[01:11:25] [debug] #0 f7448e8b in _ZN10StackTraceC1EPv () from plugins/crashdetect.so
[01:11:25] [debug] #1 f7441bcf in _ZN11CrashDetect20PrintNativeBacktraceERSoPv () from plugins/crashdetect.so
[01:11:25] [debug] #2 f7442dbc in _ZN11CrashDetect20PrintNativeBacktraceEPv () from plugins/crashdetect.so
[01:11:25] [debug] #3 f7443226 in _ZN11CrashDetect11OnExceptionEPv () from plugins/crashdetect.so
[01:11:25] [debug] #4 f7448adc in ?? () from plugins/crashdetect.so
[01:11:25] [debug] #5 f772b410 in ?? ()
[01:11:25] [debug] #6 f7585bf5 in ?? () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
[01:11:25] [debug] #7 f70eaed2 in _ZN11CMySQLQuery11StoreResultEP8st_mysqlP12st_mysql_res () from plugins/mysql_static.so
[01:11:25] [debug] #8 f70eb363 in _ZN11CMySQLQuery7ExecuteEP8st_mysql () from plugins/mysql_static.so
[01:11:25] [debug] #9 f70e39c6 in _ZN16CMySQLConnection14ProcessQueriesEv () from plugins/mysql_static.so
[01:11:25] [debug] #10 f70e44ba in _ZN5boost6detail11thread_dataINS_3_bi6bind_tIvNS_4_mfi3mf0Iv16CMySQLConnectionEENS2_5list1INS2_5valueIPS6_EEEEEEE3runEv () from plugins/mysql_static.so
[01:11:25] [debug] #11 f718f71d in ?? () from plugins/mysql_static.so
[01:11:25] [debug] #12 f7705c39 in ?? () from /lib/i386-linux-gnu/i686/cmov/libpthread.so.0
[01:11:25] [debug] #13 f754278e in clone () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
Using the 64-bit mysql plugin "mysql_static.so"

What I try to do is to search all registered users have the variable selected faction and displayed to the user that he consulted.

Or would you recommend another way to function ?, you for your attention.
Reply
#2

Try better version

pawn Код:
CMD:vermiembrosfacc(playerid, params[])
{
    if(pInfo[playerid][jAdminXLEP] <= 4) return SCM(playerid, COLOR_GRAD, "Necesitas ser administrador nivel 5 para usar este comando.");
    if(sscanf(params, "i", params[0])) return SCM(playerid, COLOR_LABELS, "Modo de uso: /vermiembrosfacc [ID facciуn]"), SCM(playerid, -1, "{FFFF00}[ID Facciones] {A6F06F}1: {FFFFFF}ASR {A6F06F}2: {FFFFFF}CMA {A6F06F}3: {FFFFFF}CIH {A6F06F}4: {FFFFFF}SAEM");
    if(params[0] < 1 || params[0] > 4) return SCM(playerid, COLOR_GRAD, "Sуlo es vбlida la ID 1 y 4, colocar sуlo /vermiembrosfacc para saber las IDґs.");
    mysql_tquery(mysql, "SELECT * FROM `usuarios`", "MiembrosFaccion", "ii", params[0], playerid);
    PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
    return 1;
}

funcion:MiembrosFaccion(id, playerid)
{
    new rows = cache_num_rows();
    if(rows != 0)
    {
        new i, faccionid, rango, cadena[64], username[MAX_PLAYER_NAME];
        for(i = 0; i < rows; i++)
        {
            cache_get_field_content(i, "Nombre", username, mysql, MAX_PLAYER_NAME);
            faccionid = cache_get_field_content_int(i, "Faccion");
            rango = cache_get_field_content_int(i, "Rango");
            if(id == 1) format(cadena, sizeof(cadena), "{FFFF00}[Facciуn ASR] {FFFFFF}%s Rango: [%i/8]", username, rango);
            else if(id == 2) format(cadena, sizeof(cadena), "{FFFF00}[Facciуn CMA] {FFFFFF}%s Rango: [%i/8]", username, rango);
            else if(id == 3) format(cadena, sizeof(cadena), "{FFFF00}[Facciуn CIH] {FFFFFF}%s Rango: [%i/8]", username, rango);
            else format(cadena, sizeof(cadena), "{FFFF00}[Facciуn SAEM] {FFFFFF}%s Rango: [%i/8]", username, rango);

            SCM(playerid, -1, cadena);
        }
        if(i == 0) SCM(playerid, COLOR_GRAD, "No hay miembros en la facciуn.");
    }
    return 1;
}
Reply
#3

Well, I had to modify some code that contained some errors.

Follow out the crash when using command when there are 4 people online works well, but when more than 8 people jump so to speak crash.

Код:
CMD:vermiembrosfacc(playerid, params[])
{
	if(pInfo[playerid][jAdminXLEP] <= 4) return SCM(playerid, COLOR_GRAD, "Necesitas ser administrador nivel 5 para usar este comando.");
    if(sscanf(params, "i", params[0])) return SCM(playerid, COLOR_LABELS, "Modo de uso: /vermiembrosfacc [ID facciуn]"), SCM(playerid, -1, "{FFFF00}[ID Facciones] {A6F06F}1: {FFFFFF}ASR {A6F06F}2: {FFFFFF}CMA {A6F06F}3: {FFFFFF}CIH {A6F06F}4: {FFFFFF}SAEM");
    if(params[0] < 1 || params[0] > 4) return SCM(playerid, COLOR_GRAD, "Sуlo es vбlida la ID 1 y 4, colocar sуlo /vermiembrosfacc para saber las IDґs.");
    mysql_tquery(mysql, "SELECT * FROM `usuarios`", "MiembrosFaccion", "ii", params[0], playerid);
	PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
	DesmantelarCMD(playerid, "/vermiembrosfacc");
	return 1;
}

funcion:MiembrosFaccion(id, playerid)
{
	new rows = cache_num_rows();
	if(rows != 0)
	{
		new i, rango, faccionid, cadena[64], username[MAX_PLAYER_NAME];
		for(i = 0; i < rows; i++)
		{
			faccionid = cache_get_field_content_int(i, "Faccion");
			rango = cache_get_field_content_int(i, "Rango");
			if(faccionid == ASR && id == 1) {
				cache_get_field_content(i, "Nombre", username, mysql, MAX_PLAYER_NAME);
				format(cadena, sizeof(cadena), "{FFFF00}[Facciуn ASR] {FFFFFF}%s Rango: [%i/8]", username, rango);
				SCM(playerid, -1, cadena);
			}
			if(faccionid == CMA && id == 2) {
				cache_get_field_content(i, "Nombre", username, mysql, MAX_PLAYER_NAME);
				format(cadena, sizeof(cadena), "{FFFF00}[Facciуn CMA] {FFFFFF}%s Rango: [%i/8]", username, rango);
				SCM(playerid, -1, cadena);
			}
			if(faccionid == CIH && id == 3) {
			    cache_get_field_content(i, "Nombre", username, mysql, MAX_PLAYER_NAME);
				format(cadena, sizeof(cadena), "{FFFF00}[Facciуn CIH] {FFFFFF}%s Rango: [%i/8]", username, rango);
				SCM(playerid, -1, cadena);
			}
			if(faccionid == SAEM && id == 4) {
			    cache_get_field_content(i, "Nombre", username, mysql, MAX_PLAYER_NAME);
				format(cadena, sizeof(cadena), "{FFFF00}[Facciуn SAEM] {FFFFFF}%s Rango: [%i/8]", username, rango);
				SCM(playerid, -1, cadena);
			}
		}
		if(i == 0) SCM(playerid, COLOR_GRAD, "No hay miembros en la facciуn.");
	}
	return 1;
}
Crash:

Код:
[02:15:20] [debug] Server crashed due to an unknown error
[02:15:20] [debug] Native backtrace:
[02:15:20] [debug] #0 f74d6e8b in _ZN10StackTraceC1EPv () from plugins/crashdetect.so
[02:15:20] [debug] #1 f74cfbcf in _ZN11CrashDetect20PrintNativeBacktraceERSoPv () from plugins/crashdetect.so
[02:15:20] [debug] #2 f74d0dbc in _ZN11CrashDetect20PrintNativeBacktraceEPv () from plugins/crashdetect.so
[02:15:20] [debug] #3 f74d1226 in _ZN11CrashDetect11OnExceptionEPv () from plugins/crashdetect.so
[02:15:20] [debug] #4 f74d6adc in ?? () from plugins/crashdetect.so
[02:15:20] [debug] #5 f77b9410 in ?? ()
[02:15:20] [debug] #6 f7613bf9 in ?? () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
[02:15:20] [debug] #7 f7178ed2 in _ZN11CMySQLQuery11StoreResultEP8st_mysqlP12st_mysql_res () from plugins/mysql_static.so
[02:15:20] [debug] #8 f7179363 in _ZN11CMySQLQuery7ExecuteEP8st_mysql () from plugins/mysql_static.so
[02:15:20] [debug] #9 f71719c6 in _ZN16CMySQLConnection14ProcessQueriesEv () from plugins/mysql_static.so
[02:15:20] [debug] #10 f71724ba in _ZN5boost6detail11thread_dataINS_3_bi6bind_tIvNS_4_mfi3mf0Iv16CMySQLConnectionEENS2_5list1INS2_5valueIPS6_EEEEEEE3runEv () from plugins/mysql_static.so
[02:15:20] [debug] #11 f721d71d in ?? () from plugins/mysql_static.so
[02:15:20] [debug] #12 f7793c39 in ?? () from /lib/i386-linux-gnu/i686/cmov/libpthread.so.0
[02:15:20] [debug] #13 f75d078e in clone () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
R39-3 use the 64-bit version (mysql_static.so)
Help
Reply
#4

bump
Reply
#5

Could you share the table structure (fields/columns + their datatype) of 'usuarios'? Also how many rows does this table have?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)