AMXX 死亡事件 DeathEvent


"a" - 全局事件。

“b” - 指定。

"c" - 重复给其他玩家时只发送一次。

"d" - 如果发送给死玩家,则调用。

“e”——活着。

注册事件


#include

public plugin_init() {

register_event( "DeathMsg", "ev_DeathMsg", "a" )
//register_event_ex("DeathMsg", "ev_DeathMsg", RegisterEvent_Global )

}

public  ev_DeathMsg() {

//do something

}

参数获取


public ev_deathMsg() {

    new attacker = read_data( 1 )

    new Victim=read_data(2)

    new headshot=read_data(3)

    new weapon=read_data(4)

}

例子


#include <amxmodx>

public plugin_init() {

    register_event( "DeathMsg", "ev_DeathMsg", "a" )

}

public ev_DeathMsg() {

    new attacker = read_data( 1 )

    new Victim=read_data(2)

     new headshot=read_data(3)

    new weapon=read_data(4)



        if(!is_user_connected(attacker) || attacker == Victim) { //if attacker isn't connected stop the plugin

            return PLUGIN_HANDLED

        }

new victim_name[32] //this is just a variable,you can call whatever you want.

get_user_name(Victim,victim_name,31) *

new attacker_name[32]

get_user_name(attacker,attacker_name,31)



// new weapon[32]

//read_data( 4, weapon, sizeof( weapon ) -1 ) //but it isn't so important which method you will use.

if(headshot) *{

//Show to the attacker who player he killed.

client_print(attacker,print_chat,"You killed %s by hs",victim_name)

//Show to the victim who killed him:

client_print(Victim,print_chat,"You was killed by %s by hs",attacker_name)

}

else { //this is the normal kill

//Show to the attacker who player he killed.

client_print(attacker,print_chat,"You killed %s",victim_name)

//Show to the victim who killed him:

client_print(Victim,print_chat,"You was killed by %s",attacker_name)

}

//To understand how detect a kill from a weapon(like knife,awp,m4a1,etc) I'll make an example. This is for knife

if(weapon==CSW_KNIFE) {

client_print(attacker,print_chat,"You killed %s with knife",victim_name)

client_print(Victim,print_chat,"You was killed by %s with knife",attacker_name)

}

if(attacker == Victim) { //check if the attacker killed himself.

client_print(attacker,print_chat,"You killed himself")

}

return PLUGIN_CONTINUE;

}

修改玩家被杀武器图

register_message(get_user_msgid("DeathMsg"), "Message_DeathMsg");

public Message_DeathMsg(msg_id, msg_dest, id)
{
    static attacker, victim, weapon[24];
    
    attacker = read_data(1);
    victim = read_data(2);
    read_data(4, weapon, 23);

    if(!is_user_connected(attacker))
        return PLUGIN_CONTINUE
        
    if(equali(weapon, "aug") && g_user_has_[attacker]))
        set_msg_arg_string(4, "katana");

    return PLUGIN_CONTINUE
} 
//“aug”被“katana”取代。您还需要自己的自定义精灵并编辑cstrike/sprites文件夹中的hud.txt以使其正常工作...
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容