Jump to content
Sign in to follow this  
wass24

Reassign key to execute script?

Recommended Posts

Is it possible to reassign a key on the keyboard to execute a script? I want to be able to use a gasmask just like Binos or night vision.

Share this post


Link to post
Share on other sites

Not really, but there's a program called F-watch that might provide a workaround. Search for it in these forums and you'll find it.

Share this post


Link to post
Share on other sites

There was also a thing called "Phobos" or something like that that allowed something similar. I found the thread from 2002 last night, but can't find it again .... sad_o.gif

Share this post


Link to post
Share on other sites

Fwatch is the way to go. Read the documentation and it is easy to use. Check it out here:

http://ofp.gamepark.cz/index.php?showthis=8361

Here is a quick example of how to script what you want:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#top

@(call loadfile ":input getkey x") == 1

;do something

~0.5

goto "top"

The above script waits until the user has pressed the "x" key (change to whichever key you need), then it takes some action, and goes back to waiting again (the delay is to give time for the user to release the key).

If you want to assign commands to more than one key, try this slightly more complicated script (adapted from my HS command system):

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_k = []

#Top

@call {_k = call loadfile ":input getkeys"; ({_x in _k} count ["1","2","3"]) != 0}

;check which number key was pressed

? "1" in _k : (do something); goto "Wait"

? "2" in _k : (do something else); goto "Wait"

? "3" in _k : (do something else); goto "Wait"

#Wait

~0.5

goto "Top"

This script waits for the player to press one of the keys we are watching for, then it takes action based on which key was pressed. This should be lower-impact on the CPU than running 3 copies of the first script, each with different keys. It should be fairly obvious how to add more keys to the above template.

I should point out that, unfortunately, Fwatch can't detect all the keys on the keyboard (characters like ~, -, +, [, and ] for example).

Also, one of the many cool features of Fwatch is that you can make it completely optional for your mission. So you could run the above script only if the player actually has fwatch running. If he didn't, the script simply wouldn't run, and there would be no other errors. Again, check the documentation for more info.

I hope this helps. If you have any Qs on how to script with Fwatch, ask and I'll be glad to help out. I'd love to see this AWESOME program get used more by editors.

Share this post


Link to post
Share on other sites

I also encourage you to try fwatch, it is a great program and relatively easy to start tinkering with.

Only problem with it is the fact that it works only on Windows operating systems and that practically means all the Linux dedicated servers have to live without it wink_o.gif

Share this post


Link to post
Share on other sites

It uses the same idea as Vektorbosons afterburner script. Creating a Camera object and reading the change in it's velocity. There was a tutorial covering the principle at OFPEC, you may have seen it? Chops used it recently with his bomb cam script.

Not sure how ProShpere fits in chronologically speaking, with Vektorbosons scripts? But essentially it's the same idea.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×