- 听众
- 收听
- 积分
- 1181
- 主题
- 回帖
- 0
- 精华
注册时间2005-10-5
最后登录1970-1-1
该用户从未签到
|
发表于 2008-3-18 15:01:12
|
显示全部楼层
贴个 *.sma 源代码的!
- // original: SpecInfo v1.3.1 by Ian
- // 2008-03-18 Caffeine
- #include <amxmodx>
- #include <engine>
- #include <fakemeta>
- #define KEYS_STR_LEN 31
- #define LIST_STR_LEN 610
- #define BOTH_STR_LEN KEYS_STR_LEN + LIST_STR_LEN
- #define FL_KEYS ( 1 << 1 ) /* 观察模式看别人的按键 */
- #define FL_OWNKEYS ( 1 << 2 ) /* 看自己的按键 */
- // 按键字符变量
- new cl_keys[33], cl_prefs[33]
- new keys_string[33][KEYS_STR_LEN + 1]
- public plugin_init() {
- // 设置: 按Y,输入“/anjian”,调用 toggle_keys() 函数
- register_clcmd( "say /anjian", "toggle_keys");
- // 每0.1秒钟,执行一次 keys_update() 函数
- set_task(0.1, "keys_update", _, _, _, "b")
- return PLUGIN_CONTINUE
- }
- // 更新按键字符
- public keys_update() {
- new players[32], num, id, i
- get_players( players, num, "a" )
- for( i = 0; i < num; i++ ) {
- id = players[i]
- formatex( keys_string[id], KEYS_STR_LEN, " ^n^t^t%s^t^t^t%s^n^t%s %s %s^t^t%s",
- cl_keys[id] & IN_FORWARD ? "W" : " .", /* 若玩家按了“前W”键,则字符为“W”,否则字符为“.” */
- cl_keys[id] & IN_JUMP ? "跳" : " -",
- cl_keys[id] & IN_MOVELEFT ? "A" : ".",
- cl_keys[id] & IN_BACK ? "S" : ".",
- cl_keys[id] & IN_MOVERIGHT ? "D" : ".",
- cl_keys[id] & IN_DUCK ? "蹲" : " -" )
- cl_keys[id] = 0
- }
- new id2
- get_players( players, num, "ch" )
- for( i=0; i<num; i++ ) {
- id = players[i]
- if( is_user_alive( id ) ) {
- if( cl_prefs[id] & FL_OWNKEYS ) clmsg( id )
- }
- else{
- id2 = pev( id, pev_iuser2 )
- if( cl_prefs[id] & FL_KEYS && id2 && id2 != id ) clmsg( id )
- }
- }
- }
- // 获取当前服务器32位玩家的按键
- public server_frame( ) {
- new players[32], num, id
- get_players( players, num, "a" )
- for( new i = 0; i < num; i++ ) {
- id = players[i]
- if( get_user_button( id ) & IN_FORWARD )
- cl_keys[id] |= IN_FORWARD
- if( get_user_button( id ) & IN_BACK )
- cl_keys[id] |= IN_BACK
- if( get_user_button( id ) & IN_MOVELEFT )
- cl_keys[id] |= IN_MOVELEFT
- if( get_user_button( id ) & IN_MOVERIGHT )
- cl_keys[id] |= IN_MOVERIGHT
- if( get_user_button( id ) & IN_DUCK )
- cl_keys[id] |= IN_DUCK
- if( get_user_button( id ) & IN_JUMP )
- cl_keys[id] |= IN_JUMP
- }
- return PLUGIN_CONTINUE
- }
- // 显示出那些按键字符
- public clmsg( id ) {
- if( !id ) return
- new prefs = cl_prefs[id]
- // Red, Green, Blue, X, Y, Effects, Fxtime, HoldTime, Fadeintime, Fadeouttime, Channel
- set_hudmessage(45, 89, 116, 0.48, 0.14, 0, 0.0, 0.1, 0.1, 0.1, 3)
- new id2
- if( is_user_alive( id ) && prefs & FL_OWNKEYS ) id2 = id
- else id2 = pev( id, pev_iuser2 )
- if( !id2 ) return
- new msg[BOTH_STR_LEN + 1]
- msg ="^n^n^n^n^n^n^n^n^n^n^n^n"
- format( msg, BOTH_STR_LEN, "%s%s", msg, keys_string[id2][1] )
- show_hudmessage( id, msg )
- }
- //打开、隐藏按键显示
- public toggle_keys( id ) {
- cl_prefs[id] ^= FL_OWNKEYS
- cl_prefs[id] ^= FL_KEYS
- set_hudmessage(45, 89, 116, -1.0, 0.8, 0, 0.0, 2.0, 0.0, 0.0, 4)
- if(cl_prefs[id]==0) {
- show_hudmessage(id, "[KZCN] 已关闭按键显示!")
- }
- else{
- show_hudmessage(id, "[KZCN] 已开启按键显示!")
- }
- return PLUGIN_HANDLED
- }
复制代码
[ 本帖最后由 caffeine 于 2008-3-18 15:02 编辑 ] |
|