Author Topic: Database Problems  (Read 4981 times)

0 Members and 1 Guest are viewing this topic.

Offline Honey.

  • Made Man
  • ***
  • Posts: 111
    • View Profile
Database Problems
« on: September 08, 2014, 07:16:24 pm »
Hello,

I was making a Register/Login System for my script but my database is not accessible by the vcmp server.I tried making Tables using my script but the database is not reached properly and when the server is ON the datbase should get locked as a default but my database doesn't get Locked.I have updated modules and Updated vcmp server client.There was a Bug in the modules where the modules cannot connect to the database but according to Stormeus it was Fixed.I do not know why I still have it.

OFF : How to know someone's FPS?
« Last Edit: September 08, 2014, 08:05:46 pm by Honey. »

Offline thijn

  • LU testers
  • VC:MP Veteran
  • *
  • Posts: 667
  • Im proud to be pro.
    • View Profile
    • Vice Underdogs
Re: Database Problems
« Reply #1 on: September 08, 2014, 08:11:49 pm »
Post some code and your directory structure.

Offline Honey.

  • Made Man
  • ***
  • Posts: 111
    • View Profile
Re: Database Problems
« Reply #2 on: September 09, 2014, 02:08:00 pm »
I tried to make tables like this :

Code: [Select]
QuerySQL( db, "CREATE TABLE IF NOT EXISTS Account ( Name TEXT, Password TEXT, IP NUMERIC, Level NUMERIC, Cash NUMERIC, Bank NUMERIC, )" );

but the database is not affected.Secondly the database was not locked when I tried to save something in it, which proves that there was no connection between my server and database.

Dir Structure :

« Last Edit: September 09, 2014, 05:13:37 pm by Honey. »

Offline heekz.shadow

  • LU testers
  • Made Man
  • *
  • Posts: 249
    • View Profile
Re: Database Problems
« Reply #3 on: September 09, 2014, 03:18:26 pm »
You realise that your script and the database will be downloaded by the client if you store them in "store" folder, right?
Code: [Select]
[20:23] <habi> later only i heard that lu chatbox is customizable. On my first visit, it appeared ugly.
[20:23] <habi> May be that also be the reason why lu has no players

Offline Honey.

  • Made Man
  • ***
  • Posts: 111
    • View Profile
Re: Database Problems
« Reply #4 on: September 09, 2014, 05:12:46 pm »
I don't have those files in the store folder.They're outside in the main directory.To Get More specific see this img:




Offline Honey.

  • Made Man
  • ***
  • Posts: 111
    • View Profile
Re: Database Problems
« Reply #5 on: September 12, 2014, 07:26:02 pm »
Bump!

Offline S.L.C

  • Street Thug
  • *
  • Posts: 42
  • Sorry if you weren't impressed!
    • View Profile
Re: Database Problems
« Reply #6 on: September 12, 2014, 08:54:49 pm »
There's an issue with your query:
Code: [Select]
CREATE TABLE IF NOT EXISTS Account ( Name TEXT, Password TEXT, IP NUMERIC, Level NUMERIC, Cash NUMERIC, Bank NUMERIC, )Can you see it?
Code: [Select]
Bank NUMERIC, )
There's a comma "," symbol that isn't supposed to be there at the end:
Code: [Select]
CREATE TABLE IF NOT EXISTS Account ( Name TEXT, Password TEXT, IP NUMERIC, Level NUMERIC, Cash NUMERIC, Bank NUMERIC )
EDIT:

But that whole query is wrong and my recommendation is to get rid or it. Try the following example and see if it works:
Code: [Select]
// General global constants
const MAX_NAME_LENGTH = 128;
const MAX_PASSWORD_LENGTH = 128;
const MAX_ADDRESS_LENGTH = 16;

// Global variable holding the database handle
local g_DB = null;

function checkDb(name)
{
// If the database file doesn't exist then try to create one
local fp = file(name, "a");
// Check if the previous action succeeded
if (fp == null)
{
print("Unable to open or create the file: " + name);
// No point in going forward
return false;
}
// Now we know the database file exists and can be opened.
else fp.close();
// Try to open the file as an SQLite database
g_DB = ConnectSQL(name);
// Check if the previous action succeeded
if (g_DB == null)
{
print("Unable to open the SQLite database: " + name);
// No point in going forward
return false;
}
else return true;
}

function onServerStart()
{
if (!checkDb("mydb.db")) return 0;

// Try to create the table
QuerySQL(g_DB, format(@"CREATE TABLE IF NOT EXISTS [Account] (
[Name] VARCHAR(%u)  NOT NULL,
[Password] VARCHAR(%u)  NOT NULL,
[IP] VARCHAR(%u)  NULL,
[Level] NUMERIC DEFAULT '0' NULL,
[Cash] NUMERIC DEFAULT '0' NULL,
[Bank] NUMERIC DEFAULT '0' NULL
);", MAX_NAME_LENGTH, MAX_PASSWORD_LENGTH, MAX_ADDRESS_LENGTH));
}
« Last Edit: September 13, 2014, 12:52:15 am by S.L.C »

Offline Honey.

  • Made Man
  • ***
  • Posts: 111
    • View Profile
Re: Database Problems
« Reply #7 on: September 13, 2014, 07:30:17 am »
Problem Solved, My DB Browser was either outdated or bugged so I installed a new and updated version of it but I still want to know how to get FPS?

Offline S.L.C

  • Street Thug
  • *
  • Posts: 42
  • Sorry if you weren't impressed!
    • View Profile
Re: Database Problems
« Reply #8 on: September 13, 2014, 10:28:11 am »
There's a read only property on the player instance called "FPS". And you can see the player FPS through that variable:
Code: [Select]
function onPlayerJoin(i_player)
{
    print(i_player.FPS);
}

Offline Honey.

  • Made Man
  • ***
  • Posts: 111
    • View Profile
Re: Database Problems
« Reply #9 on: September 13, 2014, 11:54:46 am »
Thanks  ;) Topic Locked!