Need little help
#1

Hi, i have a problem in MySQL , everytime a new account is register is saved on ID 0 in database, but i have aleardy a ID 0....
Код:
[19:24:47] [join] Banditul has joined the server (0:109.98.164.145)
[19:24:56] [Registration] New account registered. Database ID: [0]
[19:25:01] [part] Banditul has left the server (0:1)
[19:25:01] New saved account: ID SQL: 0
[19:25:56] [connection] 109.98.164.145:23553 requests connection cookie.
[19:25:57] [connection] incoming connection: 109.98.164.145:23553 id: 0
[19:25:58] [join] Player has joined the server (0:109.98.164.145)
[19:26:06] [Registration] New account registered. Database ID: [0]
[19:26:09] [part] Player has left the server (0:1)
[19:26:09] New saved account: ID SQL: 0
My register function is this:
Код:
public OnAccountRegister(playerid) 
{ 
    Player[playerid][pID] = cache_insert_id(); 
    printf("[Registration] New account registered. Database ID: [%d]", Player[playerid][pID]); 
	
	Player[playerid][pLogged] = 1;
	Player[playerid][pScore] = 0;
    Player[playerid][pAdmin] = 0;
	Player[playerid][pVIP] = 0;
	Player[playerid][pScore] = 0;
    Player[playerid][pMoney] = 5000;
	ResetPlayerMoney(playerid);
	Player[playerid][Muted] = 0;
	
	
	new Query[500], playerip[16];
	GetPlayerIp(playerid, playerip, 16);
	mysql_format(mysql, Query, sizeof(Query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Admin`, `VIP`, `Score`, `Money`,  `Muted`) VALUES ('%e', '%e', '%e', 'd', 'd', 'd', 'd', 'd')", pName(playerid), Player[playerid][Password], playerip, Player[playerid][pAdmin], Player[playerid][pVIP], Player[playerid][pScore], Player[playerid][pMoney], Player[playerid][Muted]); 
    mysql_tquery(mysql, Query, "", "");
	SetPlayerScore(playerid, Player[playerid][pScore]);
    GivePlayerMoney(playerid, Player[playerid][pMoney]);
    TogglePlayerSpectating(playerid, false); 

    SetSpawnInfo(playerid, 0, 23, 10.0, 10.0, 5.0, 0.0, 0, 0, 0, 0, 0, 0); 
    SpawnPlayer(playerid); 
    return true; 
}
And the save is:
Код:
public OnAccountSave(playerid)
{
	if(Player[playerid][pLogged] == 0) return 1;
	Player[playerid][pMoney] = GetPlayerMoney(playerid);
	ResetPlayerMoney(playerid);
	Player[playerid][pScore] = GetPlayerScore(playerid);
	new query[300];

    mysql_format(mysql, query, sizeof(query), "UPDATE `accounts` SET `Money` = '%d', `Score` = '%d', `Admin` = '%d',`VIP` = '%d',  `Muted` = '%d' WHERE `ID` = '%d'", 
	Player[playerid][pMoney],Player[playerid][pScore], Player[playerid][pAdmin], Player[playerid][pVIP],Player[playerid][Muted],Player[playerid][pID]); 
    mysql_tquery(mysql, query, "Account_Saved", "d", playerid); 
    
	Player[playerid][pLogged] = 0;
	
    return 1; 
}
Reply
#2

Set your mysql table "ID" column settings Primary Key, A_I check
Reply
#3

It's Primary Key and AI , and account in mysql register like id 1 2 3....but when a new account is register still ID 0 is saving, but after i disconnect and connect again my data save in correct ID.
Код:
[10:29:30] [join] Player has joined the server (0:109.98.164.53)
[10:29:38] [Registration] New account registered. Database ID: [0]
[10:29:42] [part] Player has left the server (0:1)
[10:29:42] New saved account: ID SQL: 0
[10:30:22] [connection] 109.98.164.53:36866 requests connection cookie.
[10:30:23] [connection] incoming connection: 109.98.164.53:36866 id: 0
[10:30:24] [join] Player has joined the server (0:109.98.164.53)
[10:30:35] [part] Player has left the server (0:1)
[10:30:35] New saved account: ID SQL: 3
So problem is in register, but i can't find it....
EDIT: Nevermind, i fix it, i made a mistake on register dialog
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)