Jump to content

can someone explain SQL


papsmurfer

Recommended Posts

Hi I am new to scripting (who isn't right) but any way I was wondering if someone could take the time and throughly explain SQL scripting and how it works and the basics of saving, this can server two purposes, n00bs can be referred here and you guys won't have to repeats bits and parts of the same questions everyday and it will benifit the MTA community. So can someone really experianced please take the time to explain how it works and everything I know this is a huge favor to ask but if someone could do it I guarentee everyone will benifit from it

thanks for your replys!!!!

for example what do i use as a database????

Edited by Guest
Link to comment

This sounds like a pretty good idea, after all the reason why SA-MP is more popular than MTA because SA-MP has so many "for dummy" tutorials to walk you through everything and if MTA had stuff like that it would be 100 times better than SA-MP I mean the gameplay in MTA is better all around. I would take the time but I don't know much about SQL, sorry :(

Link to comment

Hi; just to break in a bit here: if there's anything in my tutorial that's "confusing", it'd be nice if you could tell me what it is, that way I can improve it.

Also, the basics of the SQL language are often the same across different implementations, so you could look at any SQL tutorial (this, for example. This is meant for websites, but as I said, the language and basic principles are the same) and still be able to use it here.

Link to comment
Hi; just to break in a bit here: if there's anything in my tutorial that's "confusing", it'd be nice if you could tell me what it is, that way I can improve it.

Also, the basics of the SQL language are often the same across different implementations, so you could look at any SQL tutorial (this, for example. This is meant for websites, but as I said, the language and basic principles are the same) and still be able to use it here.

Your tutorial is not confusing, reason I said that is becuase you expect the reader to have some knowledge when 80% of the time new users don't know anything and expect everything to be spoon fed to them, annoying I know but I am looking to boost the popularity of MTA and if that means I can scrap together a tutorial (with appropriate credits of course) that spoon feeds and gives them a feel of lua and basics of saving they can move on to bigger and better things and benifiting us all. We should stop helping individuals with problems a guy two days ago had and saying the same things you know what I mean?

Link to comment
Why not use account data? Learning SQL and Lua (and programming) all not going to make your life easy. Account data should do what you want.

https://wiki.multitheftauto.com/wiki/SetAccountData

yes but how can you use SetAccountData to save car you have purchased, the last position you were before you disconnected, or houses

Here is one, to save your position when you disconnect(i think setAccountData is only for logged in players)

--Save player's position on disconnect
--save pos
function savePos(quittype)
local x,y,z = getElementPosition(source)
local account = getPlayerAccount(source)
setAccountData(account, "player.posx", x)
setAccountData(account, "player.posy", y)
setAccountData(account, "player.posz", z)
end
addEventHandler("onPlayerQuit", getRootElement(), savePos)

then you can load it with getAccountData when the player logs in, or re-joins.

P.S. just a note i found about this on the wiki:

NOTE: Editing account data while the server is running currently deletes the account.

If it were me, i'd probably save it in an XML file, but I use mySQL and the mySQL plugin for MTA.

Link to comment

I'm 99% certain that note is referring to editing the file in a text editor, not using setAccountData. I've used account data several times and not lost any accounts.

https://wiki.multitheftauto.com/wiki/Ser ... _functions

There are several examples given in those SQL functions, and combined with the SQL Documentation, you should have no issues at all. It's how I learned to use MTA's SQLite.

Link to comment
  • 1 year later...

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