Problema con carga de datos hola soy nuevo, tengo un problema, veran, a mi me guarda bien los datos, pero me carga cualquier cosa:
str_pun_mej_h, str_pun_mej_z
esos 2 son -..- Código PHP: public guardar_datos( id ) { if( g_estado[ id ] != LOGUEADO ) return; static szQuery[ 256 ], iData[ 2 ]; iData[ 0 ] = id; iData[ 1 ] = GUARDAR_DATOS; formatex(str_pun_mej_h, 30, "%d %d %d %d %d %d %d", g_puntos[id][0], g_p_gastados[id][0], g_mejoras[id][0][0], g_mejoras[id][0][1], g_mejoras[id][0][2], g_mejoras[id][0][3], g_mejoras[id][0][4]) formatex(str_pun_mej_z, 30, "%d %d %d %d %d %d", g_puntos[id][1], g_p_gastados[id][1], g_mejoras[id][1][0], g_mejoras[id][1][1], g_mejoras[id][1][2], g_mejoras[id][1][3]) formatex( szQuery, charsmax( szQuery ), "UPDATE %s SET Experiencia='%d', lvl='%d', reset='%d', classz='%d', classh='%d', pun_mej_h='%s', pun_mej_z='%s' WHERE id='%d'", TABLE, g_ammopacks[ id ], g_level[ id ],g_reset_level[ id ],g_zombieclassnext[id], g_class_h[id], str_pun_mej_h, str_pun_mej_z, g_id[ id ]); //server_print( szQuery ); SQL_ThreadQuery( g_hTuple, "DataHandler", szQuery, iData, 2 ); } public cargar_datos( id ) { static szQuery[ 256 ], iData[ 2 ]; iData[ 0 ] = id; iData[ 1 ] = CARGAR_DATOS; formatex( szQuery, charsmax( szQuery ), "SELECT `id`, `Experiencia`, `lvl`, `reset`, `classz`, `classh`, `pun_mej_h`, `pun_mej_z` FROM %s WHERE Usuario=^"%s^"", TABLE, g_usuario[ id ] ); server_print( szQuery ) SQL_ThreadQuery( g_hTuple, "DataHandler", szQuery, iData, 2 ); } // Javivi code:D public DataHandler( failstate, Handle:Query, error[ ], error2, data[ ], datasize, Float:time ) { static id; id = data[ 0 ]; if( !is_user_connected( id ) ) return PLUGIN_HANDLED static puntosSQL[2][4], p_gastadosSQL[2][4], mejoras_hSQL[5][4], mejoras_zSQL[4][4], Col_pun_mej_h, Col_pun_mej_z switch( failstate ) { case TQUERY_CONNECT_FAILED: { log_to_file( "SQL_LOG_TQ.txt", "Error en la conexion al MySQL [%i]: %s", error2, error ); return PLUGIN_CONTINUE; } 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_USUARIO: { if( !SQL_NumResults( Query ) ) client_cmd( id, "messagemode CREAR_PASSWORD" ); else { client_print( id, print_chat, "%s El usuario ya existe.", TAG ); client_cmd( id, "spk buttons/button10.wav" ); show_login_menu( id ); } } case REGISTRAR_PASSWORD: { if( failstate < TQUERY_SUCCESS ) { if( strfind( error, "Duplicate" ) != -1 ) { if( strfind( error, "Usuario" ) != -1 ) client_print( id, print_chat, "%s El usuario ya existe.", TAG ); else if( strfind( error, "Pj" ) != -1 ) client_print( id, print_chat, "%s El nombre de personaje esta en uso.", TAG ); } else client_print( id, print_chat, "%s Error al crear la cuenta. Intente nuevamente.", TAG ); client_cmd( id, "spk buttons/button10.wav" ); show_login_menu( id ); } else { client_print( id, print_chat, "%s Tu cuenta ha sido creada correctamente.", TAG ); cargar_datos( id ); } } case LOGUEAR_USUARIO: { if( SQL_NumResults( Query ) ) client_cmd( id, "messagemode LOGUEAR_PASSWORD" ); else { client_print( id, print_chat, "%s El usuario no existe.", TAG ); client_cmd( id, "spk buttons/button10.wav" ); show_login_menu( id ); } } case LOGUEAR_PASSWORD: { if( SQL_NumResults( Query ) ) { static szPass[ 33 ]; SQL_ReadResult( Query, 2, szPass, charsmax( szPass ) ); #if defined SECURITY static szBuffer[ 34 ]; md5( szPass, szBuffer ); if( equal( szBuffer, szPass ) ) #else if( equal( g_password[ id ], szPass ) ) #endif { SQL_ReadResult( Query, 3, g_playername[ id ], charsmax( g_playername[ ] ) ); cargar_datos( id ); } else { client_print( id, print_chat, "[Cuenta] Contrasenia incorrecta." ); client_cmd( id, "spk buttons/button10.wav" ); show_login_menu( id ); } } } // Ejemplo de como cargar y guardar datos. case CARGAR_DATOS: { if( SQL_NumResults( Query ) ) { g_id[ id ] = SQL_ReadResult( Query, 0 ); // Cargamos los datos de al columna 'Experiencia' en la variable global g_ammopacks g_ammopacks[ id ] = SQL_ReadResult( Query, 1 ); g_level[ id ] = SQL_ReadResult( Query, 2 ); g_reset_level[ id ] = SQL_ReadResult( Query, 3 ); g_zombieclassnext[id] = SQL_ReadResult( Query, 4 ); g_class_h[id] = SQL_ReadResult( Query, 5 ); SQL_ReadResult(Query, Col_pun_mej_h, str_pun_mej_h, 30) SQL_ReadResult(Query, Col_pun_mej_z, str_pun_mej_z, 30) func_login_success( id ); server_print( "%s", Col_pun_mej_h ); server_print( "%s", Col_pun_mej_z ); parse(str_pun_mej_h, puntosSQL[0], 3, p_gastadosSQL[0], 3, mejoras_hSQL[0], 3, mejoras_hSQL[1], 3, mejoras_hSQL[2], 3, mejoras_hSQL[3], 3, mejoras_hSQL[4], 3) parse(str_pun_mej_z, puntosSQL[1], 3, p_gastadosSQL[1], 3, mejoras_zSQL[0], 3, mejoras_zSQL[1], 3, mejoras_zSQL[2], 3, mejoras_zSQL[3], 3) server_print( "%s - %s - %s - %s - %s - %s - %s", puntosSQL[ 0 ], p_gastadosSQL[ 0 ], mejoras_hSQL[ 0 ], mejoras_hSQL[ 1 ], mejoras_hSQL[ 2 ], mejoras_hSQL[ 3 ], mejoras_hSQL[ 4 ] ); server_print( "%s - %s - %s - %s - %s - %s", puntosSQL[ 1 ], p_gastadosSQL[ 1 ], mejoras_zSQL[ 0 ], mejoras_zSQL[ 1 ], mejoras_zSQL[ 2 ], mejoras_zSQL[ 3 ] ); g_puntos[id][0] = str_to_num(puntosSQL[0]) g_puntos[id][1] = str_to_num(puntosSQL[1]) g_p_gastados[id][0] = str_to_num(p_gastadosSQL[0]) g_p_gastados[id][1] = str_to_num(p_gastadosSQL[1]) new i for(i = 0; i < 5; i++) g_mejoras[id][0][i] = str_to_num(mejoras_hSQL[i]) for(i = 0; i < 4; i++) g_mejoras[id][1][i] = str_to_num(mejoras_zSQL[i]) } else { client_print( id, print_chat, "%s Error al cargar los datos, intente nuevamente.", TAG ); g_estado[id] = OFFLINE; show_login_menu( id ); } } case GUARDAR_DATOS: { if( failstate < TQUERY_SUCCESS ) console_print( id, "%s Error en el guardado de datos.", TAG ); else{ formatex(str_pun_mej_h, 30, "%d %d %d %d %d %d %d", g_puntos[id][0], g_p_gastados[id][0], g_mejoras[id][0][0], g_mejoras[id][0][1], g_mejoras[id][0][2], g_mejoras[id][0][3], g_mejoras[id][0][4]) formatex(str_pun_mej_z, 30, "%d %d %d %d %d %d", g_puntos[id][1], g_p_gastados[id][1], g_mejoras[id][1][0], g_mejoras[id][1][1], g_mejoras[id][1][2], g_mejoras[id][1][3]) console_print( id, "%s Datos guardados.", TAG ); } } } return PLUGIN_CONTINUE; } |