SA-MP Forums Archive
ayuda guardado mysql - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: ayuda guardado mysql (/showthread.php?tid=575194)



ayuda guardado mysql - capottematias - 24.05.2015

hola vi un tutorial como hacer un guardado mysql

hice como esta en el tutorial pero no me guarda las cordenadas ni nada solo la contraseсa

aka dejo los codigos de como es el guardado

espero q me puedan ayudar )

Quote:

forward SaveAccount(playerid);public SaveAccount(playerid)
{
new query[500];
GetPlayerPos(playerid, PlayerInfo[playerid][posx], PlayerInfo[playerid][posy], PlayerInfo[playerid][posz]);
format(query, 500, "UPDATE `user` SET `posX`='%f', `posY`='%f', `posZ`='%f', `angle`='%f', `interiorid`='%f', `adminlvl`='%s', `pass2`='%f', `dinero`='%d', `dinerobank`='%d', `banco`='%d', `movil`='%d', `dni`='%d', `busquedad`='%d', `sexo`='%d', `edad`='%d',`skin`='%d',`origen`='%d',`faccion`='% s', `carcel`='%d', `vida`='%d',
WHERE `id`='%d' LIMIT 1",
PlayerInfo[playerid][posx],
PlayerInfo[playerid][posy],
PlayerInfo[playerid][posz],
PlayerInfo[playerid][angle],
PlayerInfo[playerid][interiorid],
PlayerInfo[playerid][adminlvl],
PlayerInfo[playerid][pass2],
PlayerInfo[playerid][dinero],
PlayerInfo[playerid][dinerobank],
PlayerInfo[playerid][banco],
PlayerInfo[playerid][movil],
PlayerInfo[playerid][dni],
PlayerInfo[playerid][Busqueda],
PlayerInfo[playerid][sexo],
PlayerInfo[playerid][edad],
PlayerInfo[playerid][skin],
PlayerInfo[playerid][origen],
PlayerInfo[playerid][faccion],
PlayerInfo[playerid][carcel],
PlayerInfo[playerid][vida]);
mysql_function_query(Conecction, query, true, "OnQueryFinish", "ii", 0, playerid);
return 1;
}

Quote:

