29.05.2018, 18:48
So, I put this code to OnGameModeInit. When I start the server this table is still not created, but other tables can be created. By the way I use MySQL R41
Код:
new query[1024]; format(query, sizeof(query), "CREATE TABLE IF NOT EXISTS `business` `ID` int(11) NOT NULL default '0',\ `Name` varchar(%d) default NULL,\ `Owner` varchar(24) default '-',\ `BusinessX` float default NULL,\ `BusinessY` float default NULL,\ `BusinessZ` float default NULL,\ `Closed` tinyint(1) default NULL,\ `Price` int(11) default NULL,\ `SalePrice` int(11) default NULL,\ `Earning` int(11) default NULL,", MAX_BUSINESS_NAME); format(query, sizeof(query), "%s\ `Money` int(11) default NULL,\ `Type` int(11) default NULL,\ `LastVisited` int(11) default NULL,\ PRIMARY KEY (`ID`),\ UNIQUE KEY `ID` (`ID`)\ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;", query); mysql_tquery(g_SQL, "CREATE TABLE IF NOT EXISTS `business_perms` (\ `ID` int(11) NOT NULL auto_increment,\ `Name` varchar(24) default NULL,\ `BusinessID` int(11) default NULL,\ `Can_Deposit` tinyint(1) default NULL,\ `Can_Take` tinyint(1) default NULL,\ PRIMARY KEY (`ID`),\ KEY `BusinessID` (`BusinessID`),\ CONSTRAINT `business_perms_ibfk_1` FOREIGN KEY (`BusinessID`) REFERENCES `business` (`ID`) ON DELETE CASCADE\ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;", "", ""); mysql_tquery(g_SQL, "CREATE TABLE IF NOT EXISTS `business_safelogs` (\ `ID` int(11) NOT NULL auto_increment,\ `Name` varchar(24) default NULL,\ `BusinessID` int(11) default NULL,\ `Amount` int(11) default NULL,\ `Date` int(11) default NULL,\ PRIMARY KEY (`ID`),\ KEY `BusinessID` (`BusinessID`),\ CONSTRAINT `business_safelogs_ibfk_1` FOREIGN KEY (`BusinessID`) REFERENCES `business` (`ID`) ON DELETE CASCADE\ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;", "", ""); mysql_tquery(g_SQL, "CREATE TABLE IF NOT EXISTS `business_transactions` (\ `ID` int(11) NOT NULL auto_increment,\ `OldOwner` varchar(24) default NULL,\ `NewOwner` varchar(24) default NULL,\ `Amount` int(11) default NULL,\ PRIMARY KEY (`ID`)\ ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", "", "");