Raised This Month: $32 Target: $400
 8% 

Mysql Files (NoPlay)


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Server Management        Approver:   BAILOPAN (72)
LoWe
Member
Join Date: Mar 2004
Old 11-25-2004 , 11:28   Mysql Files (NoPlay)
Reply With Quote #1

This plugin was original developed by NoPlay, and re-written for multiply server support by FeliX who thanks GeekGod for help.

If any of the above listed doesn't want me to develop the plugin or feels like they are the ones that should be developing this; feel free to send me an PM.

Code:
This plugin fetches the name of files and the content of each file from a
mysqlserver and then it creates the files on the server, all paths in the
filename is relative to the mod-directory.

The files are loaded at mapstart, or by the command:
amx_reloadfiles (require ADMIN_RCON access)

Currently, the maxlength of the content of the file is around: 3000 symbols and letters.

This AMXX plugin requires a dbi-module to be running and configured to use your mysqlserver.
To configure your MySQL information, go to the addons/amxmodx/configs/sql.cfg file and edit it.
Files specified with the serverid 0 will be loaded at all servers, files with a special serverid
will only be loaded at the servers configured with that serverid.
To set your servers serverid, type this in your server config:

amx_serverid X // Replace X with your servers id; eg. amx_serverid 1
amx_mysqlfiles_table "name" // Sets the name of the "files-table"; eg. amx_mysqlfiles_table "amx_files"

Version History:
:: 3.00
lowe took over the development
Updated for amxmodx 1.0
added amx_reloadfiles command
Changed the error handling code.
:: 3.01
Changed accesslevel to ADMIN_RCON, thanks to BigBaller and lantz69.
:: 3.10
improved the amx_reloadfiles a lot.
multilanguage support!
Fixed a error with sql-config execution
:: 3.20
You may now choice what name you want the "files-table" in the database to have by setting the amx_mysqlfiles_table cvar to the name of the table.
The "files-table" will be created automatically (if it doesnt exists), only thing you gotta do is adding "files" too it!
:: 3.21
Implementing changes suggested by [PUPPETS] Gonzo to allow bigger files.

Note's by FeliX:
This plugin was original developed by NoPlay, and re-written for multiply server support by FeliX. Thanks to GeekGod for help.
Note's by lowe:
I wish to thank the amxmodx developing team, I sometimes look in the admin.sma and admincmd.sma when i doesn't know how to do ;). I would also like to give credit to [PUPPETS] Gonzo for his changes that's implemented in 3.21.

Thanks to the translators:
FeliX
This plugin is currently translated to swedish, danish and english! If you want to, feel free to translate it to your language and post your translation here.
Attached Files
File Type: txt mysqlfiles.txt (816 Bytes, 914 views)
File Type: sma Get Plugin or Get Source (mysqlfiles.sma - 1473 views - 6.5 KB)

Last edited by LoWe; 09-17-2008 at 16:16. Reason: New version
LoWe is offline
Send a message via Skype™ to LoWe
lantz69
AMX Mod X Beta Tester
Join Date: Mar 2004
Location: Sweden, Skåne
Old 11-25-2004 , 13:42  
Reply With Quote #2

ADMIN_ADMIN doesn't work with amxmodx 1.0
You need to change that.
__________________
Using: Amxmodx 1.8.1.xxxx, cstrike
http://www.vanilla.se/
lantz69 is offline
BigBaller
Veteran Member
Join Date: Mar 2004
Location: Everett, WA
Old 11-25-2004 , 14:17  
Reply With Quote #3

you should problay change ADMIN_ADMIN to ADMIN_RCON or something.
__________________

BigBaller is offline
LoWe
Member
Join Date: Mar 2004
Old 11-25-2004 , 15:28  
Reply With Quote #4

But, its used in admincmd.sma ? I'll change it anyway; I know that there is a lack of information about it in users.ini.
LoWe is offline
Send a message via Skype™ to LoWe
FeliX
Junior Member
Join Date: Apr 2004
Old 11-25-2004 , 17:00  
Reply With Quote #5

