Jump to content
  • 0

Set up vG script


Nicolasdes

Question

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.

Link to comment

Recommended Posts

  • 0

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." ?

Link to comment
  • 0

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 

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...