Sign in to follow this  
Nicolasdes

Set up vG script

Recommended Posts

Hello, I've found vG's Sapphire Script and when I launch server.exe, it said (at the end):

[2012-05-19 12:57:39] ERROR: mysql\connection.lua:13: attempt to call global 'mysql_connect' (a nil value)

[2012-05-19 12:57:55] ERROR: attempt to call a nil value

[2012-05-19 12:57:55] ERROR: call: failed to call 'mysql:query_fetch_assoc' [string "?"]

Some lines of my connection.lua:

-- connection settings 
local hostname = "**HOST**" 
local username = "** USR **" 
local password = "**PASS**" 
local database = "**DB**" 
local port = 3306 
  
-- global things. 
local MySQLConnection = nil 
local resultPool = { } 
local sqllog = false 
local countqueries = 0 
  
-- connectToDatabase - Internal function, to spawn a DB connection 
function connectToDatabase(res) 
    MySQLConnection = mysql_connect(hostname, username, password, database, port) 
     
    if (not MySQLConnection) then 
        if (res == getThisResource()) then 
            cancelEvent(true, "Cannot connect to the database.") 
        end 
        return nil 
    end 
     
    return nil 
end 

SQL works with another gamemodes.

Share this post


Link to post

You need to set up a MySQL server. and then changing the connection details.

Share this post


Link to post

Here's the code again in LUA Syntax:

-- connection settings 
local hostname = "**HOST**" 
local username = "** USR **" 
local password = "**PASS**" 
local database = "**DB**" 
local port = 3306 
  
-- global things. 
local MySQLConnection = nil 
local resultPool = { } 
local sqllog = false 
local countqueries = 0 
  
-- connectToDatabase - Internal function, to spawn a DB connection 
function connectToDatabase(res) 
    MySQLConnection = mysql_connect(hostname, username, password, database, port) 
    
    if (not MySQLConnection) then 
        if (res == getThisResource()) then 
            cancelEvent(true, "Cannot connect to the database.") 
        end 
        return nil 
    end 
    
    return nil 
end 

Anyways, Did it output to the console: "Cannot connect to the database." ?

Share this post


Link to post

A lot of errors appear, but I think, it didn't

EDIT: When I close the server, it say: "Closing SQLite3", but the ressource is mysql.

Share this post


Link to post

SQlite is another built-in MTA Database...

It's used for Accounts... but I doubt vG uses it...

Share this post


Link to post

Did you created your own table?

Probably the script is running through vG's Database

Share this post


Link to post

oh, you're going to have to use the MTA functions to create a DB, unless you want to use the SQL Browser to create it...

Share this post


Link to post

ok, When you start a script you could do a check with the function to see if the db is created, if it's not created then you could use a function to create it, here's some MTA functions:

dbPoll 
dbConnect 
dbExec 
dbQuery 
dbFree 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.