Slouken: SecureActionButton and TargetUnit

#0 - March 13, 2007, 10:24 a.m.
Blizzard Post
Hi Slouken,

After a longish break, I'm in the process of porting my Chatmanager addon to the 2.0 client. One of the features that Chatmanager had in 1.11 and earlier was the ability to target players that were displayed in the player list (basically the names of all players found in a particular chat channel) by left-clicking on their name. However in 2.0, the TargetUnit function can't be called from non-secure code.

I thought I'd be able to do this using the SecureActionButton template for the player name buttons and setting the "unit" attribute to the name of the player that I want to be targeted via left-click (since TargetUnit will accept a name as well as a unit token). However, before the SecureActionButton_OnClick function calls TargetUnit it first of all calls UnitExists with the unit attribute to check whether the unit exists, and UnitExists follows a different rules than TargetUnit, and doesn't like ordinary player names (it fails with an "Unknown unit token" popup error).

Would it be possible to provide some way in a future release to allow us to set up attributes for targeting players by name from a SecureActionButton similar to how the /target slash command works, or is this something Blizzard specifically doesn't want addons to be able to do? (This would only need to work out of combat, so for example the SecureActionButton_OnClick code could just ignore requests to target units that aren't valid unit tokens while in combat).


Cheers
-- Cirk

#4 - March 14, 2007, 2:25 a.m.
Blizzard Post
By the way, in 2.1 the names of party/raid members and pets can be used interchangeably with their unit ids. This won't work with arbitrary player names, but might be useful to know. :)