stock DB_UserInit()
{
new query[2048];
strcat(query, "CREATE TABLE IF NOT EXISTS "TABLE_USERS" (\n");
strcat(query, "Username VARCHAR(24) NOT NULL DEFAULT ' ',\n");
strcat(query, "Password CHAR(65) NOT NULL DEFAULT ' ',\n");
strcat(query, "IP CHAR(16) NOT NULL DEFAULT '0.0.0.0',\n");
strcat(query, "Exp INT(5) NOT NULL DEFAULT '0',\n");
strcat(query, "Level INT(5) NOT NULL DEFAULT '0',\n");
strcat(query, "VIP BOOLEAN NOT NULL DEFAULT '0',\n");
strcat(query, "Admin INT(4) NOT NULL DEFAULT '0',\n");
strcat(query, "Disabled BOOLEAN NOT NULL DEFAULT '0',\n");
strcat(query, "AutoLogin BOOLEAN NOT NULL DEFAULT '0',\n");
strcat(query, "RegisterDate DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'\n,");
strcat(query, "LoginDate DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00',\n");
strcat(query, "CONSTRAINT PRIMARY KEY(Username)) ENGINE=InnoDB ;");
mysql_tquery(MySQL, query, "OnQueryFinished", "dd", 0, 0);
format(query, 2048, "");
strcat(query, "CREATE TABLE IF NOT EXISTS "TABLE_CHARACTERS" (\n");
strcat(query, "ID INT(12) NOT NULL AUTO_INCREMENT,\n");
strcat(query, "Username VARCHAR(24) UNIQUE NOT NULL,\n");
strcat(query, "FirstName VARCHAR(24) NOT NULL DEFAULT ' ',\n");
strcat(query, "LastName VARCHAR(24) NOT NULL DEFAULT ' ',\n");
strcat(query, "Cash INT(12) NOT NULL DEFAULT '0',\n");
strcat(query, "Bank INT(12) NOT NULL DEFAULT '0',\n");
strcat(query, "Skin INT(4) NOT NULL DEFAULT '0',\n");
strcat(query, "Sex BOOLEAN NOT NULL DEFAULT '0',\n");
strcat(query, "Age INT(4) NOT NULL DEFAULT '0',\n");
strcat(query, "Health DECIMAL(6,2) NOT NULL DEFAULT '100.0',\n");
strcat(query, "Armor DECIMAL(6,2) NOT NULL DEFAULT '0.0',\n");
strcat(query, "Energy DECIMAL(6,2) NOT NULL DEFAULT '100.0',\n");
strcat(query, "PhoneNumber INT(6) NOT NULL DEFAULT '0',\n");
strcat(query, "DrivingLicense BOOLEAN NOT NULL DEFAULT '0',\n");
strcat(query, "FlyingLicense BOOLEAN NOT NULL DEFAULT '0',\n");
strcat(query, "GunPermit BOOLEAN NOT NULL DEFAULT '0',\n");
strcat(query, "HuntPermit BOOLEAN NOT NULL DEFAULT '0',\n");
strcat(query, "FishPermit BOOLEAN NOT NULL DEFAULT '0',\n");
strcat(query, "Wanted INT(2) NOT NULL DEFAULT '0',\n");
strcat(query, "Fine INT(12) NOT NULL DEFAULT '0',\n");
strcat(query, "Jail BOOLEAN NOT NULL DEFAULT '0',\n");
strcat(query, "Cell INT(4) NOT NULL DEFAULT '0',\n");
strcat(query, "Bail INT(12) NOT NULL DEFAULT '0',\n");
strcat(query, "Phone INT(4) NOT NULL DEFAULT '0',\n");
strcat(query, "CONSTRAINT PRIMARY KEY(ID),\n");
strcat(query, "CONSTRAINT FOREIGN KEY(Username) REFERENCES "TABLE_USERS"(Username)\nON DELETE SET NULL\nON UPDATE CASCADE\n) ENGINE=InnoDB ;");
mysql_tquery(MySQL, query, "OnQueryFinished", "dd", 0, 0);
return 1;
}
public OnQueryError(errorid, error[], callback[], query[], connectionHandle)
{
printf("***MySQL ERROR!\n\tError no.%d - %s\n\tCallback: %s\n\tQuery: %s", errorid, error, callback, query);
return 1;
}
[14:01:06] ***MySQL ERROR! Error no.1215 - Impossible d'ajouter des contraintes d'index externe Callback: OnQueryFinished Query: CREATE TABLE IF NOT EXISTS characters ( ID INT(12) NOT NULL AUTO_INCREMENT, Username VARCHAR(24) UNIQUE NOT NULL, FirstName VARCHAR(24) NOT NULL DEFAULT ' ', LastName VARCHAR(24) NOT NULL DEFAULT ' ', Cash INT(12) NOT NULL DEFAULT '0', Bank INT(12) NOT NULL DEFAULT '0', Skin INT(4) NOT NULL DEFAULT '0', Sex BOOLEAN NOT NULL DEFAULT '0', Age INT(4) NOT NULL DEFAULT '0', Health DECIMAL(6,2) NOT NULL DEFAULT '100.0', Armor DECIMAL(6,2) NOT NULL DEFAULT '0.0', Energy DECIMAL(6,2) NOT NULL DEFAULT '100.0', PhoneNumber INT(6) NOT NULL DEFAULT '0', DrivingLicense BOOLEAN NOT NULL DEFAULT '0', FlyingLicense BOOLEAN NOT NULL DEFAULT '0', GunPermit BOOLEAN NOT NULL DEFAULT '0', HuntPermit BOOLEAN NOT NULL DEFAULT '0', FishPermit BOOLEAN NOT NULL DEFAULT '0', Wanted INT(2) NOT NULL DEFAULT '0', Fine INT(12) NOT NULL DEFAULT '0', Jail BOOLEAN NOT NULL DEFAULT '0', Cell INT(4) NOT NULL DEFAULT '0', Bail INT(12) NOT NULL DEFAULT '0', Phone INT(4) NOT NULL DEFAULT '0', CONSTRAINT PRIMARY KEY(ID), CONSTRAINT FOREIGN KEY(Username) REFERENCES users(Username) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB ;
I'm sorry but I don't want to create the tables manually, I want the sa-mp server to do it
|