Dhud message for spectator and player

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
282
Реакции
34
Помог
3 раз(а)
Hi,

I would like to create dhud message for killer and spectator of the killer, so both can see the same message.
Here below is the code:
Код:
    set_hudmessage(242, 228, 94, 0.55, 0.42, 0, 0.0, 1.5, 0.0, 1.0);
    show_dhudmessage(UserId, "%L", UserId, "VAMPIRE_HEALTH_MESSAGE", VampHealth);
I've wrote it instead center message and it works but just for killer. What should I do so even spectator of the player can see it?

Thank you very much !
 
Сообщения
1,082
Реакции
58
Помог
11 раз(а)
Записать нужные нам индексы и через цикл показать сообщение
 
Сообщения
282
Реакции
34
Помог
3 раз(а)
Here is whole plugin
Код:
#include <amxmodx>
#include <reapi>
#include <VipModular>
#include "VipM/Utils"

#pragma semicolon 1
#pragma compress 1

public stock const PluginName[] = "[VipM][M] Vampire";
public stock const PluginVersion[] = _VIPM_VERSION;
public stock const PluginAuthor[] = "ArKaNeMaN";
public stock const PluginURL[] = _VIPM_PLUGIN_URL;
public stock const PluginDescription[] = "Vip modular`s module - Vampire";

new const MODULE_NAME[] = "Vampire";

public VipM_OnInitModules(){
    RegisterPluginByVars();
    register_dictionary("VipM-Vampire.ini");

    VipM_Modules_Register(MODULE_NAME, true);
    VipM_Modules_AddParams(MODULE_NAME,
        "MaxHealth", ptInteger, false,
        "ByKill", ptInteger, false,
        "ByHead", ptInteger, false,
        "ByKnife", ptInteger, false
    );
    VipM_Modules_AddParams(MODULE_NAME,
        "Limits", ptLimits, false
    );
    VipM_Modules_RegisterEvent(MODULE_NAME, Module_OnActivated, "@Event_ModuleActivate");
}

@Event_ModuleActivate(){
    RegisterHookChain(RG_CBasePlayer_Killed, "@Event_PlayerKilled", true);
}

@Event_PlayerKilled(const VictimId, UserId, InflictorId){
    if (
        UserId == VictimId
        || !is_user_alive(UserId)
        || !is_user_connected(VictimId)
    ) {
        return;
    }

    new Trie:Params = VipM_Modules_GetParams(MODULE_NAME, UserId);
    if (Params == Invalid_Trie) {
        return;
    }

    if (!VipM_Limits_ExecuteList(VipM_Params_GetCell(Params, "Limits", Invalid_Array), UserId)) {
        return;
    }

    new MaxHealth = VipM_Params_GetInt(Params, "MaxHealth", 100);
    new Health = floatround(get_entvar(UserId, var_health));
    if (Health >= MaxHealth) {
        return;
    }
    
    new ByKill = VipM_Params_GetInt(Params, "ByKill", 0);
    new VampHealth = 0;
    new ActiveItem; ActiveItem = get_member(UserId, m_pActiveItem);
    if (
        !(get_member(VictimId, m_bitsDamageType) & DMG_SLASH)
        && is_entity(ActiveItem)
        && rg_get_iteminfo(ActiveItem, ItemInfo_iId) == CSW_KNIFE
    ) {
        VampHealth = VipM_Params_GetInt(Params, "ByKnife", ByKill);
    } else if(get_member(VictimId, m_bHeadshotKilled)) {
        VampHealth = VipM_Params_GetInt(Params, "ByHead", ByKill);
    } else {
        VampHealth = ByKill;
    }

    //client_print(UserId, print_center, "%L", UserId, "VAMPIRE_HEALTH_MESSAGE", VampHealth);
    set_hudmessage(242, 228, 94, 0.55, 0.42, 0, 0.0, 1.5, 0.0, 1.0);
    show_dhudmessage(UserId, "%L", UserId, "VAMPIRE_HEALTH_MESSAGE", VampHealth);
    Health = clamp(Health + VampHealth, 1, MaxHealth < 1 ? cellmax : MaxHealth);
    set_entvar(UserId, var_health, float(Health));
}

