{"name":"setMusicEventHandler","title":"setMusicEventHandler","type":"command","url":"https://community.bistudio.com/wiki/setMusicEventHandler","revid":379536,"updated":"2026-10-31T00:51:54Z","groups":["Event Handlers","Sounds"],"status":"deprecated","replaced_by":["addMusicEventHandler"],"games":{"arma3":"1.02"},"since":"arma3 1.02","arma3_since":"1.02","description":"Sets given music track event handler. Will overwrite other music event handlers.\n\n> [!CAUTION]\n> This information is **obsolete**. Reason: Use addMusicEventHandler instead as it can stack music event handlers.","syntaxes":[{"syntax":"setMusicEventHandler [type, function]","params":[{"name":"type","type":"String","description":"\"MusicStart\" or \"MusicStop\"","type_expr":"String"},{"name":"function","type":"String","description":"script to be executed. Passes params array 0: class name of the sound in CfgMusic, 1: event handler id","type_expr":"String"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"unary","right":{"text":"[type, function]"}}],"examples":[{"code":["setMusicEventHandler [\"MusicStart\", \"hint str _this\"];"]},{"code":["setMusicEventHandler [\"MusicStop\", \"hint str _this\"];"]}],"see_also":["addMusicEventHandler","removeMusicEventHandler","playMusic","removeAllMusicEventHandlers"]}