· 10 years ago · Aug 28, 2016, 10:12 AM
1 // ~~~ ~~~ ~~~ Server Connect[Sql] ~~~ ~~~ ~~~~ //
2 Connection = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS);
3 new temp[2500];
4 strcat(temp, "CREATE TABLE IF NOT EXISTS `"Users_Table"` (`UserID` int(10) NOT NULL AUTO_INCREMENT, `UserName` varchar(24) NOT NULL,");
5 strcat(temp, "`Password` varchar(32) NULL, `PlayerIP` varchar(24) NULL, `Money` int DEFAULT 0,");
6 strcat(temp, "`AdminLevel` int DEFAULT 0,`HelperLevel` int DEFAULT 0,`NighterLevel` int DEFAULT 0,`BroadLevel` int DEFAULT 0,`VipLevel` int DEFAULT 0,");
7 strcat(temp, "`Tag` varchar(32) DEFAULT null, `Wins` int DEFAULT 0, `MWins` int DEFAULT 0, `Loses` int DEFAULT 0, `LabelText` varchar(32) NULL, `LabelTime` int DEFAULT 0, `VipTime` int DEFAULT 0,");
8 strcat(temp, "`CarColor1` int DEFAULT -1,`CarColor2` int DEFAULT -1, `CarColorTime` int DEFAULT -1, `HeadTime` int DEFAULT -1, `HeadID` int DEFAULT 0,");
9 strcat(temp, "`NeonTime` int DEFAULT -1,`NeonType` int DEFAULT 0, `HandsTime` int DEFAULT -1, `Maps` int DEFAULT 0, `TagTime` int DEFAULT -1, `Coins` int DEFAULT 0,");
10 strcat(temp, "`MuteTime` int DEFAULT -1, `pClanID` int DEFAULT 0, `ClanLevel` int DEFAULT 0, `ClanTag` varchar(25) DEFAULT NULL, `Warns` int DEFAULT 0, `ClansManager` int DEFAULT 0, `AdminWarn` int DEFAULT 0, `AutoLogin` int DEFAULT 0,");
11 strcat(temp, "PRIMARY KEY (`UserID`))");
12 strcat(temp, "ENGINE=InnoDB DEFAULT CHARSET=latin1;");
13 mysql_query(Connection, temp, false);
14
15 temp[0] = EOS;
16 strcat(temp, "CREATE TABLE IF NOT EXISTS `"Codes_Table"` (`CodeID` int(5) NOT NULL AUTO_INCREMENT, `CodeText` varchar("#MAX_CODES_STRLEN") NOT NULL, `CodeType` int DEFAULT 0,");
17 strcat(temp, "PRIMARY KEY (`CodeID`))");
18 strcat(temp, "ENGINE=InnoDB DEFAULT CHARSET=latin1;");
19 mysql_query(Connection, temp, false);
20
21 temp[0] = EOS;
22 strcat(temp, "CREATE TABLE IF NOT EXISTS `"Bans_Table"` (`BanID` int(5) NOT NULL AUTO_INCREMENT, `UserName` varchar(25) NOT NULL, `Reason` varchar(25) NOT NULL,");
23 strcat(temp, "`Admin` varchar(25) NULL, `PlayerIP` varchar("#MAX_IP_L") NULL, `Time` int DEFAULT -1,");
24 strcat(temp, "PRIMARY KEY (`BanID`))");
25 strcat(temp, "ENGINE=InnoDB DEFAULT CHARSET=latin1;");
26 mysql_query(Connection, temp, false);
27
28 temp[0] = EOS;
29 strcat(temp, "CREATE TABLE IF NOT EXISTS `"Clans_Table"` (`ClanID` int(5) NOT NULL AUTO_INCREMENT, `CName` varchar(25) NOT NULL, `CFounder` varchar(25) NOT NULL,");
30 strcat(temp, "`CPlayers` int DEFAULT NULL, `CMessage` varchar(100) NULL, `CWarns` int DEFAULT 0,`CBalance` int DEFAULT 0,");
31 strcat(temp, "`CColorR` int DEFAULT 0,`CColorG` int DEFAULT 0,`CColorB` int DEFAULT 0,");
32 strcat(temp, "`CChatColorR` int DEFAULT 0, `CChatColorG` int DEFAULT 0, `CChatColorB` int DEFAULT 0, `CChat` int DEFAULT 1, `CBank` int DEFAULT 0, `CSlots` int DEFAULT 1,");
33 strcat(temp, "`CWins` int DEFAULT 0, `CLoses` int DEFAULT 0, `CTag` int DEFAULT 0,");
34 strcat(temp, "PRIMARY KEY (`ClanID`))");
35 strcat(temp, "ENGINE=InnoDB DEFAULT CHARSET=latin1;");
36 mysql_query(Connection, temp, false);
37
38 temp[0] = EOS;
39 strcat(temp, "CREATE TABLE IF NOT EXISTS `"Server_Table"` (`DataID` int(5) NOT NULL AUTO_INCREMENT, `Clans` int DEFAULT 0, `RegisterPlayers` int DEFAULT 0,");
40 strcat(temp, "`AdminMessage` varchar(128) NOT NULL, `AdmPass` varchar(50) NOT NULL, `ServerMessage` varchar(128) NOT NULL,`MaxRecord` int DEFAULT 0, `DayMaxOnline` int DEFAULT 0,");
41 strcat(temp, "PRIMARY KEY (`DataID`))");
42 strcat(temp, "ENGINE=InnoDB DEFAULT CHARSET=latin1;");
43 mysql_query(Connection, temp, false);
44
45 for(new i = 1; i < MAX_CODES; i++)
46 {
47 format(str, sizeof(str), "SELECT * FROM "Codes_Table" WHERE CodeID = '%d'", i);
48 mysql_tquery(Connection, str, "GetCodesInfo", "i", i);
49 }
50
51 for(new i = 1; i < MAX_SERVERDATA_MYSQL; i++)
52 {
53 new g_iRows, g_iFields;
54 mysql_format(Connection, str, sizeof(str), "SELECT * FROM "Server_Table" WHERE DataID = '%d'", i);
55 mysql_query(Connection, str);
56 cache_get_data(g_iRows, g_iFields, Connection);
57 if(!g_iRows)
58 {
59 DerbyInfo[AdmPass] = EOS;
60 DerbyInfo[MaxRecord] =
61 DerbyInfo[Clans] =
62 DerbyInfo[RegisterPlayers] =
63 DerbyInfo[DayMaxOnline] = 0;
64
65 }
66 else
67 {
68 new field[200];
69 format(DerbyInfo[AdmPass], 50, (cache_get_field_content(0, "AdmPass", field), field));
70 DerbyInfo[MaxRecord] = cache_get_field_content_int(0, "MaxRecord", Connection);
71 DerbyInfo[DayMaxOnline] = cache_get_field_content_int(0, "DayMaxOnline", Connection);
72 DerbyInfo[Clans] = cache_get_field_content_int(0, "Clans", Connection);
73 DerbyInfo[RegisterPlayers] = cache_get_field_content_int(0, "RegisterPlayers", Connection);
74 }
75 }