ULX

Author Topic: Using Databases to store values such as money. (Tutorial Request)  (Read 3045 times)

0 Members and 1 Guest are viewing this topic.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Can some one make a good video tutorial about how to use databases to store values like money? (For both online and offline databases.)
I cry every time I see that I am not a respected member of this community.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Using Databases to store values such as money. (Tutorial Request)
« Reply #1 on: January 15, 2013, 12:28:36 AM »
Are you wanting to use the built in sv.db SQLite that is included in Gmod?

Or do you want something that you can tie into a website like MySQL?

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Using Databases to store values such as money. (Tutorial Request)
« Reply #2 on: January 15, 2013, 12:47:28 AM »
Are you wanting to use the built in sv.db SQLite that is included in Gmod?

Or do you want something that you can tie into a website like MySQL?

Well I would like to use the sv.db, because all I really need to do is store money (scores), ...and I don't feel like I need an online scoreboard.

---

But it really depends on what is better, I need to store players scores, perks, and inventory items.
« Last Edit: January 15, 2013, 12:49:50 AM by HeLLFox_15 »
I cry every time I see that I am not a respected member of this community.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Using Databases to store values such as money. (Tutorial Request)
« Reply #3 on: January 15, 2013, 05:07:13 AM »
I'm not sure if this is new to GM13 or not (I've never seen it...)

but it certainly looks promising..

wiki.garrysmod.com/page/Classes/Player/GetPData

Offline krooks

  • Sr. Member
  • ****
  • Posts: 382
  • Karma: 32
  • I don't like video games.
    • Diamond Krooks
Re: Using Databases to store values such as money. (Tutorial Request)
« Reply #4 on: January 15, 2013, 09:36:50 AM »
I was actually trying to do the same exact thing, I found this tutorial here: http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index69ca.html
and followed it, only changing some values like the name of the shop etc. but it wouldn't store the data, I'm wondering now if that's because the tutorial was for GM12.

There is also SetPData. My next question would be is, how do I create the "money" column? Would it auto create if I ran
player.GetByID( 1 ):SetPData( "money", 100 ) before trying to GetPData money?
« Last Edit: January 16, 2013, 02:37:58 PM by krooks »
My TTT server. Join the fun!

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Using Databases to store values such as money. (Tutorial Request)
« Reply #5 on: January 15, 2013, 03:19:45 PM »
Yes. You don't have to worry about setting anything up when using GetPData/SetPData. It will do all of the backend stuff for you.

Offline krooks

  • Sr. Member
  • ****
  • Posts: 382
  • Karma: 32
  • I don't like video games.
    • Diamond Krooks
Re: Using Databases to store values such as money. (Tutorial Request)
« Reply #6 on: January 16, 2013, 02:31:32 PM »
Great, thanks for the info -- I could see this file getting a bit messy/overloaded? Is there some way to clean it out without deleting it completely?

Maybe that doesn't even matter?
My TTT server. Join the fun!