Raised This Month: $ Target: $400
 0% 

Help SQLITE


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kokaa
New Member
Join Date: Jan 2015
Old 02-01-2015 , 12:17   Help SQLITE
Reply With Quote #1

I can stop logging me

LOG:

HTML Code:
L 02/02/2015 - 14:08:23: [SQLITE] Invalid column: 6
L 02/02/2015 - 14:08:23: [AMXX] Displaying debug trace (plugin "Homi.amxx")
L 02/02/2015 - 14:08:23: [AMXX] Run time error 10: native error (native "SQL_ReadResult")
L 02/02/2015 - 14:08:23: [AMXX]    [0] Homi.sma::DataHandler (line 846)
CODE:

Code:
public guardar_datos( id ) {
	new szQuery[ 10000 ], iData[ 2 ];
	
	iData[ 0 ] = id;
	iData[ 1 ] = GUARDAR_DATOS;
	
	formatex( szQuery, charsmax( szQuery ), "UPDATE %s SET Experiencia='%d', Diamantes='%d', Expamuleto='%d' WHERE id='%d'", 
szTable, g_nivel[ id ], g_diamantes[ id ], g_experiencia_amuleto[ id ], g_id[ id ] );
	SQL_ThreadQuery( g_hTuple, "DataHandler", szQuery, iData, 2 );
}

public DataHandler( failstate, Handle:Query, error[ ], error2, data[ ], datasize, Float:time ) {
	static id;
	id = data[ 0 ];
	
	if( !is_user_connected( id ) )
		return;

	switch( failstate ) {
		case TQUERY_CONNECT_FAILED: {
			log_to_file( "SQL_LOG_TQ.txt", "Error en la conexion al MySQL [%i]: %s", error2, error );
			return;
		}
		case TQUERY_QUERY_FAILED:
			log_to_file( "SQL_LOG_TQ.txt", "Error en la consulta al MySQL [%i]: %s", error2, error );
	}
	
	switch( data[ 1 ] ) {
		case REGISTRAR_CUENTA: {
			if( failstate < TQUERY_SUCCESS ) {
				if( containi( error, "Usuario" ) != -1 )
					ChatColor( id, "!g%s - !yEl usuario ya existe -.-!", Prefix )

				else if( containi( error, "Pj" ) != -1 )
					ChatColor( id, "!g%s - !yEl usuario ya esta conectado", Prefix );
				else
					ChatColor( id, "!g%s - !yHubo un error, porfavor crea la cuenta de nuevo", Prefix )
				
				client_cmd( id, "spk buttons/button10.wav" );
				
				show_login_menu( id );
			}
			else {
				ChatColor( id, "!g%s - !yCuenta creada con exito! !gBravo!", Prefix )
                                g_cuentas_creadas++				
                                set_task( 2.0, "Huddraw", id + 5, .flags = "b" );

				new szQuery[ 128 ], iData[ 2 ];
				
				iData[ 0 ] = id;
				iData[ 1 ] = CARGAR_DATOS;
				
				formatex( szQuery, charsmax( szQuery ), "SELECT id FROM %s WHERE Usuario=^"%s^"", szTable, g_usuario[ id ] );
				SQL_ThreadQuery( g_hTuple, "DataHandler", szQuery, iData, 2 );
			}
			
		}
		case LOGUEAR_CUENTA: {
			if( SQL_NumResults( Query ) ) {
				g_id[ id ] = SQL_ReadResult( Query, 0 );
				SQL_ReadResult( Query, 3, g_playername[ id ], charsmax( g_playername[ ] ) );					
				
				// Cargamos datos
				g_nivel[ id ] = SQL_ReadResult( Query, 4 );
				g_diamantes[ id ] = SQL_ReadResult( Query, 5 );					
				g_experiencia_amuleto[ id ] = SQL_ReadResult( Query, 6 );	

				func_login_success( id );
			}
			else {
				ChatColor( id, "!g%s - !yUsuario o password incorrecta -.-!", Prefix )
				client_cmd( id, "spk buttons/button10.wav" );
				
				show_login_menu( id );
			}
		}
		case CARGAR_DATOS: {
			if( SQL_NumResults( Query ) ) {
				g_id[ id ] = SQL_ReadResult( Query, 0 );
				
				// Ponemos la exp en 0 para el nuevo usuario.
				g_nivel[ id ] = 1;
				g_diamantes[ id ] = 0;
                                g_experiencia_amuleto[ id ] = 0;

				func_login_success( id );
			}
			else {
				ChatColor( id, "!g%s - !yHubo un error al cargar los datos, intentalo otra vez -.-!", Prefix )
				show_login_menu( id );
			}
		}
		case GUARDAR_DATOS: {
			if( failstate < TQUERY_SUCCESS )
				console_print( id, "%s Error en el guardado de datos.", szPrefix );
			
			else
				console_print( id, "%s Datos guardados.", szPrefix );
		}
	}
}
BASE:

Quote:
CREATE TABLE "cuentas" ("id" INTEGER PRIMARY KEY NOT NULL ,"Usuario" VARCHAR NOT NULL ,"Password" VARCHAR NOT NULL ,"Pj" VARCHAR NOT NULL ,"Experiencia" INTEGER DEFAULT (0) ,"Diamantes" INTEGER DEFAULT (0) , "Expamuleto" INTEGER DEFAULT 0)
help¿?
Kokaa is offline
sirerick
Senior Member
Join Date: Jul 2012
Location: Venezuela
Old 02-01-2015 , 22:18   Re: Help SQLITE
Reply With Quote #2

¿You modified the database?

PHP Code:
new szQuery10000 ]

----->

new szQuery128 ]

formatexszQuerycharsmaxszQuery ), "SELECT id FROM %s WHERE Usuario=^"%s^""szTableg_usuarioid ] );

---->

formatexszQuerycharsmaxszQuery ), "SELECT id, Experiencia, Diamantes, Expamuleto FROM %s WHERE Usuario=^"%s^""szTableg_usuarioid ] ); 
sirerick is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:20.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode