[PROBLEMA]guardado/cargado de datos mysql r15
#1

Hola!estuve viendo la ultima actualizacion del plugin de BlueG's ,el problema que tengo es algunos datos al guardar los actualiza y otros no D: ,nose que estoy haciendo mal pero ya me tiene loco estuve toda la noche tocando de todo y no logro hacerlo funcionar.

Asi guardo las cuentas



Код:
forward CargarUsuario( playerid );
public CargarUsuario( playerid )
{
	static
	    rows  ,
	    fields
	;
	cache_get_data(rows, fields, ConnectionHandle);
	
	printf(" rows = %i, fields = %i", rows, fields );
	
	if( 0 < rows < 2 ) {
	
        Informacion[ playerid ][ _pSQLID ] = 				cache_get_row_int(0,0);
	    cache_get_row(0, 1, Informacion[ playerid ][ _Nombre ],65);
 		cache_get_row( 0, 2, Informacion[ playerid ][ _Password ] );
	 //   Informacion[ playerid ][ _Password ] = 				cache_get_row( 0, 2);
		Informacion[ playerid ][ _Pos ][ 0 ] = 				cache_get_row_float( 0,3);
		Informacion[ playerid ][ _Pos ][ 1 ]  = 			cache_get_row_float( 0,4);
		Informacion[ playerid ][ _Pos ][ 2 ] = 				cache_get_row_float( 0,5);
		Informacion[ playerid ][ _Pos ][ 3 ]  = 			cache_get_row_float( 0,6);
		Informacion[ playerid ][ _Vida ]  = 				cache_get_row_float( 0,7);
		Informacion[ playerid ][ _Chaleco ]= 				cache_get_row_float( 0,8);
		Informacion[ playerid ][ _Armas ][ 0 ] = 			cache_get_row_int( 0, 9);
		Informacion[ playerid ][ _Municiones ] [ 0 ]  = 	cache_get_row_int( 0, 10);
		Informacion[ playerid ][ _Armas ][ 1 ]  = 			cache_get_row_int( 0, 11);
		Informacion[ playerid ][ _Municiones ] [ 1 ] = 		cache_get_row_int( 0, 12);
		Informacion[ playerid ][ _Armas ][ 2 ]  = 			cache_get_row_int( 0, 13);
		Informacion[ playerid ][ _Municiones ] [ 2 ] = 		cache_get_row_int( 0, 14);
		Informacion[ playerid ][ _Armas ][ 3 ]  = 			cache_get_row_int( 0, 15);
		Informacion[ playerid ][ _Municiones ] [ 3 ] = 		cache_get_row_int( 0, 16);
		Informacion[ playerid ][ _Armas ][ 4 ]  = 			cache_get_row_int( 0, 17);
		Informacion[ playerid ][ _Municiones ] [ 4 ] = 		cache_get_row_int( 0, 18);
		Informacion[ playerid ][ _Armas ][ 5 ]  = 			cache_get_row_int( 0, 19);
		Informacion[ playerid ][ _Municiones ] [ 5 ] = 		cache_get_row_int( 0, 20);
		Informacion[ playerid ][ _Armas ][ 6 ] = 			cache_get_row_int( 0, 21);
		Informacion[ playerid ][ _Municiones ] [ 6 ] = 		cache_get_row_int( 0, 22);
		Informacion[ playerid ][ _Armas ][ 7 ] = 			cache_get_row_int( 0, 23);
		Informacion[ playerid ][ _Municiones ] [ 7 ] = 		cache_get_row_int( 0, 24);
		Informacion[ playerid ][ _Armas ][ 8 ] = 			cache_get_row_int( 0,25);
		Informacion[ playerid ][ _Municiones ] [ 8 ] =  	cache_get_row_int( 0, 26);
		Informacion[ playerid ][ _Armas ][ 9 ] = 			cache_get_row_int( 0, 27);
		Informacion[ playerid ][ _Municiones ] [ 9 ] = 		cache_get_row_int( 0, 28);
		Informacion[ playerid ][ _Armas ][ 10 ] = 			cache_get_row_int( 0, 29);
		Informacion[ playerid ][ _Municiones ] [ 10 ] = 	cache_get_row_int( 0, 30);
		Informacion[ playerid ][ _Armas ][ 11 ] = 			cache_get_row_int( 0, 31);
		Informacion[ playerid ][ _Municiones ] [ 11 ] = 	cache_get_row_int( 0, 32);
		Informacion[ playerid ][ _Armas ][ 12 ] = 			cache_get_row_int( 0, 33);
		Informacion[ playerid ][ _Municiones ] [ 12 ] = 	cache_get_row_int( 0, 34);
		Informacion[ playerid ][ _Skin ] = 					cache_get_row_int( 0, 35);
		Informacion[ playerid ][ _Dinero ] = 				cache_get_row_int( 0, 36);
		Informacion[ playerid ][ _Interior ] = 				cache_get_row_int( 0, 37);
		Informacion[ playerid ][ _VirWorld ] = 				cache_get_row_int( 0, 38);
        Informacion[ playerid ][ _Admin] = 			                        cache_get_row_int( 0, 39);
		Informacion[ playerid ][ _HizoTuto ] = 				cache_get_row_int( 0, 40);
		Informacion[ playerid ][ _Sexo ] = 					cache_get_row_int( 0, 41);
		Informacion[ playerid ][ _Edad ] = 					cache_get_row_int( 0, 42);
		Informacion[ playerid ][ _Faccion ] = 				cache_get_row_int( 0, 43);
		Informacion[ playerid ][ _Trabajo ] = 				cache_get_row_int( 0, 44);
		Informacion[ playerid ][ _Encendedor] = 			cache_get_row_int( 0, 45);
		Informacion[ playerid ][ _Cigarros ] = 				cache_get_row_int( 0, 46);
		Informacion[ playerid ][ _Banco ] = 				cache_get_row_int( 0, 47);
		Informacion[ playerid ][ _Nivel ] = 				cache_get_row_int( 0, 48);
		Informacion[ playerid ][ _Experiencia ] =  			cache_get_row_int( 0, 49);
		Informacion[ playerid ][ _Payday ] = 				cache_get_row_int( 0, 50);
		Informacion[ playerid ][ _TiempoConectado ] = 		cache_get_row_int( 0, 51);

		if( GetPVarInt( playerid, #Login ) != 1 ) {

	    	// ------------------------------------- //

	    	SetSpawnInfo( playerid, 0,  Informacion[ playerid ][ _Skin ], Informacion[ playerid ][ _Pos ][ 0 ],
		                            Informacion[ playerid ][ _Pos ][ 1 ], Informacion[ playerid ][ _Pos ][ 2 ],
		                            Informacion[ playerid ][ _Pos ][ 3 ], 0, 0, 0, 0, 0, 0)  ,
			SpawnPlayer( playerid )																,
			SetPlayerInterior( playerid, Informacion[ playerid ][ _Interior ])					,
			SetPlayerVirtualWorld( playerid, Informacion[ playerid ][ _VirWorld ] )				,
			SetPlayerHealth( playerid, Informacion[ playerid ][ _Vida ] )                        ,
			SetPlayerArmour( playerid, Informacion[ playerid ][ _Chaleco ] )                     ,
			GivePlayerMoney( playerid, Informacion[ playerid ][ _Dinero ])   	                ,
			SetPVarInt( playerid, #Login, 1 )                                                   ;

			// ------------------------------------- //

			for( new i = 0; i<= 13; i++) GivePlayerWeapon( playerid, Informacion[ playerid ][ _Armas ][ i ], Informacion[ playerid ][ _Municiones ][ i ] );

        	// ------------------------------------- //

			return SendClientMessage( playerid, ~0, #Bienvenido de nuevo.), 1;
		}
		return 1;
	}
	else {
	
	    static
    		szFormatMessageKick[ 128 ]
		;
  		// ------------------------------------- //

		SetPVarInt( playerid, #MAX_LOG_ERR, GetPVarInt( playerid, #MAX_LOG_ERR ) +1 );

		// ------------------------------------- //

		if( GetPVarInt( playerid, #MAX_LOG_ERR ) > 2 ) {
		
  			SendClientMessage( playerid, ~0, #Ў Password Errуnea ! );
     		format( szFormatMessageKick, sizeof szFormatMessageKick, #**%s fue kickeado por fallar 3 veces en sъ password, GetPName( playerid ) );
       		return SendClientMessageToAll( ~0, szFormatMessageKick ), 1;

		} else {

			SendClientMessage( playerid, ~0, #Ў Password Errуnea ! );
  			return ShowPlayerDialog( playerid, Dialogo_Ingreso, DIALOG_STYLE_PASSWORD, #Ingreso., #No insertaste una contraseсa vбlida., #Aceptar., #Cancelar.), 1;
	    }
	}
}
y asi la guardo

pawn Код:
GuardarCuenta( playerid )
{
if( GetPVarInt( playerid, #Login ) == 1 )
{
printf("Guardando cuenta");
static
Consulta [ 256 ];

GetPlayerPos( playerid, Informacion[ playerid ][ _Pos ][ 0 ], Informacion[ playerid ][ _Pos ][ 1 ], Informacion[ playerid ][ _Pos ][ 2 ] )  ,
GetPlayerFacingAngle( playerid, Informacion[ playerid ][ _Pos ][ 3 ] )                                                                  ,
GetPlayerHealth( playerid, Informacion[ playerid ][ _Vida ] )                                                                           ,
GetPlayerArmour( playerid, Informacion[ playerid ][ _Chaleco ] )                                                                         ,
Informacion[ playerid ][ _Dinero ]   = GetPlayerMoney       ( playerid )                                                                ,
Informacion[ playerid ][ _Interior ] = GetPlayerInterior        ( playerid )                                                                ,
Informacion[ playerid ][ _VirWorld ] = GetPlayerVirtualWorld    ( playerid )                                                                ;

// ------------------------------------- //
mysql_format( ConnectionHandle, Consulta, "UPDATE `Usuarios` SET Password='%s', PosX=%.4f, PosY=%.4f, PosZ=%.4f, Ang=%.4f, Vida=%.2f, Chaleco=%.2f WHERE `Nombre` = '%s' AND `ID_User` = '%i';", Informacion[ playerid ][ _Password ], Informacion[ playerid ][ _Pos ][ 0 ],
Informacion[ playerid ][ _Pos ][ 1 ], Informacion[ playerid ][ _Pos ][ 2 ], Informacion[ playerid ][ _Pos ][ 3 ], Informacion[ playerid ][ _Vida ], Informacion[ playerid ][ _Chaleco ], GetPName( playerid ), Informacion[ playerid ][ _pSQLID ] );
mysql_function_query( ConnectionHandle , Consulta , false, # , # ) ;

// ------------------------------------- //
for( new i; i<13; i++ ) {
GetPlayerWeaponData( playerid, i, Informacion[ playerid ][ _Armas ][ i ], Informacion[ playerid ][ _Municiones ][ i ] );
mysql_format( ConnectionHandle, Consulta, "UPDATE `Usuarios` SET Arma_%i=%i, Municion_%i=%i WHERE `Nombre` = '%s' AND `ID_User` = '%i';", i, Informacion[ playerid ][ _Armas ][ i ], Informacion[ playerid ][ _Municiones ][ i ], GetPName( playerid ), Informacion[ playerid ][ _pSQLID ] );
mysql_function_query( ConnectionHandle , Consulta , false, # , # ) ;
}

// ------------------------------------- //
mysql_format( ConnectionHandle, Consulta, "UPDATE `Usuarios` SET Skin=%i, Dinero=%i, Interior=%i, VirWorld=%i ,NivelAdmin=%i ,Tutorial=%i ,Sexo=%i ,Edad=%i WHERE `Nombre` = '%s' AND `ID_User` = '%i';", Informacion[ playerid ][ _Skin ], Informacion[ playerid ][ _Dinero ], Informacion[ playerid ][ _Interior ], Informacion[ playerid ][ _VirWorld ],Informacion[ playerid ][ _Admin] ,Informacion[ playerid ][ _HizoTuto],Informacion[ playerid ][_Sexo],Informacion[ playerid ][_Edad],GetPName( playerid ),
Informacion[ playerid ][ _pSQLID ]);
mysql_function_query( ConnectionHandle , Consulta , false, # , # ) ;

mysql_format( ConnectionHandle, Consulta, "UPDATE `Usuarios` SET Faccion=%i ,Trabajo=%i ,Encendedor=%i ,Cigarros=%i , Banco=%i ,Nivel=%i ,Experiencia=%i WHERE `Nombre` = '%s' AND `ID_User` = '%i';",Informacion[ playerid ][_Faccion],Informacion[ playerid ][_Trabajo],Informacion[ playerid ][_Encendedor],Informacion[ playerid ][_Cigarros],Informacion[ playerid ][_Banco],Informacion[ playerid ][_Nivel],Informacion[ playerid ][_Experiencia], GetPName( playerid ),
Informacion[ playerid ][ _pSQLID ]);
mysql_function_query( ConnectionHandle , Consulta , false, # , # ) ;

mysql_format( ConnectionHandle, Consulta, "UPDATE `Usuarios` SET Payday=%i ,TiempoConeccion=%i WHERE `Nombre` = '%s' AND `ID_User` = '%i';",Informacion[ playerid ][_Payday] ,Informacion[ playerid ][_TiempoConectado], GetPName( playerid ),
Informacion[ playerid ][ _pSQLID ]);
mysql_function_query( ConnectionHandle , Consulta , false, # , # ) ;

printf("La cuenta a sido guardada");
}
return 1;
}
Lo raro es que antes de actualizar me guardaba todo a la perfecciуn,ahora me guarda algunas cosas y otras no las actualiza (creo que el problema esta en los floats porque no me guarda ni la vida,ni la posicion,ni el chaleco) y como ven le agregue unos printf para ver si la funciуn se ejecutaba correctamente (la de guardar) y la consola me devuelve los dos mensajes.


Si alguien sabe que puedo estar haciendo mal le agradecerнa su ayuda
Reply


Messages In This Thread
[PROBLEMA]guardado/cargado de datos mysql r15 - by -[R]hysi- - 14.04.2013, 08:30
Respuesta: [PROBLEMA]guardado/cargado de datos mysql r15 - by WCrimson - 14.04.2013, 14:48
Respuesta: [PROBLEMA]guardado/cargado de datos mysql r15 - by -[R]hysi- - 14.04.2013, 15:26
Respuesta: [PROBLEMA]guardado/cargado de datos mysql r15 - by WCrimson - 14.04.2013, 15:46
Respuesta: [PROBLEMA]guardado/cargado de datos mysql r15 - by -[R]hysi- - 14.04.2013, 18:33

Forum Jump:


Users browsing this thread: 2 Guest(s)