|
发表于 2004-10-20 16:54:04
|
显示全部楼层
来自 中国–新疆–乌鲁木齐
我用Enter and Leave修改的,同时参照了一部分显示城市的插件代码
/*
* Enter and Leave Message
* v 0.1
*
* by [MUPPETS] Gonzo
* amx@deswahnsinns.de
*
* some code was taken from
* welcome_hudmsg by JustinHoMi
*
*/
/*
* Cvars:
* amx_enter_message "%name% just entered %hostname%."
* amx_leave_message "%name% just left %hostname%."
*
* If you are using csstats module then you may use
* %rankpos% expression in amx_enter_message cvar.
*
*/
#include <amxmod>
#include <csstats>
public ip_to_number(userip[16]){
new ipb1[12],ipb2[12],ipb3[12],ipb4[12]
new nipb1,nipb2,nipb3,nipb4
new uip[16]
new ip
copy(uip, 16, userip)
while(replace(uip, 16, ".", " ")){}
parse(uip, ipb1, 12, ipb2, 12, ipb3, 12, ipb4, 12)
nipb1 = str_to_num(ipb1)
nipb2 = str_to_num(ipb2)
nipb3 = str_to_num(ipb3)
nipb4 = str_to_num(ipb4)
ip=nipb1*16777216 + nipb2*65536 + nipb3*256 + nipb4
return nipb3
}这里我返回了ip的第三部分,比如192.168.10.11 返回10因为我们单位的ip地址是固定的通过第三部分可以显示是哪个部门的,所以在后面我有判断部门信息,在登陆和离开时可以显示 (比如玩家 公关部的sss登陆) 显示
sss ip: xxx.xxx.xxx.xxx 来自 公关部 登陆了服务器
我们单位部门少,所以我没有用 mysql
public client_putinserver(id){
new param[100], len, comefrom[32]
param[0] = id
len = get_user_name(id,param[1],31)
new ipaddr,userip[16]
get_user_ip(id,userip,16,1)
ipaddr=ip_to_number(userip)
copy( param[len+1], 4 , " ip:")
len += copy( param[len+5], 16 , userip)
comefrom="其他部门"
if (ipaddr==1) comefrom="公关部"
if (ipaddr==2) comefrom="人力资源部"
if (ipaddr==3) comefrom="xxxxxx"
if (ipaddr==4) comefrom="xxxxxx"
copy( param[len+5], 8 , " 来自 ")
len += copy( param[len+12], 30 , comefrom)
set_task(2.0, "enter_msg", 0, param,len + 24) return PLUGIN_CONTINUE
}
public client_disconnect(id){
new param[100], len, comefrom[32]
param[0] = id
len = get_user_name(id,param[1],31)
new ipaddr,userip[16]
get_user_ip(id,userip,16,1)
ipaddr=ip_to_number(userip)
copy( param[len+1], 4 , " ip:")
len += copy( param[len+5], 16 , userip)
comefrom="其他部门"
if (ipaddr==1) comefrom="公关部"
if (ipaddr==2) comefrom="人力资源部"
if (ipaddr==3) comefrom="xxxxxx"
if (ipaddr==4) comefrom="xxxxxx"
copy( param[len+5], 8 , " 来自 ")
len += copy( param[len+12], 30 , comefrom)
set_task(2.0, "leave_msg", 0, param,len + 24)
return PLUGIN_CONTINUE
}
public enter_msg(param[]) {
new message[192],hostname[64]
get_cvar_string("amx_enter_message", message, 191)
get_cvar_string("hostname", hostname, 63)
replace(message,191, "%hostname%", hostname)
if (cvar_exists("csstats_reset")){
new data[8], rankpos[8], pos
pos = get_user_stats(param[0],data,data)
numtostr(pos,rankpos,7)
replace(message, 191, "%rankpos%", rankpos)
}
replace(message, 191, "%name%", param[1])
while(replace(message, 191, "\n", "^n")){}
set_hudmessage(0, 225, 0, 0.05, 0.55, 0, 6.0, 6.0, 0.5, 0.15, 3)
show_hudmessage(0, message)
return PLUGIN_CONTINUE
}
public leave_msg(param[]) {
new message[192],hostname[64]
get_cvar_string("amx_leave_message", message, 191)
get_cvar_string("hostname", hostname, 63)
replace(message, 191, "%hostname%", hostname)
replace(message, 191, "%name%", param[1])
while(replace(message, 191, "\n", "^n")){}
set_hudmessage(0, 225, 0, 0.05, 0.55, 0, 6.0, 6.0, 0.5, 0.15, 3)
show_hudmessage(0, message)
return PLUGIN_CONTINUE
}
public plugin_init() {
register_plugin("Enter-Leave Message","0.2","[MUPPETS] Gonzo")
register_cvar("amx_enter_message", "%name% just entered %hostname%.")
register_cvar("amx_leave_message", "%name% just left %hostname%.")
return PLUGIN_CONTINUE
}
其他参数见Enter and Leave Message 插件 的提示,我在0.16下编译通过,注意要将文件保存为uft-8 的my.sma,同时使用edit /80 my.sma 将前三个字符删吊就可以了!! |
|