Jump to content

Is there a way to detect if player used specific emote?


Recommended Posts

When the player does an emote, an event is pushed to the player called emote.

Spoiler

local function CreateEmoteCommand(emotedef)
    return {
        aliases = emotedef.aliases,
        prettyname = function(command) return string.format(STRINGS.UI.BUILTINCOMMANDS.EMOTES.PRETTYNAMEFMT, FirstToUpper(command.name)) end,
        desc = function() return STRINGS.UI.BUILTINCOMMANDS.EMOTES.DESC end,
        permission = COMMAND_PERMISSION.USER,
        params = {},
        emote = true,
        slash = true,
        usermenu = false,
        servermenu = false,
        vote = false,
        serverfn = function(params, caller)
            local player = UserToPlayer(caller.userid)
            if player ~= nil then
                player:PushEvent("emote", emotedef.data)
            end
        end,
        displayname = emotedef.displayname
    }
end

See emotes.lua

You can then listen to the event emote and run your function. The data contains data.anim which has the string of the anim that is used so you can distinguish the different emotes.

  • Thanks 1
Link to comment
Share on other sites

16 hours ago, Monti18 said:

When the player does an emote, an event is pushed to the player called emote.

  Hide contents


local function CreateEmoteCommand(emotedef)
    return {
        aliases = emotedef.aliases,
        prettyname = function(command) return string.format(STRINGS.UI.BUILTINCOMMANDS.EMOTES.PRETTYNAMEFMT, FirstToUpper(command.name)) end,
        desc = function() return STRINGS.UI.BUILTINCOMMANDS.EMOTES.DESC end,
        permission = COMMAND_PERMISSION.USER,
        params = {},
        emote = true,
        slash = true,
        usermenu = false,
        servermenu = false,
        vote = false,
        serverfn = function(params, caller)
            local player = UserToPlayer(caller.userid)
            if player ~= nil then
                player:PushEvent("emote", emotedef.data)
            end
        end,
        displayname = emotedef.displayname
    }
end

See emotes.lua

You can then listen to the event emote and run your function. The data contains data.anim which has the string of the anim that is used so you can distinguish the different emotes.

So, how should I fetch anim string data?

Tried inst.components.anim but gives nil value

local function bonesawDeluxe(inst, data)
    local emotetype = inst.components.anim
    print(emotetype)
    if emotetype == "emoteXL_bonesaw" then
        inst.components.health:DoDelta(-10)
        inst.components.sanity:DoDelta(5)
        inst.components.talker:Say("true")
    else
        inst.components.talker:Say("false")
    end
end

 

Edited by jupiter1390
Link to comment
Share on other sites

You fetch it how I told you, by using data.anim

local function bonesawDeluxe(inst, data)
    local emotetype = data.anim
    print(emotetype)
    if emotetype == "emoteXL_bonesaw" then
        inst.components.health:DoDelta(-10)
        inst.components.sanity:DoDelta(5)
        inst.components.talker:Say("true")
    else
        inst.components.talker:Say("false")
    end
end

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...