设为首页收藏本站新闻投稿

MOD中国同盟社

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2886|回复: 11

MySQL Files for AMX Mod X   [复制链接]

Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20

帖子
2836
精华
2
声望
12984 点
金币
2999 Mold
被赞许
28 次
注册时间
2006-4-28

Mod中国同盟社至高荣誉

发表于 2010-8-11 22:50:20 |显示全部楼层
From:https://forums.alliedmods.net/archive/index.php/t-7786.html


Hi, I've been using the script below for alot of time, both for AMX amd AMXX - originally developed by NoPlay and slightly modified by my self for supporting multiple servers and suiting my needs.

To night i wanted to start upgrading my servers for version 1.0 of AMXX, but this very important plugin to me doesn't work after being compiled for AMXX.
Since it's a very small plugin i asumed that it wouldn't be hard for an expirienced small programmer to correct it or make an alternative, so therefore i guessed it would be worth a shot posting it here.


/* AMX Mod script.
*
* (c) Copyright 2002, Noplay
* This file is provided as is (no warranties).
*
*/
/*
This AMX plugin requires MySQL MetaSmall module.
For the plugin to work, you need the MySQL table, it can be created with this SQL query:
  1. CREATE TABLE `amx_files` (
  2. `id` int(11) NOT NULL auto_increment,
  3. `serverid` int(11) NOT NULL default '0',
  4. `file` varchar(100) NOT NULL default '',
  5. `content` mediumtext NOT NULL,
  6. PRIMARY KEY (`id`)
  7. ) TYPE=MyISAM;
复制代码
To configure your MySQL informations, go to the addons/amx/mysql.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).

OBS!
This plugin was original developed by NoPlay, and re-written for multiply server support by FeliX.
Thanks to GeekGod for help.
*/
  1. #include <amxmod>
  2. #include <mysql>
  3. public load_files()
  4. {
  5. new mysql,cnt
  6. new file[65]
  7. new content[3025]
  8. new error[257]
  9. new host[65]
  10. new user[33]
  11. new pass[33]
  12. new db[33]
  13. // GG
  14. new string[98]

  15. get_cvar_string("amx_mysql_host",host,64)
  16. get_cvar_string("amx_mysql_user",user,32)
  17. get_cvar_string("amx_mysql_pass",pass,32)
  18. get_cvar_string("amx_mysql_db",db,32)

  19. mysql = mysql_connect(host,user,pass,db,error,256)
  20. if(mysql>0)
  21. {
  22. format(string,98,"SELECT file,content FROM amx_files where serverid = 0 or serverid = %d order by serverid ASC",get_cvar_num("amx_serverid"))
  23. if(mysql_query(mysql,string) >0)
  24. {
  25. cnt = 0
  26. while(mysql_nextrow(mysql)>0)
  27. {
  28. mysql_getfield(mysql,1,file,32)
  29. mysql_getfield(mysql,2,content,3024)

  30. delete_file(file)
  31. write_file(file,content);

  32. cnt++
  33. }
  34. server_print("[AMX] Loaded %d file(s) from database",cnt)
  35. }
  36. else
  37. {
  38. mysql_error(mysql,error,32)
  39. server_print("[AMX] MySQL error : could not load file : '%s'",error)
  40. }
  41. mysql_close(mysql)
  42. }
  43. else
  44. {
  45. server_print("[AMX] MySQL error : could not connect : '%s'",error)
  46. }
  47. return PLUGIN_HANDLED
  48. }
  49. public plugin_init()
  50. {
  51. register_plugin("MySQL Files","2","NoPlay")
  52. register_cvar("amx_mysql_host","127.0.0.1")
  53. register_cvar("amx_mysql_user","root")
  54. register_cvar("amx_mysql_pass","")
  55. register_cvar("amx_mysql_db","amx")
  56. register_cvar("amx_serverid","1")
  57. set_task(5.0,"load_files")
  58. server_cmd("exec server.cfg")
  59. return PLUGIN_CONTINUE
  60. }
复制代码
When running it on my AMX Mod X based server I'm getting a fatal error causing the server to crash:


L 11/21/2004 - 23:17:25: [AMXX] Run time error 10 (native) (plugin "mysql_files.amxx") - debug not enabled.
L 11/21/2004 - 23:17:25: [MySQL] Unknown error
L 11/21/2004 - 23:17:25: [AMXX] To enable debug mode, add " debug" after the plugin name in plugins.ini (without quotes).
L 11/21/2004 - 23:17:25: [AMXX] Run time error 10 (native) (plugin "mysql_files.amxx") - debug not enabled.
L 11/21/2004 - 23:17:25: [AMXX] To enable debug mode, add " debug" after the plugin name in plugins.ini (without quotes).
/home/gameserver/cs01/hlds_run: line 57: 8763 Segmentation fault $HL_CMD
Add "-debug" to the /home/gameserver/cs01/hlds_run command line to generate a debug.log to help with solving this problem
Sun Nov 21 23:17:25 CET 2004: Server restart in 10 seconds
Sun Nov 21 23:17:31 CET 2004: Server Quit


I hope that someone has got the time and perhaps the needs to do this
Thank you.

使用道具 举报

Rank: 8Rank: 8

帖子
1304
精华
3
声望
2290 点
金币
1140 Mold
被赞许
20 次
注册时间
2009-11-28
发表于 2010-8-11 23:11:36 |显示全部楼层
本帖最后由 zz350z 于 2010-8-11 23:12 编辑

晕··这是啥,英文看不懂···
半夜来做沙发- -!
竭诚为MODCHINA服务!!

使用道具 举报

Developers

渣一样的潜水党

Rank: 8Rank: 8

帖子
648
精华
3
声望
4468 点
金币
1260 Mold
被赞许
33 次
注册时间
2009-6-24

黑暗使者

发表于 2010-8-11 23:16:03 |显示全部楼层
沙发没了,板凳继续,话说这个是和插件有关的东西吧~马勺

使用道具 举报

Rank: 5Rank: 5

帖子
575
精华
0
声望
850 点
金币
243 Mold
被赞许
0 次
注册时间
2009-8-30
发表于 2010-8-12 00:19:19 |显示全部楼层
汗 全英文 只有用谷歌了

使用道具 举报

Rank: 3Rank: 3

帖子
337
精华
0
声望
684 点
金币
71 Mold
被赞许
0 次
注册时间
2010-7-5
发表于 2010-8-12 00:55:34 |显示全部楼层
要看好久喔!!
不看了啦!!!
我来去睡觉!!
还好论坛不用维修!!

使用道具 举报

Rank: 10Rank: 10Rank: 10

帖子
4597
精华
3
声望
9452 点
金币
26 Mold
被赞许
115 次
注册时间
2009-10-18

MTT职员 最佳贡献奖 热心会员奖 可爱小猫 黑暗使者 Modchina元老 Modchina灌水王 星界财团 图界之神

发表于 2010-8-12 15:15:21 |显示全部楼层
空间终于开哦、

使用道具 举报

Super Moderator

电影CG行业领军

Rank: 10Rank: 10Rank: 10

帖子
3015
精华
2
声望
12931 点
金币
2650 Mold
被赞许
26 次
注册时间
2009-12-14

图界之神 黑暗使者 Modchina灌水王 可爱小猫 星界财团 懒人勋章

发表于 2010-8-12 20:44:42 |显示全部楼层
这个板块貌似是针对外国朋友的

使用道具 举报

Rank: 3Rank: 3

帖子
207
精华
0
声望
820 点
金币
335 Mold
被赞许
0 次
注册时间
2009-5-23
发表于 2010-8-15 10:38:17 |显示全部楼层

英文版!
不错的说!~~

使用道具 举报

Rank: 7Rank: 7Rank: 7

帖子
605
精华
0
声望
2162 点
金币
330 Mold
被赞许
0 次
注册时间
2009-11-6
发表于 2010-8-16 14:48:01 |显示全部楼层
完全看不懂的說...

使用道具 举报

Rank: 10Rank: 10Rank: 10

帖子
3735
精华
1
声望
5900 点
金币
2148 Mold
被赞许
47 次
注册时间
2009-12-20

优秀版主奖 Modchina灌水王 星界财团 可爱小猫

发表于 2010-8-16 20:18:36 |显示全部楼层
Marshal V5!!!
至于你信不信,我反正信了

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

回顶部