05.05.2015, 16:09
Hi everyone, i made one MySQL register and login system. Yesterday started to work bad and i didn't change anything on the system of login/register script.
The problem is that's, when someone reponse the dialog of the register, one callback is called and it creates the account and the database and set all the variables for the player correctly. The account creates perfectly, but the problem is the next:
- I never changed the values of the variable pInfo[playerid][Telefono] and pInfo[playerid][Certificacion] but when i save the account at the callback it save with strange values. I'm goint to show you the script and the sa-mp server console (I used printf for look and search the error at the save.)
In this screen we can see, the update and variables are wrong. I disconnected when the account was just created.
Remember the variables of Rango, Telefono and Certifacion never wasn't changed in the gamemode script.
Where is the error?
The problem is that's, when someone reponse the dialog of the register, one callback is called and it creates the account and the database and set all the variables for the player correctly. The account creates perfectly, but the problem is the next:
- I never changed the values of the variable pInfo[playerid][Telefono] and pInfo[playerid][Certificacion] but when i save the account at the callback it save with strange values. I'm goint to show you the script and the sa-mp server console (I used printf for look and search the error at the save.)
PHP Code:
public Crearcuenta(playerid) //Create account.
{
new Query[254],name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
mysql_format(MySQL, Query, sizeof(Query), "INSERT INTO `usuarios`(`Usuario`, `Clave`, `Nivel`, `Respeto`, `Nstaff`, `Certificacion`, `Telefono`, `PosX`, `PosY`, `PosZ`, `Skin`, `Rango`) VALUES ('%s','%s',3,12,'Vacio',1,0,100,100,100,26,0)",name, pInfo[playerid][Clave]);
mysql_pquery(MySQL, Query, "OnAccountRegister", "d", playerid);
}
public OnAccountRegister(playerid) //This callback is called when the account is created.
{
SetSpawnInfo( playerid, 0, 26, 1707.1550,-1870.9567,13.5685,358.7590, 0, 0, 0, 0, 0, 0 );
TogglePlayerSpectating(playerid, 0);
SpawnPlayer(playerid);
pInfo[playerid][Skin] = 26;
pInfo[playerid][Nivel] = 3;
pInfo[playerid][Respeto] = 12;
pInfo[playerid][Rango] = 0;
pInfo[playerid][Telefono] = 0; //We can see, the variable is just set to 0.
pInfo[playerid][PosicionX] = 1707.1550;
pInfo[playerid][PosicionY] = -1870.9567;
pInfo[playerid][PosicionZ] = 13.5685;
format(pInfo[playerid][NombreStaff], 254, "Vacio");
SendClientMessage(playerid, -1, "Has recibido nivel tres por registrarte en fase desarrollo.");
}
public ActualizarCuenta(playerid) //Update the account. (This callback is called onplayerdisconnect)
{
new Query[254], Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X,Y,Z);
pInfo[playerid][Skin] = GetPlayerSkin(playerid);
mysql_format(MySQL, Query, sizeof(Query), "UPDATE `usuarios` SET `Clave`='%s',`Nivel`=%d, `Respeto`=%d,`Nstaff`='%s',`Certificacion`=%d, `Telefono`=%d, `PosX`=%f,`PosY`=%f,`PosZ`=%f,`Skin`=%d,`Rango`=%d WHERE `Usuario` = '%s'",
pInfo[playerid][Clave], pInfo[playerid][Nivel], pInfo[playerid][Respeto], pInfo[playerid][NombreStaff], pInfo[playerid][Certificacion], pInfo[playerid][Telefono], X,Y,Z, pInfo[playerid][Skin], pInfo[playerid][Rango], Nombre(playerid));
mysql_tquery(MySQL, Query);
//This is for test and check where is the error.
print(" ");
print(" ");
printf("%s", Query);
printf("Telefono variable is: %d (test)", pInfo[playerid][Telefono]);
}
Remember the variables of Rango, Telefono and Certifacion never wasn't changed in the gamemode script.
Where is the error?