Code:
function RobintonsAddon_OnLoad()
this:RegisterEvent("PLAYER_TARGET_CHANGED");
end
function RobintonsAddon_OnEvent(event)
local targetClass = UnitClass("target");
if event == "PLAYER_TARGET_CHANGED" then
if (targetClass == "Warrior") then
if (UnitIsFriend("player","target")) then
return
else
PlaySoundFile("Interface\\Addons\\RobintonsAddon\\Sounds\\Warrior.wav");
end
end
end
end
Try that and let me know...
make sure to register your onload and onevent handlers in an xml file
Code:
<Scripts xmlns="http://www.blizzard.com/wow/ui/">
<OnLoad>
RobintonsAddon_OnLoad();
</OnLoad>
<OnEvent>
RobintonsAddon_OnEvent(event);
</OnEvent>
</Scripts>
Learning to write mods for WoW is a very comlicated and time consuming process with no definitive guide online...I spend alot of time trying to decifer wowwiki. however, wikis are user submitted info so really thats just what other people have figured out through trial and error and sometimes the information there is incomplete or incorrect or how the code functions remains not understood. Try looking at how blizzard codes things at
http://wdnaddons.com/ Its a historical reference of the LUA/XML game files and you can learn alot from learing the logic there...thats what I've done as I continue to develop RedAlert.