A few simple Databse questions
#1

Hi

I am converting the ppc from using file operations to use sqlite databse instead.

For those that are common with ppc, may know that the fileoperations are done in an include, and my question is: when i open the database in the gamemode, how/can i acsess the database from the include (PPC_FileOperations)?

Also i noticed that there was some changes to the database in samp 0.3.7 and is these errors cause of using old values? If not, can you tell me whats wrong with it?

pawn Код:
//Open sqlite database
    new DB:Database;
    Database = db_open("DataPlayers.db");
    db_free_result(db_query(Database, "CREATE TABLE IF NOT EXISTS `Player` (`Name`, `Password`, `Level`, `Rank`, `Jailed`, `Wanted`, `Bans`, `RadioStation`, `TimezoneOffset`, `Fines`, `TotalFines`, `BanTime`, `SpawnToHouse`, `BusLicense`,
    `StatsMetersDriven`, `StatsTruckerJobs`, `StatsConvoyJobs`, `StatsBusDriverJobs`, `StatsPilotJobs`, `StatsSmugglerJobs`, `StatsSmugglerStolen`, `StatsSecouricarMissions`, `StatsVanMissions`, `StatsTankerMissions`, `StatsArticMissions`,
    `StatsDumperMissions`, `StatsCementMissions`, `StatsPoliceFined`, `StatsPoliceJailed`, `Money`, `Score`, `PlayerWelcomeMessage`)"
));
With erros:
pawn Код:
C:\Documents and Settings\IBM NetVista\Tyцpцytд\Sqlite Euro Trucking\gamemodes\PPC_Trucking.pwn(135) : error 037: invalid string (possibly non-terminated string)
C:\Documents and Settings\IBM NetVista\Tyцpцytд\Sqlite Euro Trucking\gamemodes\PPC_Trucking.pwn(135) : error 017: undefined symbol "CREATE"
C:\Documents and Settings\IBM NetVista\Tyцpцytд\Sqlite Euro Trucking\gamemodes\PPC_Trucking.pwn(135) : error 017: undefined symbol "TABLE"
C:\Documents and Settings\IBM NetVista\Tyцpцytд\Sqlite Euro Trucking\gamemodes\PPC_Trucking.pwn(135) : fatal error 107: too many error messages on one line
And line 135 :
pawn Код:
db_free_result(db_query(Database, "CREATE TABLE IF NOT EXISTS `Player` (`Name`, `Password`, `Level`, `Rank`, `Jailed`, `Wanted`, `Bans`, `RadioStation`, `TimezoneOffset`, `Fines`, `TotalFines`, `BanTime`, `SpawnToHouse`, `BusLicense`,
Thanks!
Reply
#2

You do realize that you cannot directly split to multiple lines when performing a string. You need to use the character "\", which indicates splitting to next line. (notice the red bolds)
Код:
db_free_result(db_query(Database, "CREATE TABLE IF NOT EXISTS `Player` (`Name`, `Password`, `Level`, `Rank`, `Jailed`, `Wanted`, `Bans`, `RadioStation`, `TimezoneOffset`, `Fines`, `TotalFines`, `BanTime`, `SpawnToHouse`, `BusLicense`, \
	`StatsMetersDriven`, `StatsTruckerJobs`, `StatsConvoyJobs`, `StatsBusDriverJobs`, `StatsPilotJobs`, `StatsSmugglerJobs`, `StatsSmugglerStolen`, `StatsSecouricarMissions`, `StatsVanMissions`, `StatsTankerMissions`, `StatsArticMissions`, \
	`StatsDumperMissions`, `StatsCementMissions`, `StatsPoliceFined`, `StatsPoliceJailed`, `Money`, `Score`, `PlayerWelcomeMessage`)"));
Also maybe you get a input line too long error. Use strcat and then run your query.


Quote:

how/can i acsess the database from the include (PPC_FileOperations)?

Yes you can do that, just similar way you open and access the database in the main script/gamemode.
Reply
#3

Thanks! +1 rep for you
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)