Post: CFG Button Handling
08-18-2011, 12:57 AM #1
aerosoul94
smooth like butter
(adsbygoogle = window.adsbygoogle || []).push({}); This is Button Handling for CFG that Blackstorm shared with me a while ago. It saves space and makes it easier to change controls throughout the entire menu. This is pretty simple.

Just vstr a "binds" variable when your menu starts up like this:
    bind DPAD_UP "vstr menu"

set menu "[B][FONT=Arial Black]vstr binds[/FONT][/B];vstr menuOption1"
set menuOption1 "blablabla;blablabla;blablabla" //This part doesnt matter, its just there to show you its a menu


Then in your binds variable you will use to keep your binds. This is where you can easily switch the buttons around. So here's an example "binds" command line:
    set binds "bind DPAD_UP vstr [B][FONT=Arial Black]1[/FONT][/B];bind DPAD_DOWN vstr [B][FONT=Arial Black]2[/FONT][/B];bind BUTTON_A vstr [B][FONT=Arial Black]3[/FONT][/B];bind BUTTON_B vstr [B][FONT=Arial Black]4[/FONT][/B]"


So if you ever want to switch a button with another button, instead of going through ALL your command lines and replacing the buttons, just go to this "binds" command line and and switch it once there.

So here's how to use it. For each menu option you have, instead of using binds, use set. It will switch the commands 1, 2, and 3 to whatever you set it to. Thanks to the binds above it will execute those commands. Example:
    set menuOption1 "^1Menu_Option_1;[B][FONT=Arial Black]set 1[/FONT][/B] vstr menuOption3;[B][FONT=Arial Black]set 2[/FONT][/B] vstr menuOption2;[B][FONT=Arial Black]set 3[/FONT][/B] vstr menuOptionCommand1"
set menuOption2 "^1Menu_Option_2;[B][FONT=Arial Black]set 1[/FONT][/B] vstr menuOption1;[B][FONT=Arial Black]set 2[/FONT][/B] vstr menuOption3;[B][FONT=Arial Black]set 3[/FONT][/B] vstr menuOptionCommand2"
set menuOption3 "^1Menu_Option_3;[B][FONT=Arial Black]set 1[/FONT][/B] vstr menuOption2;[B][FONT=Arial Black]set 2[/FONT][/B] vstr menuOption1;[B][FONT=Arial Black]set 3[/FONT][/B] vstr menuOptionCommand3"


How does it save space?

Compare what you usually used and what I just showed you:
    bind BUTTON_BACK vstr cmd
set 1 vstr cmd


Depending on the actual button you use as you can see here the first one is 25 characters and 33 bytes while the second one is only 14 characters and 22 bytes. It might not seem like a lot but it adds up.

Why does saving space matter?

I don't know. I use a lot of space in cfg's. So if anyone else beside me would like to save space so they can add more options then this will help.

Other than that, you can change buttons quicker.

Credits:
Blackstorm
Me
(adsbygoogle = window.adsbygoogle || []).push({});

The following 7 users say thank you to aerosoul94 for this useful post:

Plumm, PunjabiBoii, Rainbow Gravity, Swiftbarryman_, XILE_, xVz, zFlaVouR
08-18-2011, 12:57 AM #2
Blackstorm
Veni. Vidi. Vici.
08-18-2011, 02:16 AM #3
Plumm
#TeamPS
Originally posted by aerosoul94 View Post
This is Button Handling for CFG that Blackstorm shared with me a while ago. It saves space and makes it easier to change controls throughout the entire menu. This is pretty simple.

Just vstr a "binds" variable when your menu starts up like this:
    bind DPAD_UP "vstr menu"

set menu "[B][FONT=Arial Black]vstr binds[/FONT][/B];vstr menuOption1"
set menuOption1 "blablabla;blablabla;blablabla" //This part doesnt matter, its just there to show you its a menu


Then in your binds variable you will use to keep your binds. This is where you can easily switch the buttons around. So here's an example "binds" command line:
    set binds "bind DPAD_UP vstr [B][FONT=Arial Black]1[/FONT][/B];bind DPAD_DOWN vstr [B][FONT=Arial Black]2[/FONT][/B];bind BUTTON_A vstr [B][FONT=Arial Black]3[/FONT][/B];bind BUTTON_B vstr [B][FONT=Arial Black]4[/FONT][/B]"


So if you ever want to switch a button with another button, instead of going through ALL your command lines and replacing the buttons, just go to this "binds" command line and and switch it once there.

So here's how to use it. For each menu option you have, instead of using binds, use set. It will switch the commands 1, 2, and 3 to whatever you set it to. Thanks to the binds above it will execute those commands. Example:
    set menuOption1 "^1Menu_Option_1;[B][FONT=Arial Black]set 1[/FONT][/B] vstr menuOption3;[B][FONT=Arial Black]set 2[/FONT][/B] vstr menuOption2;[B][FONT=Arial Black]set 3[/FONT][/B] vstr menuOptionCommand1"
set menuOption2 "^1Menu_Option_2;[B][FONT=Arial Black]set 1[/FONT][/B] vstr menuOption1;[B][FONT=Arial Black]set 2[/FONT][/B] vstr menuOption3;[B][FONT=Arial Black]set 3[/FONT][/B] vstr menuOptionCommand2"
set menuOption3 "^1Menu_Option_3;[B][FONT=Arial Black]set 1[/FONT][/B] vstr menuOption2;[B][FONT=Arial Black]set 2[/FONT][/B] vstr menuOption1;[B][FONT=Arial Black]set 3[/FONT][/B] vstr menuOptionCommand3"


How does it save space?

Compare what you usually used and what I just showed you:
    bind BUTTON_BACK vstr cmd
set 1 vstr cmd


Depending on the actual button you use as you can see here the first one is 25 characters and 33 bytes while the second one is only 14 characters and 22 bytes. It might not seem like a lot but it adds up.

Why does saving space matter?

I don't know. I use a lot of space in cfg's. So if anyone else beside me would like to save space so they can add more options then this will help.

Other than, you can change buttons quicker.

Credits:
Blackstorm
Me

Nice, this will make writing my next patch from scratch a whole lot easier.
08-28-2011, 10:22 PM #4
xVz
Don't advertise in your usertitle
Thanks, this really made my patch not as easy to edit for noobs Happy

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo