Page 1 of 1
Custom console scripts
Posted: Sun May 12, 2013 10:59 am
by exe
Hello,
lately I've been trying to create own scripts in BF1942 with the console commands and conditionals (if/while). It's pretty basic but I can see some very interesting and new possibilities. The main issue is that I can't seem to run these scripts in the game. If I add code to the vehicle (e. g. alternative fire) it only runs it at the start of a map and just ignores it after that. Is there any kind of event I could use? I know you can also map scripts to F1/F2/F3/F4 via
Code: Select all
console.bindKeyToConsoleScript int string
but this is not really practical when you play because these are also used for the radio commands. Is it possible to remap them maybe?
Re: Custom console scripts
Posted: Sun May 12, 2013 5:20 pm
by Apache Thunder
Yep. There are some lines of code in the Common.con file for the Controls folder in your profile. (found in Mods/BF1942/Settings/Profiles/[Name of your chosen profile]/Controls)
Code: Select all
ControlMap.addKeyToTriggerMapping c_GIScript1 IDFKeyboard IDKey_F1 c_CMNonRepetive
ControlMap.addKeyToTriggerMapping c_GIScript2 IDFKeyboard IDKey_F2 c_CMNonRepetive
ControlMap.addKeyToTriggerMapping c_GIScript3 IDFKeyboard IDKey_F3 c_CMNonRepetive
ControlMap.addKeyToTriggerMapping c_GIScript4 IDFKeyboard IDKey_F4 c_CMNonRepetive
(found under the defaultGameControlMap section)
Change those keys to something else if you want console scripts working on different keys then the default ones.
Re: Custom console scripts
Posted: Sun May 12, 2013 6:28 pm
by exe
Works, thanks a lot! I wonder why I didn't think of that.

Re: Custom console scripts
Posted: Tue May 14, 2013 3:50 pm
by exe
To get my idea working I need some help again: Is there a way (= console command) to find out
my nick name in the game? I know there are a couple of name related commands but none of them gives me the result I want. The closest I found are these:
but they always return the name of the player who joins last and not
my name.
When I change my name via
I can see that the game edits the GeneralOptions.con and writes
into the chat, so there has to be some kind of code to get that information.
Re: Custom console scripts
Posted: Fri Feb 14, 2014 12:05 pm
by Waldek
Can I use that method to bind console commands? For example "Hud 0" to NumPad1 key?
Re: Custom console scripts
Posted: Sat Feb 15, 2014 12:25 pm
by exe
Yes.
There are probably other methods but here's how I got it working:
1. Unpack
game.rfa
2. Add these lines
Code: Select all
ControlMap.create defaultGameControlMap
ControlMap.addKeyToTriggerMapping c_GIScript1 IDFKeyboard IDKey_Numpad1 c_CMNonRepetive
console.bindKeyToConsoleScript 1 Bf1942/game/displayHud
to the mod's
Init.con found in the
game.rfa.
3. Create a
displayHud.con in the game.rfa file (same place as
Init.con) with this content
Code: Select all
Var v_Hud
game.useHud -> v_Hud
if v_Hud == 0
game.useHud 1
elseIf v_Hud == 1
game.useHud 0
endIf
4. Re-pack
game.rfa.