So you mean if a thread is in forum x then it should display ad x, if the thread is in forum y it should display ad y?
Then you don't need a hack, you can do this with template conditionals.
In template SHOWTHREAD put
Code:
<if condition="$thread[forumid] == 12">
Ad for Forum ID 12
</if>
<if condition="$thread[forumid] == 16">
Ad for Forum ID 16
</if>
Or you can use
this Hack.
The template-code this hack uses for template FORUMDISPLAY also works in template SHOWTHREAD.