ALERT!
Click here to register with a few steps and explore all our cool stuff we have to offer!
Home
Upgrade
Credits
Help
Search
Awards
Achievements
 6410

GTA 5 Array players

by NoNameV2345 - 01-09-2018 - 12:43 AM
#1
Hello everyone, today I will show you how to put the arrays on the players.
what are they for?
when you select a player, and you activate an option (for example money drop), if you keep this option active on the player, and then you select another player, it automatically becomes abbilita on the selected player without wanting. Here's how to fix it.
Code:
//variables
bool MoneyOnPlayer[18];
//func
void MoneyOnPlayer(int player)
{
    STREAMING::REQUEST_MODEL(0x113FD533);
    if (STREAMING::HAS_MODEL_LOADED(0x113FD533) == 1) 
    {
        Vector3 mycoords = ENTITY::GET_ENTITY_COORDS(PLAYER::GET_PLAYER_PED(player), true);
        OBJECT::CREATE_AMBIENT_PICKUP(0xCE6FDD6B, mycoords.x, mycoords.y, mycoords.z, 0, 40000, 0x113FD533, 0, 1);
        STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(0x113FD533); 
    }
}
//to your hook
for (int array = 0; array < 18; array++)

    {
//exaple

if (MoneyOnPlayer[i])
        {
            MoneyOnPlayer(i);
        }
//more here
//how add to case? easy

addBoolOption("Money Drop",MoneyOnPlayer[selectedPlayer]);
switch(getOption())
{
case 1: MoneyOnPlayer[selectedPlayer] = MoneyOnPlayer[selectedPlayer];break;
}
break;
This account is currently banned
Ban reason: Leeching and Spamming is not allowed, please read the forum Rules upon your return.
Reply
#2
Why not create a player structure and have all toggles in that structure. saves having tonnes of variables. Nevertheless I suppose this ghetto method works fine.
This account is currently banned
Ban reason: Multi
Reply
#3
Thanks for this :)
Reply
#4
(01-09-2018 - 03:44 AM)densN Wrote: Why not create a player structure and have all toggles in that structure. saves having tonnes of variables. Nevertheless I suppose this ghetto method works fine.

there are many ways, and I did see the simplest one
This account is currently banned
Ban reason: Leeching and Spamming is not allowed, please read the forum Rules upon your return.
Reply
#5
You can do it easier look, try using selectedPlayer
Reply
#6
(01-11-2018 - 08:25 PM)SinceModz Wrote: You can do it easier look, try using selectedPlayer

"when you select a player, and you activate an option (for example money drop), if you keep this option active on the player, and then you select another player, it automatically becomes abbilita on the selected player without wanting. Here's how to fix it."
This account is currently banned
Ban reason: Leeching and Spamming is not allowed, please read the forum Rules upon your return.
Reply
#7
is for pc menu source ?!
Reply
#8
Ooh, i see. Thanks m8
Reply
#9
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
Reply
#10
(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



his method will improve, but it seems more difficult for those who are at the first function, so I published the easiest method I knew, to make life easier for those who are at the first functions.
This account is currently banned
Ban reason: Leeching and Spamming is not allowed, please read the forum Rules upon your return.
Reply

Users browsing: 1 Guest(s)