orward OnQueryFinish(resultid, extraid, ConnectionHandle);
public OnQueryFinish(resultid, extraid, ConnectionHandle)
{
new Rows, Field, string[256];
if(resultid != 0)
{
cache_get_data(Rows, Field);
}
switch(resultid)
{
case 1:
{
if(Rows == 1)
{
new content[20];
cache_get_field_content(0, "Contraseсa", PlayerInfo[extraid][passtext]);
cache_get_field_content(0, "posX", content); PlayerInfo[extraid][posx] = floatstr(content);
cache_get_field_content(0, "posY", content); PlayerInfo[extraid][posy] = floatstr(content);
cache_get_field_content(0, "posZ", content); PlayerInfo[extraid][posz] = floatstr(content);
cache_get_field_content(0, "angle", PlayerInfo[extraid][angle]);
cache_get_field_content(0, "interiorid", content); PlayerInfo[extraid][interiorid] = strval(content);
//cache_get_field_content(0, "virtualworldid", content); PlayerInfo[extraid][virtualworldid] = strval(content);
cache_get_field_content(0, "adminlvl", PlayerInfo[extraid][adminlvl]);
cache_get_field_content(0, "email", content); PlayerInfo[extraid][email] = strval(content);
cache_get_field_content(0, "pass2", content); PlayerInfo[extraid][pass2] = strval(content);
cache_get_field_content(0, "dinero", content); PlayerInfo[extraid][dinero] = strval(content);
cache_get_field_content(0, "dinerobank", content); PlayerInfo[extraid][dinerobank] = strval(content);
cache_get_field_content(0, "banco", content); PlayerInfo[extraid][banco] = strval(content);
cache_get_field_content(0, "movil", content); PlayerInfo[extraid][movil] = strval(content);
cache_get_field_content(0, "dni", content); PlayerInfo[extraid][dni] = strval(content);
cache_get_field_content(0, "Busqueda", content); PlayerInfo[extraid][Busqueda] = strval(content);
cache_get_field_content(0, "sexo", content); PlayerInfo[extraid][sexo] = strval(content);
cache_get_field_content(0, "edad", content); PlayerInfo[extraid][edad] = strval(content);
cache_get_field_content(0, "skin", content); PlayerInfo[extraid][skin] = strval(content);
cache_get_field_content(0, "origen", content); PlayerInfo[extraid][origen] = strval(content);
cache_get_field_content(0, "faccion", content); PlayerInfo[extraid][faccion] = strval(content);
cache_get_field_content(0, "carcel", content); PlayerInfo[extraid][carcel] = strval(content);
cache_get_field_content(0, "Vida", content); PlayerInfo[extraid][vida] = floatstr(content);
cache_get_field_content(0, "Chaleco", content); PlayerInfo[extraid][chaleco] = floatstr(content);
cache_get_field_content(0, "razonadv1", content); PlayerInfo[extraid][advrazon1] = strval(content);
cache_get_field_content(0, "razonadv2", content); PlayerInfo[extraid][advrazon2] = strval(content);
cache_get_field_content(0, "razonadv3", content); PlayerInfo[extraid][advrazon3] = strval(content);
cache_get_field_content(0, "advertencias",content); PlayerInfo[extraid][warnings] = strval(content);
cache_get_field_content(0, "DudeChannel", content); PlayerInfo[extraid][DudeChannel] = strval(content);
cache_get_field_content(0, "KeyCar1", content); PlayerInfo[extraid][KeyCar1] = strval(content);
cache_get_field_content(0, "KeyCar2", content); PlayerInfo[extraid][KeyCar2] = strval(content);
cache_get_field_content(0, "KeyCar3", content); PlayerInfo[extraid][KeyCar3] = strval(content);
SetSpawnInfo(extraid,0,0, PlayerInfo[extraid][posx],PlayerInfo[extraid][posy],PlayerInfo[extraid][posz],0.0,0,0,0,0,0,0);
SetPlayerArmour(extraid, PlayerInfo[extraid][chaleco]);
SetPlayerHealth(extraid, PlayerInfo[extraid][vida]);




Respuesta: ayuda guardado mysql - Zume - 24.05.2015

PHP код:
forward SaveAccount(playerid);public SaveAccount(playerid)
{
    new 
        
query[500];

    
GetPlayerPos(playeridPlayerInfo[playerid][posx], PlayerInfo[playerid][posy], PlayerInfo[playerid][posz]);

    
format(querysizeof query"UPDATE `user` SET `posX`='%f', `posY`='%f', `posZ`='%f', `angle`='%f', `interiorid`='%f'",
        
PlayerInfo[playerid][posx],
        
PlayerInfo[playerid][posy],
        
PlayerInfo[playerid][posz],
        
PlayerInfo[playerid][angle],
        
PlayerInfo[playerid][interiorid]);

    
format(querysizeof query"%s, `adminlvl`='%s', `pass2`='%f', `dinero`='%d', `dinerobank`='%d', `banco`='%d', `movil`='%d', `dni`='%d'"
        
query
        
PlayerInfo[playerid][adminlvl],
        
PlayerInfo[playerid][pass2],
        
PlayerInfo[playerid][dinero],
        
PlayerInfo[playerid][dinerobank],
        
PlayerInfo[playerid][banco],
        
PlayerInfo[playerid][movil],
        
PlayerInfo[playerid][dni]);

    
format(querysizeof query"%s, `busquedad`='%d', `sexo`='%d', `edad`='%d',`skin`='%d',`origen`='%d',`faccion`='% s', `carcel`='%d', `vida`='%d'"
        
query
        
PlayerInfo[playerid][Busqueda],
        
PlayerInfo[playerid][sexo],
        
PlayerInfo[playerid][edad],
        
PlayerInfo[playerid][skin],
        
PlayerInfo[playerid][origen],
        
PlayerInfo[playerid][faccion],
        
PlayerInfo[playerid][carcel],
        
PlayerInfo[playerid][vida]);

    
format(querysizeof query"%s WHERE `id`='%d' LIMIT 1"queryACA_FALTA_ALGO);
    
    
mysql_function_query(Conecctionquerytrue"OnQueryFinish""ii"0playerid);
    return 
1;

Revisa el WHERE, y el tipo de las variables.. vi un "interiorid" con %f. y procura redondear los %f con %.2f


Re: Respuesta: ayuda guardado mysql - capottematias - 24.05.2015

Quote:
Originally Posted by _Zume
Посмотреть сообщение
PHP код:
forward SaveAccount(playerid);public SaveAccount(playerid)
{
    new 
        
query[500];
    
GetPlayerPos(playeridPlayerInfo[playerid][posx], PlayerInfo[playerid][posy], PlayerInfo[playerid][posz]);
    
format(querysizeof query"UPDATE `user` SET `posX`='%f', `posY`='%f', `posZ`='%f', `angle`='%f', `interiorid`='%f'",
        
PlayerInfo[playerid][posx],
        
PlayerInfo[playerid][posy],
        
PlayerInfo[playerid][posz],
        
PlayerInfo[playerid][angle],
        
PlayerInfo[playerid][interiorid]);
    
format(querysizeof query"%s, `adminlvl`='%s', `pass2`='%f', `dinero`='%d', `dinerobank`='%d', `banco`='%d', `movil`='%d', `dni`='%d'"
        
query
        
PlayerInfo[playerid][adminlvl],
        
PlayerInfo[playerid][pass2],
        
PlayerInfo[playerid][dinero],
        
PlayerInfo[playerid][dinerobank],
        
PlayerInfo[playerid][banco],
        
PlayerInfo[playerid][movil],
        
PlayerInfo[playerid][dni]);
    
format(querysizeof query"%s, `busquedad`='%d', `sexo`='%d', `edad`='%d',`skin`='%d',`origen`='%d',`faccion`='% s', `carcel`='%d', `vida`='%d'"
        
query
        
PlayerInfo[playerid][Busqueda],
        
PlayerInfo[playerid][sexo],
        
PlayerInfo[playerid][edad],
        
PlayerInfo[playerid][skin],
        
PlayerInfo[playerid][origen],
        
PlayerInfo[playerid][faccion],
        
PlayerInfo[playerid][carcel],
        
PlayerInfo[playerid][vida]);
    
format(querysizeof query"%s WHERE `id`='%d' LIMIT 1"queryACA_FALTA_ALGO);
    
    
mysql_function_query(Conecctionquerytrue"OnQueryFinish""ii"0playerid);
    return 
1;

Revisa el WHERE, y el tipo de las variables.. vi un "interiorid" con %f. y procura redondear los %f con %.2f

format(query, sizeof query, "%s WHERE `id`='%d' LIMIT 1", query, ACA_FALTA_ALGO); donde me pusiste ACA_FALTA_ALGO saves q lleva o no tenes idea?ї


Respuesta: ayuda guardado mysql - Zume - 24.05.2015

Una ID ЪNICA que diferencie a al fila del usuario con todas las demбs


Re: Respuesta: ayuda guardado mysql - capottematias - 25.05.2015

Quote:
Originally Posted by _Zume
Посмотреть сообщение
Una ID ЪNICA que diferencie a al fila del usuario con todas las demбs
me sigue apareciendo las selditas vacias


Respuesta: ayuda guardado mysql - Zume - 25.05.2015

Lo guardas en la fila equivocada o inexistente, o la sintбxis es mala por que no exista uno de los valores en la tabla.. Revise mysql_log