srcdslab / sm-plugin-BossHUD

Display health for boss and breakable entities
1 stars 4 forks source link

feature: show boss died like a player suicide #2

Open maxime1907 opened 1 year ago

maxime1907 commented 1 year ago

Would be nice if its possible to display the boss death to the upper right corner like a player suicide

Rushaway commented 1 year ago

Require to make it with a fakeclient. Idk how to do it properly without using fakeclient Do you have any idea?

maxime1907 commented 1 year ago

from zombiereloaded we do it this way but idk if its possible its just an idea that popped into my head

    g_hCvarsList.CVAR_INFECT_EVENT_WEAPON              =    CreateConVar("zr_infect_event_weapon",         "zombie_claws_of_death",            "Weapon icon used when the death event is sent for a player that gets infected.");

    // If attacker is valid, then continue.
    if (ZRIsClientValid(attacker))
    {
        // Create and send custom player_death event.
        Handle event = CreateEvent("player_death");
        if (event != INVALID_HANDLE)
        {
            char eventWeapon[MAX_EVENT_LENGTH];
            GetConVarString(g_hCvarsList.CVAR_INFECT_EVENT_WEAPON, eventWeapon, MAX_EVENT_LENGTH);
            SetEventInt(event, "userid", GetClientUserId(client));
            SetEventInt(event, "attacker", GetClientUserId(attacker));
            SetEventString(event, "weapon", eventWeapon);
            FireEvent(event, false);
        }

        // Apply score and health gain.
        InfectUpdateScore(attacker, client);
    }
Rushaway commented 3 months ago

I was able to create the event etc.. But the problem is the name of the boss. We cant set a name to it. https://wiki.alliedmods.net/Counter-Strike:_Source_Events#player_death An idea is to requiere SourceTV, to force the name change of it and use sourceTV as the victim (userid)

Side effect: Rename SourceTV can lead to unwanted issue with others plugins/exts who's already using SourceTV (ex rename sourcetv can break the demo irc)

maxime1907 commented 3 months ago

yeah touching sourcetv is just not recommended because it will conflict with other stuff

Rushaway commented 3 months ago

After hours of debugging, the problem with sourcetv who stop recording was due to :

Renaming the sourcetv does not make any problem and does not break anything even if it's recording (was tested aswell)

So I want to go with sourcetv for this feature, by just using SetClientName to the boss and right after the fake event was fired rename it back to original name.

Spoiler: I made it works like a charm with sourcetv.

I can also make it with FakeClients if the server does not have sourcetv, but for me this feature should only go with sourcetv enabled.

maxime1907 commented 3 months ago

lol nice one! cant wait to see this feature on our servers :smiley:

it makes me think about the record being stopped, could we do something to autofix it, in case anything bad happens ? (can we make a fix in autorecorder)

Rushaway commented 3 months ago

We already have forward for detect when a record is stoped, but feel free to open an issue on the repo.

maxime1907 commented 3 months ago

https://github.com/srcdslab/sm-plugin-AutoRecorder/issues/5