Austrothalik Posted February 24, 2021 Share Posted February 24, 2021 Hi, im new to .lua and scripting but i already work with sql and other languages I am creating a script and I need to store data in a database. Now I manually create a database in the database folder and create a resource to connect with that database that I created manually. That way when i give my resource to someone it does not work because the other user does not have the database created etc. Or he will need my database exclusive resource too. I would like to know how to use the mta default database (i already check the database wiki, i know they exist but i dont know how to use or call them), that way I would create the table there with <executeSQLCreateTable> and be able to make my resource work on other servers. My english and pessimo please be patient and help me. If you all help me to make this work creating a table, so i think i can manage with the rest --CREATE BLIP function CreateBlip(player,command,icon,name) local db = exports.db:getConnection() local x, y, z = getElementPosition(player) y = y + 5 dbExec(db, 'INSERT INTO blips (x, y, z, icon, name) VALUES (?,?,?,?,?)',x,y,z,icon,name) createBlip(x,y,z,icon) end addCommandHandler('createBlip', CreateBlip, false,false) --------------------------------------------------------------------------------------------------- samething like this maybe --CREATE TABLE ------------------------------------------------------------------ function createSQLOnStart () -- create our table, if it doesn't already exist executeSQLCreateTable ( "blips", "id INT, x INT, y INT, z INT, icon INT, name TEXT" ) end addEventHandler ( "onResourceStart", getResourceRootElement(),createSQLOnStart ) --CREATE BLIP function CreateBlip(player,command,icon,name) --ignore this line---local db = exports.db:getConnection() (i was using this to connect the database that i create) local x, y, z = getElementPosition(player) y = y + 5 dbExec(db, 'INSERT INTO blips (x, y, z, icon, name) VALUES (?,?,?,?,?)',x,y,z,icon,name) createBlip(x,y,z,icon) end addCommandHandler('createBlip', CreateBlip, false,false) --------------------------------------------------------------------------------------------------- if someone already has experience and is willing to help me with these basic doubts, please leave the disagreement below 2 minutes ago, Austrothalik said: disagreement discord** Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now