To play a sound when someone joins, press Alt+B then click on the 'Notify' tab at the top. Check the box marked 'Enabled' then click 'Add' and add the person's nick. Then right below, click the button for 'Sounds: Online' and find the path to the sound file you want to use. You can choose one for Offline also if you want.
To play a sound when someone messages you (I assume you mean private mgs/query), press Alt+O and click on 'Sounds'. Under 'On Event, play sound' choose Query/Chat from the drop list, then right below that click the button to find the path to the sound file you want to use.