1. It is my 1st post about scripting. If post is in wrong place pleas remove him. Ahh and my english it's not so good but i think evryone can understand me.

    Im starting programing addons. I wont to code addons witch play sound when player whisper to you. For do this i need event's. But i don't know where to code this "function". What i should save code and where declarate fundction and how to include this function when player is writing to You?

    So i've got function

    in Lua file

     function HelloWorld() 
        print("Addon by Possibility zaladowany v1.0");
     end ;

    in XML

     <Script File="HelloWorld.lua"/>
        <Frame name="HelloWorldFrame">

    and this work correct. Event is called in XML file and its include between <OnLoad></OnLoad> where i should save code for this function.

     function Wr()
     print("Player is writing to You");

    show me where called this function in XML ? in LUA file? i don't know

    PS don't tell me how to play song. Firstly this addon must write "Player is writing to You" at chat nothink else.

    If you add the Wr definition to your .lua file, then you can just call it whenever you want. I don't really understand your question.

    I suggest reading the World of Warcraft Programming book. It's very clear about how you can do simple event-based programming.

    Wr definition? what is this?

    i cant buy book beacouse i dont have account in bank (i am 17 year old) and i am from poland.

    my question is: how to use this <<< this:RegisterEvent("PLAYERTARGETCHANGED")>>> in lua file??

     local addon, addonName = ...
     local frame = CreateFrame("Frame")
     local onEvent = function(self, event, ...)
       if event == "PLAYER_TARGET_CHANGED" then
         print("Your target changed")
     frame:SetScript("OnEvent", onEvent)

    No XML required, fully working addon.

    Yay thans you so mutch i'am gona to try write new addon