Nice work - a MUST when running multiple servers
FeliX is offline
LoWe
Member
Join Date: Mar 2004
Old 11-26-2004 , 10:03  
Reply With Quote #6

New version released:
Code:
:: 3.10
improved the amx_reloadfiles a lot.
multilanguage support!
Fixed a error with sql-config execution
LoWe is offline
Send a message via Skype™ to LoWe
LoWe
Member
Join Date: Mar 2004
Old 11-29-2004 , 14:35  
Reply With Quote #7

Update
Code:
:: 3.20
You may now choice what name you want the "files-table" in the database to have by setting the amx_mysqlfiles_table cvar to the name of the table.
The "files-table" will be created automatically (if it doesnt exists), only thing you gotta do is adding "files" too it!
LoWe is offline
Send a message via Skype™ to LoWe
LoWe
Member
Join Date: Mar 2004
Old 11-29-2004 , 14:47  
Reply With Quote #8

BAILOPAN APPROVED IT!

LoWe is offline
Send a message via Skype™ to LoWe
LoWe
Member
Join Date: Mar 2004
Old 07-19-2005 , 12:26  
Reply With Quote #9

This plugin has an issue with big files. If a file is to big the server will crash at when it loads the files, ill try to find time to fix it.
Now fixed

Last edited by LoWe; 09-17-2008 at 16:18. Reason: Issue fixed
LoWe is offline
Send a message via Skype™ to LoWe
[Godmin] Gonzo
SourceMod Donor
Join Date: Jul 2004
Location: Godmins World
Old 09-08-2005 , 00:55  
Reply With Quote #10

Quote:
Originally Posted by LoWe
This plugin has an issue with big files. If a file is to big the server will crash at when it loads the files, ill try to find time to fix it.
Try this modifyed version:

Code:
/* AMX Mod X script. * * (c) Copyright 2002, Noplay * This file is provided as is (no warranties). * This plugin fetches the name of files and the content of each file from a mysqlserver and then it creates the files on the server, all paths in the filename isrelative to the mod-directory. The files are loaded at mapstart, or by the command: amx_reloadfiles (require ADMIN_RCON access) Currently, the maxlength of the content of the file is around: 3000 symbols and letters. This AMXX plugin requires a dbi-module to be running and configured to use your mysqlserver. To configure your MySQL information, go to the addons/amxmodx/configs/sql.cfg file and edit it. Files specified with the serverid 0 will be loaded at all servers, files with a special serverid will only be loaded at the servers configured with that serverid. To set your servers serverid, type this in your server config: amx_serverid X // Replace X with your servers id; eg. amx_serverid 1 amx_mysqlfiles_table "name" // Sets the name of the "files-table"; eg. amx_mysqlfiles_table "amx_files" Version History: :: 3.00 lowe took over the development Updated for amxmodx 1.0 added amx_reloadfiles command Changed the error handling code. :: 3.01 Changed accesslevel to ADMIN_RCON, thanks to BigBaller and lantz69. :: 3.10 improved the amx_reloadfiles a lot. multilanguage support! Fixed a error with sql-config execution :: 3.20 You may now choice what name you want the "files-table" in the database to have by setting the amx_mysqlfiles_table cvar to the name of the table. The "files-table" will be created automatically (if it doesnt exists), only thing you gotta do is adding "files" too it! Note's by FeliX: This plugin was original developed by NoPlay, and re-written for multiply server support by FeliX. Thanks to GeekGod for help. Note's by lowe: I wish to thank the amxmodx developing team, I sometimes look in the admin.sma and admincmd.sma when i doesn't know how to do ;) . Thanks to the translators: FeliX */ #include <amxmodx> #include <amxmisc> #include <dbi> #pragma dynamic 32768 public plugin_init() {     register_plugin("MySQL Files","3.20","NoPlay/FeliX/lowe")     register_dictionary("mysqlfiles.txt")     register_cvar("amx_sql_host","127.0.0.1")     register_cvar("amx_sql_user","root")     register_cvar("amx_sql_pass","")     register_cvar("amx_sql_db","amx")     register_cvar("amx_serverid","1")     register_cvar("amx_mysqlfiles_table","amx_files")     register_concmd("amx_reloadfiles","load_files",ADMIN_RCON," - Reloads all the textfiles from the mysql database.")     server_cmd("exec addons/amxmodx/configs/sql.cfg")     server_cmd("amx_reloadfiles")     server_cmd("exec server.cfg") } public plugin_modules() {     require_module("DBI") } public load_files(id,level,cid) {     if (!cmd_access(id,level,cid,0))         return PLUGIN_HANDLED     new Sql:SqLlink,cnt     new file[65]     new content[8193]     new error[257]     new host[65]     new user[33]     new pass[33]     new db[33]     new table[33]     new string[98]     get_cvar_string("amx_sql_host",host,64)     get_cvar_string("amx_sql_user",user,32)     get_cvar_string("amx_sql_pass",pass,32)     get_cvar_string("amx_sql_db",db,32)     get_cvar_string("amx_mysqlfiles_table",table,32)     SqLlink = dbi_connect(host,user,pass,db,error,256)     if(SqLlink <= SQL_FAILED)     {         if (!id)         {             server_print("[Mysql Files] %L",LANG_SERVER,"SQL_ERROR",error)         }         else         {             client_print(id,print_console,"[Mysql Files] %L",LANG_PLAYER,"SQL_ERROR",error)         }     }     else     {         dbi_query(SqLlink,"CREATE TABLE IF NOT EXISTS `%s` ( `id` int(11) NOT NULL auto_increment, `serverid` int(11) NOT NULL default '0', `file` varchar(64) NOT NULL default '', `content` text NOT NULL, PRIMARY KEY  (`id`) ) COMMENT = 'AMX Mod X Configuration Files' TYPE=MyISAM",table)         format(string,98,"SELECT file,content FROM %s where serverid = '0' OR serverid = '%d' order by serverid ASC",table,get_cvar_num("amx_serverid"))         new Result:Res = dbi_query(SqLlink,string)         if (Res == RESULT_FAILED || Res == RESULT_NONE)         {             if (dbi_error(SqLlink,error,256))             {                 if (!id)                 {                     server_print("[Mysql Files] %L",LANG_SERVER,"SQL_ERROR",error)                 }                 else                 {                     client_print(id,print_console,"[Mysql Files] %L",LANG_PLAYER,"SQL_ERROR",error)                 }             }             else             {                 if (!id)                 {                     server_print("[Mysql Files] %L",LANG_SERVER,"NO_FILES")                 }                 else                 {                     client_print(id,print_console,"[Mysql Files] %L",LANG_PLAYER,"NO_FILES")                 }             }         }         else         {             cnt = 0             while( dbi_nextrow(Res) > 0)             {                 dbi_result(Res, "file",file,32)                 dbi_result(Res,"content",content,8192)                 if (file_exists(file) && !(delete_file(file)))                 {                     if (!id)                     {                         server_print("[Mysql Files] %L",LANG_SERVER,"DELETE_ERROR",file)                     }                     else                     {                         client_print(id,print_console,"[Mysql Files] %L",LANG_PLAYER,"DELETE_ERROR",file)                     }                     cnt--                 }                 else                 {                     if (!(write_file(file,content)))                     {                         if (!id)                         {                             server_print("[Mysql Files] %L",LANG_SERVER,"WRITE_ERROR",file)                         }                         else                         {                             client_print(id,print_console,"[Mysql Files] %L",LANG_PLAYER,"WRITE_ERROR",file)                         }                     }                 }                 cnt++             }             if (!id)             {                 server_print("[Mysql Files] %L",LANG_SERVER,"LOADED_NUM_FILES",cnt)             }             else             {                 client_print(id,print_console,"[Mysql Files] %L",LANG_PLAYER,"LOADED_NUM_FILES",cnt)             }         }         dbi_free_result(Res)         dbi_close(SqLlink)     }     return PLUGIN_HANDLED }

Note the bigger array/string sizes and #pragma dynamic 32768

Works fine for my server(s) now. Great Plugin, thanks a lot!
__________________
[Godmin] Gonzo is offline
Send a message via ICQ to [Godmin] Gonzo
Reply



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 23:40.


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