Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix calling Send using UM instance from UM hook #578

Merged
merged 2 commits into from
Sep 22, 2024

Conversation

Yarukon
Copy link
Contributor

@Yarukon Yarukon commented Sep 22, 2024

This should fix the use case below

public HookResult Hook_WeaponFiring(UserMessage userMessage)
{
    var weaponid = userMessage.ReadUInt("weapon_id");
    var soundType = userMessage.ReadInt("sound_type");
    var itemdefindex = userMessage.ReadUInt("item_def_index");

    userMessage.SetUInt("weapon_id", 0);
    userMessage.SetInt("sound_type", 9);
    userMessage.SetUInt("item_def_index", 61);

    // send for people who use silencer.
    userMessage.Recipients = new(silencer);
    userMessage.Send();

    userMessage.SetUInt("weapon_id", weaponid);
    userMessage.SetInt("sound_type", soundType);
    userMessage.SetUInt("item_def_index", itemdefindex);

    userMessage.Recipients = new(normal);

    return HookResult.Continue;
}

Code is from oylsister/StopSound@95998e3

@roflmuffin roflmuffin merged commit 9c8f25f into roflmuffin:main Sep 22, 2024
5 checks passed
@Yarukon Yarukon deleted the fix-umhook-send branch September 22, 2024 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants