Well, I guess the same way you'd do it for any html, like put the info in the url, or submit a form. For example, you could put this somewhere in the template:
Code:
<a href="myscript.php?threaduser=$threadinfo[postuserid]&threadid=$threadinfo[threadid]&userid=$bbuserinfo[userid]">Link to my script</a>
Then in your script it will be in $_REQUEST[]. If you included global.php in your script, you could use $vbulletin->input->clean_gpc() to make sure the values are integers and put them in $vbulletin->GPC[]. (There's an example of this in almost every "top level" vbulletin script).
Hopefully I'm understanding what you want to do.
ETA: just realized, if you did include global.php in your custom script then you don't need to pass the "current" user's id, you can get it in your script by using $vbulletin->userinfo['userid'];