212: mysql_format(mysql, query, sizeof(query), "INSERT INTO `players` (`ID`, `User`, `Pass`, `IP`, `Admin`,\ 213:`SkinID`, `AccountLocked`, `AccountBanned`, `BanningAdmin`, `BannedReason`, `MoneyHand`, `MoneyBank`,\ 214:`Health`, `Armour`, `LastActivity`, `WeaponSlot1`, `WepSlotAmmo1`, `WeaponSlot2`, `WepSlotAmmo2`, `WeaponSlot3`, `WepSlotAmmo3`, `WeaponSlot4`, `WepSlotAmmo4`, `WeaponSlot5`, `WepSlotAmmo5`) VALUES ('', '%e', '%s', '%s', 0, 299, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 5000, 0, 0, 0, 100.0, 0.0, 0, 0)", GetUserName(playerid), Player[playerid][Pass], IP[playerid]); 215: mysql_tquery(mysql, query, "CreateUser", "i", playerid);
new string[500], query[500];
format(string, sizeof(string), "INSERT INTO `players` (`ID`, `User`, `Pass`, `IP`, `Admin`, `MoneyHand`, `MoneyBank`, `Health`, `Armour`, ");
strcat(string, "`LastActivity`, `WeaponSlot1`, `WeaponAmmo1`, `WeaponSlot2`, `WeaponAmmo2`, `WeaponSlot3`, `WeaponAmmo3`, `WeaponSlot4`, `WeaponAmmo4`, `WeaponSlot5`, `WeaponAmmo5`) ");
strcat(string, "VALUES (``, `%e`, `%s`, `%s`, 0, 299, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 5000, 0, 0, 0, 100.0, 0.0,0, 0)");
mysql_format(mysql, query, sizeof(query), string, GetUserName(playerid), Player[playerid][Pass], IP[playerid]);
mysql_tquery(mysql, query, "CreateUser", "i", playerid);
strimplode(" ",
q,
sizeof(q),
"CREATE TABLE IF NOT EXISTS `PlayerClassData`",
"(PlayerName TEXT,",
"p_Class INTEGER,",
"p_LastSwitch INTEGER,",
"p_ClassLevel TEXT,",
"p_ClassTime TEXT,",
"p_ClassCurrLevel TEXT);"
);
1) Use default values. This will significantly shorten your query because you don't have to insert zeros.
2) Inventory information should actually be moved to a separate table. If there can be an indefinite amount of something it should be in a separate table. Now you can argue that you only want to store three weapons, but if in the future you decide you want to store more you have to edit your database and your queries, whereas with proper normalization you wouldn't have to change anything. |