PDA

View Full Version : Help!


Hybris
09/10/2015, 08:16 PM
Hello this line is too long I was wondering if there was a way to put the query's under eachother or something
db_query(Database, "CREATE TABLE IF NOT EXISTS Users (Userid INTEGER PRIMARY KEY AUTOINCREMENT, Username VARCHAR(24) COLLATE NOCASE, Password VARCHAR(129), Admin INTEGER DEFAULT 0 NOT NULL, Premium INTEGER DEFAULT 0 NOT NULL, Money INTEGER DEFAULT 0 NOT NULL, Score INTEGER DEFAULT 0 NOT NULL, Kills INTEGER DEFAULT 0 NOT NULL, Deaths INTEGER DEFAULT 0 NOT NULL, KD INTEGER DEFAULT 0 NOT NULL)");

Face9000
09/10/2015, 08:18 PM
Use strcat. One tip: Save just the more important variables like Username, Password and if you have it, IP. For others save them manually.

Hybris
09/10/2015, 08:42 PM
Aren't there faster ways to do this?

Face9000
09/10/2015, 09:04 PM
Yes. With that code you're creating the table "Users", probably you're running it on OnGameModeInit, instead, open your database with phpmyadmin, and execute this query:


CREATE TABLE IF NOT EXISTS `Users` (
`Userid` int(10) NOT NULL,
`Username` varchar(24) NOT NULL,
`Password` varchar(129) NOT NULL,
`Admin` int(11) NOT NULL,
`Premium` int(11) NOT NULL,
`Money` int(11) NOT NULL,
`Score` int(11) NOT NULL,
`Kills` int(11) NOT NULL,
`Deaths` int(11) NOT NULL,
`Deaths` int(11) NOT NULL,
`KG` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Hybris
09/10/2015, 09:17 PM
Sorry but im using SQL not MySQL I just need an efficient and fast way to make the columns without reducing speed...

Face9000
09/10/2015, 09:27 PM
Emh....SQL is MySql...with the code your provided us it will create everytime the table, with my code just once.

Hybris
09/10/2015, 09:39 PM
Im not creating the table everytime only if the table is non existant in scriptfiles while mysql needs a mysql server I only need a efficient way of creating the query's but Im not sure if there is a better way than strcat

gurmani11
09/10/2015, 10:42 PM
new tquery[512];
strcat(tquery,"CREATE TABLE IF NOT EXISTS Users (Userid INTEGER PRIMARY KEY AUTOINCREMENT,\
Username VARCHAR(24) COLLATE NOCASE,\
Password VARCHAR(129),\
Admin INTEGER DEFAULT 0 NOT NULL,\
Premium INTEGER DEFAULT 0 NOT NULL,\
Money INTEGER DEFAULT 0 NOT NULL,");
strcat(tquery,"Score INTEGER DEFAULT 0 NOT NULL,\
Kills INTEGER DEFAULT 0 NOT NULL,\
Deaths INTEGER DEFAULT 0 NOT NULL,\
KD INTEGER DEFAULT 0 NOT NULL)");

db_query(Database,tquery);