2
votes

At DoEmote("slap", "X") I want x to be some sort of argument for who's sending the initial emote message. I tried things such as arg2, arg12 and sender

I also tried making a work around to make you target the emoter then respond with /slap. But neither seem to work.

local p3 = CreateFrame("Frame")
p3:RegisterEvent("CHAT_MSG_TEXT_EMOTE", arg1, arg2, arg12)
p3:SetScript("OnEvent", function(self, event, arg1, arg2)
    if event == ("CHAT_MSG_TEXT_EMOTE") 
        and strfind(arg1, "laughs") 
        and strfind(arg1, "you.") 
        and name == ("Zalíssa") 
        then DoEmote("slap", "")
    end
    end)
1
"Neither seem to work" - how did you test this? Was there an error? You seem to have a huge IF condition that might be false in all cases you tried, and thus the code seemed not to work, even though the fault was not in the DoEmote part that you seem to be trying to figure. Is DoEmote reached? If it is, then which of the parameters is supposed to be sender name? You should print the variables and see instead of working blindly. If you already know this information then share it. :) - Rochet2

1 Answers

3
votes

As pretty much every other WoW API functions, DoEmote accepts UnitId as second parameter. You can only use names of individual players (and act on them) if they are in your party or raid.

When your desired player is your target you can simply DoEmote("slap", "target"). If they are not, you can try to scan your party/raid members target, targettarget and focus units and try to find if any of them is your desired player by comparing what UnitName returns for each of them and use DoEmote with corresponding ID.

If your desired player does not correspond to any valid UnitId - i.e. is not focused/targeted/chain targeted by anybody in your raid/party, including yourself, then you can't do anything about that. You can only ever act on units that correspond to IDs.

You can also use SendChatMessage to EMOTE channel with just whatever text you want, directly writing "slaps Zalíssa." as an argument as last resort. This will have same effect as /e chat command with all its shortcomings - your text will be transmitted verbatim, no translations will be performed for other languages of client, no emote animation or sound will be played and player name won't be inflected/declined in languages where it matters.