Smarting Posted December 6, 2018 Share Posted December 6, 2018 Hello everyone, i have a problem. I am not lua scripter, but somehow i managed to get trough some other errors, but this one is not understandable for me. addEvent("acc:onPlayerSubmit", true) addEventHandler("acc:onPlayerSubmit", getRootElement(), function(username, pass, op, remember, autologin, email) if client then local ip, serial = getPlayerIP(client), getPlayerSerial(client) if op == 0 then --Logging in dbQuery(handlePlayerLogin, {client, username, pass, ip, serial, remember, autologin}, connection, "SELECT * FROM `accounts` WHERE username = ?", username) elseif op == 1 then --Registering if isValidEmail(email) then dbQuery(handlePlayerRegister, {client, username, pass, email, ip, serial, remember}, connection, "SELECT username FROM `accounts` WHERE username = ? OR email = ?", username, email) else triggerClientEvent(client, "acc:onSubmitFail", client, "Disposable emails are not allowed. Please use another email provider.") end end end end) Error code : WARNING: account-manager/s_accounts.lua:209: Bad argument @ 'dbQuery' [Expected db-connection at argument 1, got nil] Thanks! :) Link to comment
Moderators IIYAMA Posted December 6, 2018 Moderators Share Posted December 6, 2018 It means that the connection to the database has been failed. This connection is used for the code and the database to be able to communicate with each other. In your code you should be looking for this function: dbConnect https://wiki.multitheftauto.com/wiki/DbConnect That is where the real problem starts. You have either received an error about the dbConnect function or the dbConnect function has never been called. Link to comment
Smarting Posted December 7, 2018 Author Share Posted December 7, 2018 20 hours ago, IIYAMA said: It means that the connection to the database has been failed. This connection is used for the code and the database to be able to communicate with each other. In your code you should be looking for this function: dbConnect https://wiki.multitheftauto.com/wiki/DbConnect That is where the real problem starts. You have either received an error about the dbConnect function or the dbConnect function has never been called. It has to be in the same file? or it can be in other file, cause in this file i did not find dbConnect. Can i ask you show some kinda example? How to make connection? And if in other file there is that connection, and if i add in other file same connection, is it slowing down server? Like example: In this code i add dbConnect with details, and in other file is the same dbConnect, is it going to slow down system. Link to comment
Moderators IIYAMA Posted December 7, 2018 Moderators Share Posted December 7, 2018 It can be in another file but it has to be in the same resource. Making a connection just with a new + empty database will not solve your problem. Containers(tables) for the data have be generated before you can store or load data. If the connection function isn't in any of the files + there are no tables in the database, then it is recommended to consider it unfixable in case of not going to hire a paid scripter. Link to comment
Dimos7 Posted December 8, 2018 Share Posted December 8, 2018 (edited) You can have a global database and resource conect it but you need to expprt the function to this resource ofc that is example you need table etc for working correct function connectToDatabase() connection =dbConnect("sqlite", ":/global.db") end addEventHandler("onResourceStart", resourceRoot, connectToDatabase) function getConnection () return connection end Edited December 8, 2018 by Dimos7 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