So I'm only going to post some of this so I don't completely give out my menu but the toggle makes it so it adds an action that says ON if its on and OFF if its off. Whenever I first toggle it, it doesn't turn to the ON status but when I refresh the menu and turn it from ON to OFF it works without closing menu and reopening.
I am reopening the menu everytime the toggle is selected so it should work.
Code:
main_menu = {
if(isNil "command_vgod_tog") then {
player addAction ["<t color='#FF0000'>Vehicle God [OFF]</t>", {[]spawn vgod}];
} else {
if!(command_vgod_tog) then {
player addAction ["<t color='#FF0000'>Vehicle God [OFF]</t>", {[]spawn vgod}];
} else {
player addAction ["<t color='#40FF00'>Vehicle God [ON]</t>", {[]spawn vgod}];
};
};
};
vgod = {
if(isNil "command_vgod_tog") then {
command_vgod_tog = TRUE;
} else {
if!(command_vgod_tog) then {
command_vgod_tog = TRUE;
} else {
command_vgod_tog = FALSE;
};
};
if (command_vgod_tog) then {
titleText["Vehicle God Mode enabled!", "PLAIN"];
while {command_vgod_tog} do {
waitUntil {vehicle player != player};
vehiclegod_vehicle = vehicle player;
vehiclegod_vehicle removeAllEventHandlers "handleDamage";
vehiclegod_vehicle addEventHandler["handleDamage", {false}];
vehiclegod_vehicle allowDamage false;
vehiclegod_vehicle setDamage 0;
vehiclegod_vehicle setFuel 1;
};
} else {
titleText["Vehicle God Mode disabled!", "PLAIN"];
waitUntil {vehicle player == player};
vehiclegod_vehicle removeAllEventHandlers "handleDamage";
vehiclegod_vehicle addEventHandler["handleDamage", {true}];
vehiclegod_vehicle allowDamage true;
};
[]spawn main_menu;
};
PS: By the way, my other toggles work perfectly fine and I'm using the same technique. It just won't work for some reason.