I've changed just that parameter because people think it's end of the round when they get HP :D
 
Сообщения
494
Реакции
341
Помог
11 раз(а)
Try.
Код:
#include <amxmodx>
#include <reapi>
#include <VipModular>
#include "VipM/Utils"

#pragma semicolon 1
#pragma compress 1

public stock const PluginName[] = "[VipM][M] Vampire";
public stock const PluginVersion[] = _VIPM_VERSION;
public stock const PluginAuthor[] = "ArKaNeMaN";
public stock const PluginURL[] = _VIPM_PLUGIN_URL;
public stock const PluginDescription[] = "Vip modular`s module - Vampire";

new const MODULE_NAME[] = "Vampire";

public VipM_OnInitModules(){
    RegisterPluginByVars();
    register_dictionary("VipM-Vampire.ini");

    VipM_Modules_Register(MODULE_NAME, true);
    VipM_Modules_AddParams(MODULE_NAME,
        "MaxHealth", ptInteger, false,
        "ByKill", ptInteger, false,
        "ByHead", ptInteger, false,
        "ByKnife", ptInteger, false
    );
    VipM_Modules_AddParams(MODULE_NAME,
        "Limits", ptLimits, false
    );
    VipM_Modules_RegisterEvent(MODULE_NAME, Module_OnActivated, "@Event_ModuleActivate");
}

@Event_ModuleActivate(){
    RegisterHookChain(RG_CBasePlayer_Killed, "@Event_PlayerKilled", true);
}

@Event_PlayerKilled(const VictimId, UserId, InflictorId){
    if (
        UserId == VictimId
        || !is_user_alive(UserId)
        || !is_user_connected(VictimId)
    ) {
        return;
    }

    new Trie:Params = VipM_Modules_GetParams(MODULE_NAME, UserId);
    if (Params == Invalid_Trie) {
        return;
    }

    if (!VipM_Limits_ExecuteList(VipM_Params_GetCell(Params, "Limits", Invalid_Array), UserId)) {
        return;
    }

    new MaxHealth = VipM_Params_GetInt(Params, "MaxHealth", 100);
    new Health = floatround(get_entvar(UserId, var_health));
    if (Health >= MaxHealth) {
        return;
    }
   
    new ByKill = VipM_Params_GetInt(Params, "ByKill", 0);
    new VampHealth = 0;
    new ActiveItem; ActiveItem = get_member(UserId, m_pActiveItem);
    if (
        !(get_member(VictimId, m_bitsDamageType) & DMG_SLASH)
        && is_entity(ActiveItem)
        && rg_get_iteminfo(ActiveItem, ItemInfo_iId) == CSW_KNIFE
    ) {
        VampHealth = VipM_Params_GetInt(Params, "ByKnife", ByKill);
    } else if(get_member(VictimId, m_bHeadshotKilled)) {
        VampHealth = VipM_Params_GetInt(Params, "ByHead", ByKill);
    } else {
        VampHealth = ByKill;
    }

    set_hudmessage(242, 228, 94, 0.55, 0.42, 0, 0.0, 1.5, 0.0, 1.0);
    show_dhudmessage(UserId, "%L", UserId, "VAMPIRE_HEALTH_MESSAGE", VampHealth);

    new
        pPlayers[MAX_PLAYERS],
        iPlayersCount;

    get_players(pPlayers, iPlayersCount, "bch");

    for(new i, pObserver; i < iPlayersCount; i++)
    {
        pObserver = pPlayers[i];

        if(UserId == get_member(pObserver, m_hObserverTarget))
            show_dhudmessage(pObserver, "%L", pObserver, "VAMPIRE_HEALTH_MESSAGE", VampHealth);
    }

    Health = clamp(Health + VampHealth, 1, MaxHealth < 1 ? cellmax : MaxHealth);
    set_entvar(UserId, var_health, float(Health));
}
 
Сообщения
282
Реакции
34
Помог
3 раз(а)
bizon it works like charm !
Thank you very much !

The topic can be closed.
 
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу