|
发表于 2008-2-20 17:34:27
|
显示全部楼层
来自 中国–河北–张家口
回复: 求一个插件! 都进来看看.
/* AMX Mod X - Script
地图同步插件使用说明:
命令:
amx_addforwardmapserver <目标服务器地址> <目标服务器端口> <目标服务器rcon_password>
添加需要与此服务器地图同步的服务器的地址、端口和rcon_password,可以添加20个需要同步的服务器,如:
amx_addforwardmapserver "192.168.0.254" 27016 "123456"
使用时要注意:
1、目标服务器的地址、端口和rcon_password必须正确,并且rcon_password不能为空,否则将无法同步;
2、此插件只重试两次,所以需要保证网络情况良好,否则可能无法同步;
3、请保证此服务器上的地图在目标服务器上都有;
4、建议目标服务器的 mp_timelimit 为 0;
5、在 amxx.cfg 中使用 amx_addforwardmapserver 命令加上你需要同步的服务器,可以添加最多20个需要同步的服务器,一条 amx_addforwardmapserver 命令添加一个服务器;
6、此插件需要开启 sockets 模块,在 configs\modules.ini 里开启。
1.75以上版本能自动加载,不需要手工开启。
*/
#include <amxmodx>
#include <amxmisc>
#include <sockets>
#define QUERY_TIMEOUT 1.0
#define MAXSERVERCOUNT 20
new g_socket[MAXSERVERCOUNT], g_host[MAXSERVERCOUNT][64], g_port[MAXSERVERCOUNT], g_rcon_password[MAXSERVERCOUNT][32]
new g_ServerCount = 0
public plugin_init()
{
register_plugin("Forward Changelevel", "1.0", "Rulzy")
register_concmd("amx_addforwardmapserver", "cmdAddForwardMapServer", ADMIN_MAP, "<host> <port> <rcon_password>")
set_task(1.0, "send_challenge_rcon")
}
public send_challenge_rcon()
{
new Error
new text[22]
format(text, 21, "%c%c%c%cchallenge rcon^x0A^x00", 255, 255, 255, 255)
for(new i=0;i<g_ServerCount;i++)
{
g_socket = socket_open(g_host, g_port, SOCKET_UDP, Error)
if(g_socket>0 && Error==0)
{
socket_send2(g_socket, text, 20)
}
}
set_task(QUERY_TIMEOUT, "read_server_answer")
}
public read_server_answer()
{
new buffer[64], mapname[32], ID, text[128], nRcvLen
get_mapname(mapname, 31)
for(new i=0;i<g_ServerCount;i++)
{
if(g_socket>0)
{
if(socket_change(g_socket,1))
{
nRcvLen = socket_recv(g_socket, buffer, 63)
if(nRcvLen>19 && buffer[0]==-1 && buffer[1]==-1 && buffer[2]==-1 && buffer[3]==-1 && containi(buffer[4],"challenge rcon ")==0)
{
ID = str_to_num(buffer[19])
format(text, 127, "%c%c%c%crcon %d ^"%s^" changelevel %s^x00", 255, 255, 255, 255, ID, g_rcon_password, mapname)
socket_send2(g_socket, text, strlen(text)+1)
socket_close(g_socket)
}else{
socket_close(g_socket)
g_socket = 0
}
}else{
socket_close(g_socket)
g_socket = 0
}
}
}
set_task(20.0, "send_challenge_rcon2")
}
public send_challenge_rcon2()
{
new Error
new text[22]
format(text, 21, "%c%c%c%cchallenge rcon^x0A^x00", 255, 255, 255, 255)
for(new i=0;i<g_ServerCount;i++)
{
if(g_socket<=0)
{
g_socket = socket_open(g_host, g_port, SOCKET_UDP, Error)
if(g_socket>0 && Error==0)
{
socket_send2(g_socket, text, 20)
}
}else{
g_socket = 0
}
}
set_task(QUERY_TIMEOUT, "read_server_answer2")
}
public read_server_answer2()
{
new buffer[64], mapname[32], ID, text[128], nRcvLen
get_mapname(mapname, 31)
for(new i=0;i<g_ServerCount;i++)
{
if(g_socket>0)
{
if(socket_change(g_socket,1))
{
nRcvLen = socket_recv(g_socket, buffer, 63)
if(nRcvLen>19 && buffer[0]==-1 && buffer[1]==-1 && buffer[2]==-1 && buffer[3]==-1 && containi(buffer[4],"challenge rcon ")==0)
{
ID = str_to_num(buffer[19])
format(text, 127, "%c%c%c%crcon %d ^"%s^" changelevel %s^x00", 255, 255, 255, 255, ID, g_rcon_password, mapname)
socket_send2(g_socket, text, strlen(text)+1)
}
}
socket_close(g_socket)
}
}
}
public cmdAddForwardMapServer(id, level, cid)
{
if(!cmd_access(id, level, cid, 4))
return PLUGIN_HANDLED
if(g_ServerCount>=MAXSERVERCOUNT)
{
if(id==0)
server_print("Max Server Count Reached.")
else
client_print(id, print_chat, "Max Server Count Reached.")
return PLUGIN_HANDLED
}
read_argv(1, g_host[g_ServerCount], 63)
new sport[6]
read_argv(2, sport, 5)
g_port[g_ServerCount] = str_to_num(sport)
read_argv(3, g_rcon_password[g_ServerCount], 31)
g_ServerCount++
return PLUGIN_HANDLED
}
楼上的你最好别用弄了后让你的服务器是又跳PING又不稳定除非你服务器好网速好可以考虑我是用不起 |
|