si intento guardar mas variables me salta "no such table: cuentas", asi creo la db
pd: si me pueden ayudar a acortar el guardado de una forma distinta se los agradeceria con +1
Código PHP:
Error en la consulta al MySQL [1]: no such table: cuentas
CREATE TABLE "cuentas"
(
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"Usuario" VARCHAR NOT NULL UNIQUE,
"Password" VARCHAR NOT NULL,
"Pj" VARCHAR NOT NULL UNIQUE,
"ap" INTEGER DEFAULT 5,
"lvl" INTEGER DEFAULT 1,
"rr" INTEGER DEFAULT 0,
"habhm1" INTEGER DEFAULT 0,
"habhm2" INTEGER DEFAULT 0,
"habhm3" INTEGER DEFAULT 0,
"habhm4" INTEGER DEFAULT 0,
"habhm5" INTEGER DEFAULT 0,
"habzm1" INTEGER DEFAULT 0,
"habzm2" INTEGER DEFAULT 0,
"habzm3" INTEGER DEFAULT 0,
"habzm4" INTEGER DEFAULT 0,
"habzm5" INTEGER DEFAULT 0,
"ptsh" INTEGER DEFAULT 0,
"ptsz" INTEGER DEFAULT 0,
"ptshg" INTEGER DEFAULT 0,
"ptszg" INTEGER DEFAULT 0,
"ptt" INTEGER DEFAULT 0,
"mh" INTEGER DEFAULT 0,
"mz" INTEGER DEFAULT 0,
"effe" INTEGER DEFAULT 0,
"c1" INTEGER DEFAULT 0,
"c2" INTEGER DEFAULT 0,
"c3" INTEGER DEFAULT 0,
"cf1" INTEGER DEFAULT 0,
"cf2" INTEGER DEFAULT 0,
"cf3" INTEGER DEFAULT 0,
"cn1" INTEGER DEFAULT 0,
"cn2" INTEGER DEFAULT 0,
"cn3" INTEGER DEFAULT 0
)
Código PHP:
public guardar_datos( id ) {
new szQuery[2000], iData[ 2 ], len;
len = 0
iData[ 0 ] = id;
iData[ 1 ] = GUARDAR_DATOS;
len += formatex(szQuery[len], sizeof szQuery - 1 - len, "UPDATE %s SET ", szTable);
len += formatex(szQuery[len], sizeof szQuery - 1 - len, "ap='%d', lvl='%d', rr='%d',", g_iAmmoPacks[id], gLevel[id][0], gLevel[id][1]);
len += formatex(szQuery[len], sizeof szQuery - 1 - len, "habhm1='%d', habhm2='%d', habhm3='%d', habhm4='%d', habhm5='%d',", gHabilidad[id][0][0], gHabilidad[id][0][1], gHabilidad[id][0][2], gHabilidad[id][0][3], gHabilidad[id][0][4]);
len += formatex(szQuery[len], sizeof szQuery - 1 - len, "habzm1='%d', habzm2='%d', habzm3='%d', habzm4='%d', habzm5='%d',", gHabilidad[id][1][0], gHabilidad[id][1][1], gHabilidad[id][1][2], gHabilidad[id][1][3], gHabilidad[id][1][4]);
len += formatex(szQuery[len], sizeof szQuery - 1 - len, "ptsh='%d', ptsz='%d', ptshg='%d', ptszg='%d', ptt='%d', mh='%d', mz='%d',", gPuntos[id][0], gPuntos[id][1], gPuntosG[id][0], gPuntosG[id][1], gPuntoT[id], gMision[id][0], gMision[id][1]);
len += formatex(szQuery[len], sizeof szQuery - 1 - len, "effe='%d', c1='%d', c2='%d', c3='%d', cf1='%d', cf2='%d', cf3='%d',", gHudEffect[id], gHudColor[id][0], gHudColor[id][1], gHudColor[id][2], gNvgColor[id][0], gNvgColor[id][1], gNvgColor[id][2]);
len += formatex(szQuery[len], sizeof szQuery - 1 - len, "cn1='%d', cn2='%d', cn3='%d'", gFlareColor[id][0], gFlareColor[id][1], gFlareColor[id][2]);
len += formatex(szQuery[len], sizeof szQuery - 1 - len, "WHERE id='%d'", 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 )
client_print( id, print_chat, "%s El usuario ya existe.", szPrefix );
else if( containi( error, "Pj" ) != -1 )
client_print( id, print_chat, "%s El nombre de personaje esta en uso.", szPrefix );
else
client_print( id, print_chat, "%s Error al crear la cuenta. Intente nuevamente.", szPrefix );
client_cmd( id, "spk buttons/button10.wav" );
show_login_menu( id );
}
else {
client_print( id, print_chat, "%s Tu cuenta ha sido creada correctamente.", szPrefix );
new szQuery[ 2000 ], 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_iAmmoPacks[ id ] = SQL_ReadResult( Query, 4 );
gLevel[id][0] = SQL_ReadResult( Query, 5);
gLevel[id][1] = SQL_ReadResult( Query, 6 );
gHabilidad[id][0][0] = SQL_ReadResult( Query, 7 );
gHabilidad[id][0][1] = SQL_ReadResult( Query, 8 );
gHabilidad[id][0][2] = SQL_ReadResult( Query, 9 );
gHabilidad[id][0][3] = SQL_ReadResult( Query, 10 );
gHabilidad[id][0][4] = SQL_ReadResult( Query, 11 );
gHabilidad[id][1][0] = SQL_ReadResult( Query, 12 );
gHabilidad[id][1][1] = SQL_ReadResult( Query, 13 );
gHabilidad[id][1][2] = SQL_ReadResult( Query, 14 );
gHabilidad[id][1][3] = SQL_ReadResult( Query, 15 );
gHabilidad[id][1][4] = SQL_ReadResult( Query, 16 );
gPuntos[id][0] = SQL_ReadResult( Query, 17 );
gPuntos[id][1] = SQL_ReadResult( Query, 18 );
gPuntosG[id][0] = SQL_ReadResult( Query, 19 );
gPuntosG[id][1] = SQL_ReadResult( Query, 20 );
gPuntoT[id] = SQL_ReadResult( Query, 21 );
gMision[id][0] = SQL_ReadResult( Query, 22 );
gMision[id][1] = SQL_ReadResult( Query, 23 );
gHudEffect[id] = SQL_ReadResult( Query, 24 );
gHudColor[id][0] = SQL_ReadResult( Query, 25 );
gHudColor[id][1] = SQL_ReadResult( Query, 26 );
gHudColor[id][2] = SQL_ReadResult( Query, 27 );
gNvgColor[id][0] = SQL_ReadResult( Query, 28 );
gNvgColor[id][1] = SQL_ReadResult( Query, 29 );
gNvgColor[id][2] = SQL_ReadResult( Query, 30 );
gFlareColor[id][0] = SQL_ReadResult( Query, 31 );
gFlareColor[id][1] = SQL_ReadResult( Query, 32 );
gFlareColor[id][2] = SQL_ReadResult( Query, 33 );
func_login_success( id );
}
else {
client_print( id, print_chat, "%s Usuario o Contraseñ incorrecta.", szPrefix );
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_iAmmoPacks[ id ] = 5
gLevel[id][0] = 1
gLevel[id][1] = 0
gHabilidad[id][0][0] = 0
gHabilidad[id][0][1] = 0
gHabilidad[id][0][2] = 0
gHabilidad[id][0][3] = 0
gHabilidad[id][0][4] = 0
gHabilidad[id][0][0] = 0
gHabilidad[id][1][1] = 0
gHabilidad[id][1][2] = 0
gHabilidad[id][1][3] = 0
gHabilidad[id][1][4] = 0
gPuntos[id][0] = 500
gPuntos[id][1] = 500
gPuntosG[id][0] = 0
gPuntosG[id][1] = 0
gPuntoT[id] = 0
gMision[id][0] = 1
gMision[id][1] = 1
gHudEffect[id] = 0
gHudColor[id][0] = 255
gHudColor[id][1] = 255
gHudColor[id][2] = 255
gNvgColor[id][0] = 255
gNvgColor[id][1] = 255
gNvgColor[id][2] = 255
gFlareColor[id][0] = 255
gFlareColor[id][1] = 255
gFlareColor[id][2] = 255
func_login_success( id );
}
else {
client_print( id, print_chat, "%s Error al cargar los datos, intente nuevamente.", szPrefix );
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 );
}
}
}
pd: si me pueden ayudar a acortar el guardado de una forma distinta se los agradeceria con +1
https://steamcommunity.com/id/adriancek1ng/
Aquellos que te critican quieren verte distinto,
Por que ven en ti lo que ellos no serán jamás.
Aquellos que te critican quieren verte distinto,
Por que ven en ti lo que ellos no serán jamás.