I'm not having any problem at all capturing the keypress and I know this because I can successfully fire a message every time I hit the "M" key. The problem is in the conditional section of this code:
scn gdnvCarb203Swapint iModeBEGIN OnEquip if iMode == 0 if getequippedobject 5 == weapon1 set iMode to 1 else set iMode to 2 endif endifEND BEGIN GameModethe conditional below is wrapped in a keypress event -- I have removed all that codebecause I know with 100% certainty that the error is not there.if iMode == 1 ; assault rifle version currently equipped, switch to M203 set iMode to 2 player.additem weapon2 1 1 player.equipitem weapon2 removemeelseif iMode == 2 ; m203 currently equipped, switch to rifle set iMode to 1 player.additem weapon1 1 1 player.equipitem weapon1 removemeendifEND
What happens is, I load up the game, add weapon1 via console, and equip it. Then I hit "M" and the weapon swaps to the M203 (grenade launcher) version. When I hit "M" again, nothing happens - the M203 remains. I have the same script attached to both weapons and it looks like it should work, but maybe I'm just too close to the code. Even more interesting is when I drop the M203 version, pick it up, equip it, and hit "M" -- it unequips (leaving me with just my fists out) but the model sticks itself to my right arm.
If anybody's got any pointers or better ways to handle such swaps... do you care to share?