MySQL, problem saving. + REP.
#1

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.)

PHP Code:

public Crearcuenta(playerid//Create account.
{
    new 
Query[254],name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    
mysql_format(MySQLQuerysizeof(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)",namepInfo[playerid][Clave]);
    
mysql_pquery(MySQLQuery"OnAccountRegister""d"playerid);
}
public 
OnAccountRegister(playerid//This callback is called when the account is created.
{
    
SetSpawnInfoplayerid0261707.1550,-1870.9567,13.5685,358.759000000);
    
TogglePlayerSpectating(playerid0);
    
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:XFloat:YFloat:Z;
    
GetPlayerPos(playeridX,Y,Z);
    
pInfo[playerid][Skin] = GetPlayerSkin(playerid);
    
mysql_format(MySQLQuerysizeof(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,ZpInfo[playerid][Skin], pInfo[playerid][Rango], Nombre(playerid));
    
mysql_tquery(MySQLQuery);
        
//This is for test and check where is the error.
    
print(" ");
    print(
" ");
    
printf("%s"Query);
    
printf("Telefono variable is: %d (test)"pInfo[playerid][Telefono]);

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?
Reply
#2

The variable is set to 0 when a player registers. What happens when a player is already registered? It simply doesn't set the variable to 0 and you get the value of the previous player.

Reset your variables in OnPlayerConnect.
Reply
#3

PHP Code:
public OnPlayerConnect(playerid)
{
    
SetPlayerColor(playeridCOLOR_WHITE);
    
pInfo[playerid][Nivel] = 0pInfo[playerid][Respeto] = 0pInfo[playerid][Rango] = 0pInfo[playerid][Telefono] = 0pInfo[playerid][Certificacion] = 0pInfo[playerid][Skin] = 0;
    
ShowPlayerDialog(playeridDIALOG_CANCIONDIALOG_STYLE_MSGBOX"{58ACFA}Rol Iberico.""· El servidor usa mъsica para el login.\n{FE9A2E}· їQuieres activar la mъsica de login?""Sн.""No.");
    return 
1;

The problem still, i don't know where can be the error. Thanks for help man.

EDIT: It's strange because the value of Telefono never change and always save as 99.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)