Jump to content

[Help] SQL With Lua.


Perfect

Recommended Posts

Posted

Hello, Recently I decided to learn SQLITE as i was running from it for many months.

I don't know how to connect lua with SQLITE.

Please tell me how to connect lua with SQLITE.

And If you can Please provide a simple example like storing player money etc....

Multi Theft Auto Player since middle of 2011.

Everybody want to act Crazy/Smart/Intelligent/Different/Unique/Innocent and Thats why I am Perfect.

Posted

well, everything can be found here; https://wiki.multitheftauto.com/wiki/ExecuteSQLQuery

here is a simple query to store money, not receiving it!

addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), 
    function () 
        executeSQLQuery ( "CREATE TABLE IF NOT EXISTS players (id INT, name TEXT, money INT)") 
    end 
); 
  
addCommandHandler ( "givemehmuniess", 
    function ( thePlayer ) 
        givePlayerMoney ( 200 ); 
        executeSQLQuery ( "INSERT INTO `players`(`name`,`money`) VALUES(?,?)", getPlayerName ( thePlayer ), getPlayerMoney ( thePlayer ) ); 
    end 
); 
  

logo-small.png?v=3 tiny-sapdfr.png

 

If you want to contact me directly concerning Advanced-Gaming, please contact me at [email protected]

Posted

Oh well, Thank you, i guess i understand something but with little confusion.

Can you Please tell me Where the table will create ? or it will create file.db in same resource and create table there ? How to create file.db ?

and this will work ? if negative then why ?

addEventHandler ( "onPlayerQuit", root, 
function () 
executeSQLQuery("SELECT money FROM players WHERE name=?", source) 
local nmoney = setPlayerMoney(source,players.money+100) 
executeSQLQuery("UPDATE players SET 'money' =? WHERE 'name'=?",nmoney,source) 
end) 
  

Multi Theft Auto Player since middle of 2011.

Everybody want to act Crazy/Smart/Intelligent/Different/Unique/Innocent and Thats why I am Perfect.

Posted

Well, I wanted give player money from table named 'players' and then save back again in table players in column named 'money'.

Multi Theft Auto Player since middle of 2011.

Everybody want to act Crazy/Smart/Intelligent/Different/Unique/Innocent and Thats why I am Perfect.

Posted
This might help.

SQL With Lua

Multi Theft Auto Player since middle of 2011.

Everybody want to act Crazy/Smart/Intelligent/Different/Unique/Innocent and Thats why I am Perfect.

Posted

You should learn the basics of SQL to start with mysql in lua.

B2T:

You need to have smth like a id/name in your database of your player to save the money to the specific player.

I'll write you smth when i got home.

Posted
You should learn the basics of SQL to start with mysql in lua.

B2T:

You need to have smth like a id/name in your database of your player to save the money to the specific player.

I'll write you smth when i got home.

Well, I mean i have learnt some basics of SQL and now wanna try them with lua.

Waiting for your post.

Multi Theft Auto Player since middle of 2011.

Everybody want to act Crazy/Smart/Intelligent/Different/Unique/Innocent and Thats why I am Perfect.

Posted

I already read JR10 Post but it didn't solve all my confusion, thats why i came here.

But your second thread did a good job, Thank You So Much.

Multi Theft Auto Player since middle of 2011.

Everybody want to act Crazy/Smart/Intelligent/Different/Unique/Innocent and Thats why I am Perfect.

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