Always search our forum before posting.
Then if you have questions regarding what you find, ask in the same thread.
The link you posted from facepunch back to here, your question probably would have gotten better answer if you'd asked there in the thread you'd copied from.
See also our releases section (you posted code in FP from a developers section, which, is almost always more rough around the edges...our releases section is, for the most part, where people release stuff they know works (at least, when they released it)
/index.php/topic,6036.0.html