DerekSP Posted April 10, 2019 Share Posted April 10, 2019 Hello. I have been following a youtube tutorial about MTA coding, and I got to the point where I want to set up a database of parked cars. I have a /park command that is supposed to write the position and direction of the vehicle a player is in to "vehicles" table in global.db Here's the code: function parkVehicle(player, command, model) local playerVehicle = getPedOccupiedVehicle(player) local db = exports.db:getConnection() if playerVehicle then local x, y, z = getElementPosition(playerVehicle) local d, e, f = getElementRotation(playerVehicle) dbExec(db, 'INSERT INTO vehicles (model, x, y, z, d) VALUES (?, ?, ?, ?, ?)', model, x, y, z, d) outputChatBox("Vehicle parked") else outputChatBox("You are not in a vehicle") end end addCommandHandler('park', parkVehicle, false, false) The youtube tutorial had this done automatically upon spawning of the vehicle, but I wanted to split it into two commands, but seems like I failed somewhere. Please, I need any help. I have been checking the code, comparing it to the tutorial, and everything seems like it should work just fine... Link to comment
Dimos7 Posted April 10, 2019 Share Posted April 10, 2019 1)Make sure that the resource has the database is running 2)Make sure you have in meta file write the export function correct and type server 3) Use /debugscipt 3 see errors or warnings that script have Link to comment
Gordon_G Posted April 10, 2019 Share Posted April 10, 2019 (edited) I can see that you use the "db" resource by exporting, is the function in this resource returning the dbConnection ? Edited April 10, 2019 by Gordon_G 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