Raised This Month: $ Target: $400
 0% 

[DB] Database Manager


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 08-25-2007 , 17:18   [DB] Database Manager
Reply With Quote #1

Database manager

Description:
Different plugins may require different tables to get user informations, like XP, level, money, kills, deaths and bla bla bla... This plugin/stock automatically select info from table, create columns where necessary and makes it easy for people that want to use the database

How it works
Database manager detects all columns from the sm_users. Plugins can enable,disable the selecting of each column, or create a new column if needed.

Cvars
  • sm_db_config (deafult: "default") - The connection DB manager will use
  • sm_db_persit (deafult: "1") - Set to true to use persistant connection
  • sm_db_autolite (deafult: "1") - If the DB does not exist, SQLite will be used

Installation:
  • MySQL
    First, go to the file addons\sourcemod\configs\databases.cfg , and edit the "default" connection to your needs, it shouldn't be complicated, It should end up looking something like this:
    PHP Code:
    "default"
        
    {
            
    "driver"        "default"
            "host"            "localhost"
            "database"        "sm"
            "user"            "root"
            "pass"            ""
            
    //"timeout"            "0"
            //"port"            "0"
        

    And the leave the plugin to do the rest
    -----------------------------------
  • SQLite
    Change the cvar sm_db_config to "storage-local"
    and make sure that in addons\sourcemod\configs\databases.cfg this exists:
    PHP Code:
        "storage-local"
        
    {
            
    "driver"            "sqlite"
            "database"            "sourcemod-local"
        

  • Put a_mysql.smx file into your /addons/sourcemod/plugins folder, you can easily get the a_mysql.smx file by clicking at "Get Plugin" at the end of this message


FAQ:
  • I am getting an error "Can't connect to local MySQL server through socket '/tmp/mysql.sock'"
    • If you have acess to root in your linux computer, execute this in shell "ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock"



Example
See next post

ChangeLog:
  • August 25, 2007
    • Initial Release
    • Fixed Float Adding
    • Started Lock tables
    • Removed all FastQueries
  • August 26, 2007
    • Removed all the connecting/disconecting
    • Added cvars
    • Made it a lot user to use
  • August 27, 2007
    • Added SQLite support
    • Started using atd_array, there is no more limits now
  • August 29, 2007
    • MAJOR UPDATE!
  • August 30, 2007
    • Fixed adt_size array bug
  • September 06, 2007
    • Added new cvar
  • September 15, 2007 (3.1)
    • Changed some "new" to "decl"
    • Removed some fail states
  • January 10, 2007 (4.0)
    • Now the plugin will story all data in 2 Adt arrays.
    • Fixed possible error of things
    • Changed the way the plugin saves data on the database.
    • Added some extra checks to prevent errors.
  • January 21, 2008
    • Data is now saved on every round start.

Notes:
Put the globaldb.inc in addons\sourcemod\scripting\include
Attached Files
File Type: sp Get Plugin or Get Source (a_mysql.sp - 3015 views - 30.8 KB)
File Type: inc globaldb.inc (2.2 KB, 1616 views)
File Type: sp Get Plugin or Get Source (a_mysql_beta.sp - 1978 views - 35.0 KB)
__________________
http://www.nican132.com
I require reputation!

Last edited by Nican; 03-23-2008 at 11:41. Reason: Update!
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:50.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode