LonelyRoad Posted September 24, 2014 Share Posted September 24, 2014 So I have been out of the MTA scene for a while, but now I am back and looking to continue with work on my own gamemode. More to the point, the last time I did work on said gamemode the module was the only method of working with a MySQL database. Now, evidently, it is possible to use the native SQL functions instead, and I assume for many reasons it would be a good idea to convert my gamemode to using them instead. Anyway, more on to the point of my post... How can I actually change my scripts now, everything I've done was using functions from the module with a 'wrapper' resource to provide ability to do queries etc. Is there any updated wrapper that provides the same functionality but with the native SQL functions? (See old wrapper here) Link to comment
Callum Posted September 24, 2014 Share Posted September 24, 2014 Not sure how you can go about converting it, but here is a simple SQL 'wrapper' I created that provides 'query' and 'execute' functionality (the only two functions you really need). SQL.Connect needs to be called in order for the connection to be established. You can change the dbConnect arguments to change it to a MySQL database. Link to comment
LonelyRoad Posted September 24, 2014 Author Share Posted September 24, 2014 Calling SQL connect could be done onResourceStart (addEventHandler) right? Since you mention it, query and exec are the only two I am currently making use of, would you mind if I slightly modified your 'wrapper' and used it in my game mode? How should args be given to your functions? Link to comment
Callum Posted September 24, 2014 Share Posted September 24, 2014 Yeah, on line 7 just insert: addEventHandler("onResourceStart",resourceRoot,SQL.Connect) And sure, it is open source after all. Link to comment
LonelyRoad Posted September 24, 2014 Author Share Posted September 24, 2014 Callum: Please see italics text for edit in my previous post. Link to comment
Callum Posted September 24, 2014 Share Posted September 24, 2014 ( query, [arg1, arg2, ...] ) So, for example: SQL.Query("SELECT id FROM accounts WHERE username = ? LIMIT 1", username) 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