you must make struct to selectedOptions and put options to money drop
(01-22-2018 - 03:29 AM)Soviet Wrote: The reason most menus don't use this sort of setup is because of the overhead you incur with all those extra variables. For every new mod with a toggle option that affects another player (ex: nuke loop on player), you would now add 18 global variables to memory rather than 1. Think of how much this would inflate your menu if you had hundreds of these toggle options. If I were a user for a menu, I'd much rather be limited by nuking 1 player at a time than nuking multiple players at once with a laggy menu.
Personally, I would stick to using a single bool since it just makes life easier and you spend less time making each mod. If you need to have separate toggles for each player, here's an alternative. Instead of 1 player per bool, try using an unsigned int and treating the bits inside it as bools through bitmasking. For example, you could rework your code to be:
Code:unsigned int moneyDropBits;//variable to hold all the player bits
bool isMoneyDropEnabled(int player)//method to see if a player's bit is enabled in moneyDropBits
{
return moneyDropBits & (1 << player);
}
#define moneyDropEnabled(player) ((moneyDropBits & (1 << player)) != 0)//define version of above method
//in your hook
for (int i = 0; i < 18; i++)
{
if (isMoneyDropEnabled(i))
{
//example of method usage
MoneyOnPlayer(i);
}
if (moneyDropEnabled(i))
{
//example of define usage
MoneyOnPlayer(i);
}
}
//in the menu case
addBoolOption("Money Drop", isMoneyDropEnabled(selectedPlayer));
//or
addBoolOption("Money Drop", moneyDropEnabled(selectedPlayer));
switch(getOption())
{
case 1:
moneyDropBits ^= (1 << selectedPlayer);//switches the player's bit in moneyDropBits
break;
}
break;
I would recommend using the #define version in this code because the method requires more space for instructions
Hey good stuff.......
Users browsing: