MySQL don't do UPDATE
#1

Hello, in my gamemode, the data has to be saved when the player disconnect. There is a function called SaveAccount(playerid), but when the player disconnect, the function don't update the database. The connection is succesful, because the register works properly, but this function, doesn't work and I don't know why.

Code:
pawn Код:
public SaveAccount(playerid)
{
    if(JugadorLogeado[playerid] == 1)
    {
    new query[1500],Float:x,Float:y,Float:z,Float:z_a,Float:VidaV,Float:x2,Float:y2,Float:z2,Float:z_a2,Float:VidaV2;
    new pName[32];
    if(autos[playerid] > 0)
    {
    GetVehicleHealth(autos[playerid], VidaV);
    GetVehiclePos(autos[playerid], x,y,z);
    PlayerInfo[playerid][vX] = x;
    PlayerInfo[playerid][vY] = y;
    PlayerInfo[playerid][vZ] = z;
    GetVehicleZAngle(autos[playerid], z_a);
    PlayerInfo[playerid][vA] = z_a;
    PlayerInfo[playerid][pVidaV] = VidaV;
    Baul[autos[playerid]] = 0;
    EspacioBaul[autos[playerid]] = 0;
    EspacioBaul2[autos[playerid]] = 0;
    EspacioBaul3[autos[playerid]] = 0;
    EspacioBaul4[autos[playerid]] = 0;
    DestroyVehicle(autos[playerid]);
    }
    if(autos2[playerid] > 0)
    {
    GetVehicleHealth(autos2[playerid], VidaV2);
    GetVehiclePos(autos2[playerid], x2,y2,z2);
    PlayerInfo[playerid][v2X] = x2;
    PlayerInfo[playerid][v2Y] = y2;
    PlayerInfo[playerid][v2Z] = z2;
    GetVehicleZAngle(autos2[playerid], z_a2);
    PlayerInfo[playerid][v2A] = z_a2;
    PlayerInfo[playerid][pVidaV2] = VidaV2;
    Baul[autos2[playerid]] = 0;
    EspacioBaul[autos2[playerid]] = 0;
    EspacioBaul2[autos2[playerid]] = 0;
    EspacioBaul3[autos2[playerid]] = 0;
    EspacioBaul4[autos2[playerid]] = 0;
    DestroyVehicle(autos2[playerid]);
    }
    PlayerInfo[playerid][pInterior] = GetPlayerInterior(playerid);
    PlayerInfo[playerid][pMundoVirtual] = GetPlayerVirtualWorld(playerid);
    GetPlayerPos(playerid, PlayerInfo[playerid][jPos_x], PlayerInfo[playerid][jPos_y], PlayerInfo[playerid][jPos_z]);
    GetPlayerName(playerid, pName, 32);
    PlayerInfo[playerid][vGas] = VehicleFuel[autos[playerid]];
    PlayerInfo[playerid][v2Gas] = VehicleFuel[autos2[playerid]];
    GetPlayerHealth(playerid, PlayerInfo[playerid][jVida]), GetPlayerArmour(playerid, PlayerInfo[playerid][jArmadura]);
    format(query, 1500, "UPDATE `usuarios` SET `Vida`='%f', `Chaleco`='%f', `Admin`='%d', `Nivel`='%d', `Money`='%d',`Seguro1`='%d',`GPS`='%d',`Radio`='%d',`X`='%f',`Y`='%f',`Z`='%f',`A`='%f',`X2`='%f',`Y2`='%f',`Z2`='%f',`A2`='%f',`Sexo`='%d',`Numero`='%d',`Interior`='%d',`MundoVirtual`='%d',`NivelArmero`='%d',`ExpArmero`='%d',`Materiales`='%d',`NivelCamionero`='%d',`NivelBasurero`='%d',`ExpBasurero`='%d'", PlayerInfo[playerid][jVida], PlayerInfo[playerid][jArmadura],
    PlayerInfo[playerid][jAdminNvl],PlayerInfo[playerid][jNivel],PlayerInfo[playerid][jDinero],PlayerInfo[playerid][pSeguro1],PlayerInfo[playerid][pGPS],PlayerInfo[playerid][pRadio],PlayerInfo[playerid][vX],PlayerInfo[playerid][vY],PlayerInfo[playerid][vZ],PlayerInfo[playerid][vA],PlayerInfo[playerid][v2X],PlayerInfo[playerid][v2Y],PlayerInfo[playerid][v2Z],PlayerInfo[playerid][v2A],PlayerInfo[playerid][jSexo],
    PlayerInfo[playerid][pNumero],PlayerInfo[playerid][pInterior],PlayerInfo[playerid][pMundoVirtual],PlayerInfo[playerid][pNivelArmero],PlayerInfo[playerid][pExpArmero],PlayerInfo[playerid][pMateriales],PlayerInfo[playerid][pNivelCamionero],PlayerInfo[playerid][pNivelBasurero],PlayerInfo[playerid][pExpBasurero]);
    format(query, 1500, "%s, `posX`='%f', `posY`='%f', `posZ`='%f',`TiempoCarcel`='%d',`TiempoJail`='%d',`Agonizando`='%d',`Trabajo`='%d',`Faccion`='%d'", query, PlayerInfo[playerid][jPos_x],  PlayerInfo[playerid][jPos_y],  PlayerInfo[playerid][jPos_z],PlayerInfo[playerid][pTiempoCarcelS]*1000,PlayerInfo[playerid][pTiempoJailS]*1000,PlayerInfo[playerid][Agonizando],PlayerInfo[playerid][jJob],PlayerInfo[playerid][jMiembro]);
    format(query, 1500, "%s, `Licencia`='%d',`Skin`='%d',`Banco`='%d',`VidaV`='%f',`VidaV2`='%f',`CasaID`='%d',`Moneda`='%d',`EnCasa`='%d',`EnRopero`='%d',`EnGarage`='%d',`vinterior`='%d',`vvw`='%d',`v2interior`='%d',`v2vw`='%d',`vGas`='%d',`v2Gas`='%d',`TiempoPD`='%d'", query,PlayerInfo[playerid][pLicencia],PlayerInfo[playerid][jRopa],PlayerInfo[playerid][pBanco],PlayerInfo[playerid][pVidaV],PlayerInfo[playerid][pVidaV2],PlayerInfo[playerid][CasaID],PlayerInfo[playerid][Moneda],
    PlayerInfo[playerid][EnCasa],PlayerInfo[playerid][EnRopero],
    PlayerInfo[playerid][EnGarage],PlayerInfo[playerid][vinterior], PlayerInfo[playerid][vvw],PlayerInfo[playerid][v2interior],PlayerInfo[playerid][v2vw],PlayerInfo[playerid][vGas],PlayerInfo[playerid][v2Gas],PlayerInfo[playerid][TiempoPD]);
    format(query, 1500, "%s, `Cargos`='%d',`ModeloSkin`='%d',`Duty`='%d',`WP0`='%d',`WP1`='%d',`WP2`='%d',`WP3`='%d',`WP4`='%d',`WP5`='%d',`WP6`='%d',`WP7`='%d',`WP8`='%d',`WP9`='%d',`WP10`='%d',`WP11`='%d',`WP12`='%d',`Experiencia`='%d'", query, PlayerInfo[playerid][pCargos],PlayerInfo[playerid][pModelo],
    PlayerInfo[playerid][pDuty],PlayerInfo[playerid][pWP0],PlayerInfo[playerid][pWP1],PlayerInfo[playerid][pWP2],PlayerInfo[playerid][pWP3],PlayerInfo[playerid][pWP4],PlayerInfo[playerid][pWP5],PlayerInfo[playerid][pWP6],PlayerInfo[playerid][pWP7],PlayerInfo[playerid][pWP8],PlayerInfo[playerid][pWP9],PlayerInfo[playerid][pWP10],PlayerInfo[playerid][pWP11],PlayerInfo[playerid][pWP12],PlayerInfo[playerid][jExperiencia]);
    format(query, 1500, "%s, `Segurov`='%d',`Segurov2`='%d',`ExpCamionero`='%d',`Agenda`='%d',`Crack`='%d',`Medicamentos`='%d',`vipjob`='%d',`VIP`='%d',`Rango`='%d',`Repuestos`='%d' WHERE `Username`='%s'", query,PlayerInfo[playerid][vSeguro],PlayerInfo[playerid][vSeguro2],PlayerInfo[playerid][pExpCamionero],PlayerInfo[playerid][pAgenda],PlayerInfo[playerid][pCrack],PlayerInfo[playerid][pMedicamentos],PlayerInfo[playerid][vipjob],PlayerInfo[playerid][vip],PlayerInfo[playerid][pRango],
    PlayerInfo[playerid][Repuestos],pName);
    mysql_function_query(Conecction, query, true, "OnQueryFinish", "ii", 0, playerid);
    JugadorLogeado[playerid] = 0;
    }
return 1;
}
And, mysql log:
Код:
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] >> cache_get_field_content(Connection handle: 1)
[10:40:48] [DEBUG] ProcessTick() - The cache has been cleared.
[10:40:48] [DEBUG] >> mysql_query_callback(Connection handle: 1)
[10:40:48] [DEBUG] ProcessQueryThread(OnQueryFinish) - Executing query UPDATE `usuarios` SET `Vida`='100.000000', `Chaleco`='0.000000', `Admin`='0', `Nivel`='1', `Money`='6000',`Seguro1`='0',`GPS`='0',`Radio`='0',`X`='0.000000',`Y`='0.000000',`Z`='0.000000',`A`='0.000000',`X2`='0.000000',`Y2`='0.000000',`Z2`='0.000000',`A2`='0.000000',`Sexo`='1',`Numero`='0',`Interior`='0',`MundoVirtual`='0',`NivelArmero`='1',`ExpArmero`='0',`Materiales`='0',`NivelCamionero`='1',`NivelBasurero`='1',`ExpBasurero`='0', `Posx`='1723.239990', `Posy`='-1870.859985', `Posz`='13.823735',`TiempoCarcel`='0',`TiempoJail`='0',`Agonizando`='0',`Trabajo`='0',`Faccion`='0', `Licencia`='0',`Skin`='250',`Banco`='0',`VidaV`='1000.000000',`VidaV2`='0.000000',`CasaID`='0',`Moneda`='0',`EnCasa`='0',`EnRopero`='0',`EnGarage`='0',`vinterior`='0',`vvw`='0',`v2interior`='0',`v2vw`='0',`vGas`='100',`v2Gas`='100',`TiempoPD`='0', `Cargos`='0',`ModeloSkin`='0',`Duty`='0',`WP0`='0',`WP1`='0',`WP2`='0',`WP3`='0',`WP4`='0',`WP5`='0',`WP6`='0',`WP7`='0',`WP8`='0',`WP9`='0',`WP10`='0',`WP11`='0',`WP12`='0',`Experiencia`='0', `Segurov`='0',`Segurov2`='0',`ExpCamionero`='0',`Agenda`='0',`Crack`='0',`Medicamentos`='0',`vipjob`='0',`VIP`='0',`Rango`='1',`Repuestos`='0' WHERE `Username`='Lenny_Doubhouse'...
[10:40:48] [DEBUG] ProcessQueryThread(OnQueryFinish) - Query was successful.
[10:40:48] [DEBUG] ProcessQueryThread(OnQueryFinish) - Data caching enabled.
[10:40:48] [WARNING] CMySQLHandler::StoreResult() - No data to store.
[10:40:48] [DEBUG] ProcessQueryThread(OnQueryFinish) - Data being passed to ProcessTick().
[10:40:48] [DEBUG] OnQueryFinish(ii) - Callback is being called...
[10:40:48] [DEBUG] ProcessTick() - The cache has been cleared.
The position is the same that in register, money, admin level and more too.
Reply
#2

їAnyone? :l
Reply
#3

The query was successful and it updates with the data you've stored. If you do not assign new values to the variables for the money, admin, position etc they'll be the same as when you registered.
Reply
#4

--reply removed--
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The query was successful and it updates with the data you've stored. If you do not assign new values to the variables for the money, admin, position etc they'll be the same as when you registered.
For example, the new position is stored in this line:
pawn Код:
GetPlayerPos(playerid, PlayerInfo[playerid][jPos_x], PlayerInfo[playerid][jPos_y], PlayerInfo[playerid][jPos_z]);
And then, in the query, in posX I insert the value of jPos_x, but always is the same as in the register. :S
Reply
#6

In the query was executed and you posted, the position is not 0.0 but:
pawn Код:
"... `Posx`='1723.239990', `Posy`='-1870.859985', `Posz`='13.823735' ..."
Reply
#7

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
you have to use strcat function to join one part of query with another
How strcat would be used in these cases?

pawn Код:
format(query, 1500, "UPDATE `usuarios` SET `Vida`='%f', `Chaleco`='%f', `Admin`='%d', `Nivel`='%d', `Money`='%d',`Seguro1`='%d',`GPS`='%d',`Radio`='%d',`X`='%f',`Y`='%f',`Z`='%f',`A`='%f',`X2`='%f',`Y2`='%f',`Z2`='%f',`A2`='%f',`Sexo`='%d',`Numero`='%d',`Interior`='%d',`MundoVirtual`='%d',`NivelArmero`='%d',`ExpArmero`='%d',`Materiales`='%d',`NivelCamionero`='%d',`NivelBasurero`='%d',`ExpBasurero`='%d'", PlayerInfo[playerid][jVida], PlayerInfo[playerid][jArmadura],
    PlayerInfo[playerid][jAdminNvl],PlayerInfo[playerid][jNivel],PlayerInfo[playerid][jDinero],PlayerInfo[playerid][pSeguro1],PlayerInfo[playerid][pGPS],PlayerInfo[playerid][pRadio],PlayerInfo[playerid][vX],PlayerInfo[playerid][vY],PlayerInfo[playerid][vZ],PlayerInfo[playerid][vA],PlayerInfo[playerid][v2X],PlayerInfo[playerid][v2Y],PlayerInfo[playerid][v2Z],PlayerInfo[playerid][v2A],PlayerInfo[playerid][jSexo],
    PlayerInfo[playerid][pNumero],PlayerInfo[playerid][pInterior],PlayerInfo[playerid][pMundoVirtual],PlayerInfo[playerid][pNivelArmero],PlayerInfo[playerid][pExpArmero],PlayerInfo[playerid][pMateriales],PlayerInfo[playerid][pNivelCamionero],PlayerInfo[playerid][pNivelBasurero],PlayerInfo[playerid][pExpBasurero]);
    strcat(query, "`posX`='%f', `posY`='%f', `posZ`='%f',`TiempoCarcel`='%d',`TiempoJail`='%d',`Agonizando`='%d',`Trabajo`='%d',`Faccion`='%d'", PlayerInfo[playerid][jPos_x],  PlayerInfo[playerid][jPos_y],  PlayerInfo[playerid][jPos_z],PlayerInfo[playerid][pTiempoCarcelS]*1000,PlayerInfo[playerid][pTiempoJailS]*1000,PlayerInfo[playerid][Agonizando],PlayerInfo[playerid][jJob],PlayerInfo[playerid][jMiembro]);
    strcat(query, "`Licencia`='%d',`Skin`='%d',`Banco`='%d',`VidaV`='%f',`VidaV2`='%f',`CasaID`='%d',`Moneda`='%d',`EnCasa`='%d',`EnRopero`='%d',`EnGarage`='%d',`vinterior`='%d',`vvw`='%d',`v2interior`='%d',`v2vw`='%d',`vGas`='%d',`v2Gas`='%d',`TiempoPD`='%d'", PlayerInfo[playerid][pLicencia],PlayerInfo[playerid][jRopa],PlayerInfo[playerid][pBanco],PlayerInfo[playerid][pVidaV],PlayerInfo[playerid][pVidaV2],PlayerInfo[playerid][CasaID],PlayerInfo[playerid][Moneda],
    PlayerInfo[playerid][EnCasa],PlayerInfo[playerid][EnRopero],
    PlayerInfo[playerid][EnGarage],PlayerInfo[playerid][vinterior], PlayerInfo[playerid][vvw],PlayerInfo[playerid][v2interior],PlayerInfo[playerid][v2vw],PlayerInfo[playerid][vGas],PlayerInfo[playerid][v2Gas],PlayerInfo[playerid][TiempoPD]);
Could it be used as that?
Reply
#8

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
In the query was executed and you posted, the position is not 0.0 but:
pawn Код:
"... `Posx`='1723.239990', `Posy`='-1870.859985', `Posz`='13.823735' ..."
Yes, but those are the coords of register, they hasn't changed, but I moved and they are still without change.
Reply
#9

You don't need strcat, you use format to insert the previous text and it is fine than calling 5 extra times another function (strcat).

I'm really not sure - the mysql logs clearly shows that the query was successful and you got the position before so it should've worked.
Reply
#10

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
You don't need strcat, you use format to insert the previous text and it is fine than calling 5 extra times another function (strcat).
Ok, but why the new coords, admin level and others aren't saved? The query update, but don't change nothing. It is without the new values... :S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)