Jump to content

MYSQL


TheNightRider

Recommended Posts

Posted

@SolidSnake14 MTA Paradise is a good GM it just needs to be put in proper things and re-scripted re-don like put the account-system and lses-system don't just put things in the players thing.

Posted

@NightRider, I suggest you take a look at one of the resources that use sqlite, like house_system by dakilla, or my business resource.

Posted
@SolidSnake14 MTA Paradise is a good GM it just needs to be put in proper things and re-scripted re-don like put the account-system and lses-system don't just put things in the players thing.

I was talking about the MySQL of MTA Paradise, he tried to put a Lua table with columns into a MySQL table like MTA Paradise does, but it's not that simple.

Posted

I have had a look and ive tidied the script up however it still returns the connection has nil (false) could someone explain why this is happening?

  
function( ) 
        local server = dbConnect( "sqlite", "Storedinfo.db" ) 
        local qh = dbQuery(server, "SELECT * FROM vehicles") 
        local results = dbPoll( qh, -1 ) 
        for key, value in pairs( results ) do 
           dbFree ( dbQuery ( connection,"CREATE TABLE IF NOT EXISTS newTable ( vehicleID, model, posX, posY, posZ, rotX, rotY, rotZ, interior, dimension, respawnPosX, respawnPosY, respawnPosZ, respawnRotX, respawnRotY, respawnRotZ, respawnInterior, respawn, Dimension, numberplate, health, color1, color2, characterID, engineState, locked, lightsState, tintedWindows, fuel")) 
          return end 
  

Posted
function( ) 
    local server = dbConnect( "sqlite", "Storedinfo.db" ) 
    local qh = dbQuery(server, "SELECT * FROM vehicles") 
    local results = dbPoll( qh, -1 ) 
    dbFree ( dbQuery ( server,"CREATE TABLE IF NOT EXISTS newTable ( vehicleID, model, posX, posY, posZ, rotX, rotY, rotZ, interior, dimension, respawnPosX, respawnPosY, respawnPosZ, respawnRotX, respawnRotY, respawnRotZ, respawnInterior, respawn, Dimension, numberplate, health, color1, color2, characterID, engineState, locked, lightsState, tintedWindows, fuel")) 
end) 

Posted

What kind of nil?

like "attempt to call global function (blahblah) a nil value" ? That means you need to check meta.xml and make sure it's serverside script

also are you sure you're running one of the latest nightlies (patches) ?

Posted

Thanks for that I forgot to state its server in the meta.xml lol I was told in the past if you don't state which 1 it is it will become serverside any ways. What is the nightlies patch and do you know where I can get it from?

I have a syntax error near 'fuel' but I cannot find it lol

  
dbFree ( dbQuery ( server,"CREATE TABLE IF NOT EXISTS newTable ( vehicleID, model, posX, posY, posZ, rotX, rotY, rotZ, interior,respawnPosX, respawnPosY, respawnPosZ, respawnRotX, respawnRotY, respawnRotZ, respawnInterior, respawn, Dimension, numberplate, health, color1, color2, characterID, engineState, locked, lightsState, tintedWindows, fuel")) 
  

Posted
Thanks for that I forgot to state its server in the meta.xml lol I was told in the past if you don't state which 1 it is it will become serverside any ways. What is the nightlies patch and do you know where I can get it from?

I have a syntax error near 'fuel' but I cannot find it lol

  
dbFree ( dbQuery ( server,"CREATE TABLE IF NOT EXISTS newTable ( vehicleID, model, posX, posY, posZ, rotX, rotY, rotZ, interior,respawnPosX, respawnPosY, respawnPosZ, respawnRotX, respawnRotY, respawnRotZ, respawnInterior, respawn, Dimension, numberplate, health, color1, color2, characterID, engineState, locked, lightsState, tintedWindows, fuel")) 
  

dbFree ( dbQuery ( server,"CREATE TABLE IF NOT EXISTS newTable ( vehicleID, model, posX, posY, posZ, rotX, rotY, rotZ, interior,respawnPosX, respawnPosY, respawnPosZ, respawnRotX, respawnRotY, respawnRotZ, respawnInterior, respawn, Dimension, numberplate, health, color1, color2, characterID, engineState, locked, lightsState, tintedWindows, fuel )")) 

Try this. Not sure

Also.. In order to execute these db-functions you need either 1.1 with latest patch (https://nightly.multitheftauto.com) or MTA 1.2

If you don't have these then your MTA server will most likely not have the functions built-in so they will return nil when called

About meta.xml, if you don't define server/client types then it indeed defaults to server

Posted

Thank you now it says error:call to none-running server resource (sql) string??

Forget to mention am on the MTA 1.2 and I don't know where on the site the patch is.

  
if exports.sql:query_free( "UPDATE vehicles SET characterID = " .. -faction .. " WHERE vehicleID = " .. data.vehicleID ) then 
  
  

Posted

Do you have a resource called 'sql' running?

I guess it should be:

if dbFree ( dbQuery ( server, "UPDATE vehicles SET characterID = " .. faction .. " WHERE vehicleID = " .. data.vehicleID )) then 

Posted
Do you have a resource called 'sql' running?

I guess it should be:

if dbFree ( dbQuery ( server, "UPDATE vehicles SET characterID = " .. faction .. " WHERE vehicleID = " .. data.vehicleID )) then 

Sql as in for mysql?

if so then no i don't and your right ive corrected that and now the script builds the tables but i want to set the correct settings for the table for each such as autoincrement, num, text etc. but idk how to do that part whatsoever :(

Posted

You are already updating the sql table.

Be more specific about your problem.

Also, I would suggest you to use '?' instead of using the variables in the query string.

Ex:

if dbFree ( dbQuery ( server, "UPDATE vehicles SET characterID = ? WHERE vehicleID = ?"  , faction, data.vehicleID )) then 

Take a look here for more information: executeSQLQuery.

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