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
 3524

Help with Friend List

by XBLxPhantom - 02-16-2019 - 10:10 PM
#1
So, I've had this working Perfect. But for some reason, it isn't anymore lmao. FatalCrash everytime i try to open the list. 

this is how i have it.  If anyone knows of other Mods that conflict with it maybe? that's all i can think of now but i have no idea what could be conflicting with it, if so. 

Code:
for (int i = 0; i < NETWORK::NETWORK_GET_FRIEND_COUNT(); i++) {
            char* VBuf = new char[0x500];
            strcpy(VBuf, NETWORK::NETWORK_GET_FRIEND_NAME(i));
            if (NETWORK::NETWORK_IS_FRIEND_ONLINE(i) && !NETWORK::NETWORK_IS_FRIEND_IN_SAME_TITLE(NETWORK::NETWORK_GET_FRIEND_NAME(i)))
                strcat(VBuf, " ~g~[ONLINE]");
            if (NETWORK::NETWORK_IS_FRIEND_ONLINE(i) && NETWORK::NETWORK_IS_GAMER_IN_MY_SESSION(i))
                strcat(VBuf, " ~o~[SAME LOBBY]");
            if (NETWORK::NETWORK_IS_FRIEND_ONLINE(i) && NETWORK::NETWORK_IS_FRIEND_IN_MULTIPLAYER(NETWORK::NETWORK_GET_FRIEND_NAME(i)))
                strcat(VBuf, " ~o~[GTA ONLINE]");
            if (NETWORK::NETWORK_IS_FRIEND_ONLINE(i) && !NETWORK::NETWORK_IS_FRIEND_IN_MULTIPLAYER(NETWORK::NETWORK_GET_FRIEND_NAME(i)))
                strcat(VBuf, " ~o~[GTA STORY]");
            if (!NETWORK::NETWORK_IS_FRIEND_ONLINE(i))
                strcat(VBuf, " ~r~[OFFLINE]");
            AddOption(VBuf);
            delete[] VBuf;
        }
        break;
Reply
#2
Have the compiler use the menu's stack for the text buffer. I don't see why you'd need to dynamically allocate 0x500 bytes of data when clearing it won't be using that much.

try something like

char VBuf[96] = "";

instead of

char* VBuf = new char[0x500];

don't forget to remove the
delete[] VBuf;
This account is currently banned
Ban reason: Leeching and Spamming is not allowed, please read the forum Rules upon your return.
Multi
Reply
#3
(02-17-2019 - 06:44 AM)pdb Wrote: Have the compiler use the menu's stack for the text buffer. I don't see why you'd need to dynamically allocate 0x500 bytes of data when clearing it won't be using that much.

try something like

char VBuf[96] = "";

instead of

char* VBuf = new char[0x500];

don't forget to remove the
delete[] VBuf;

Thanks ! tweaking and testing now. If it works I'll credit you For the help.   check out Celestial free menu. :D
Reply
#4
(02-17-2019 - 06:44 AM)pdb Wrote: Have the compiler use the menu's stack for the text buffer. I don't see why you'd need to dynamically allocate 0x500 bytes of data when clearing it won't be using that much.

try something like

char VBuf[96] = "";

instead of

char* VBuf = new char[0x500];

don't forget to remove the
delete[] VBuf;

Nope, Still Fatalcrashes when i open it.
Reply
#5
Check your natives bro
Reply
#6
(02-16-2019 - 10:10 PM)XBLxPhantom Wrote: So, I've had this working Perfect. But for some reason, it isn't anymore lmao. FatalCrash everytime i try to open the list. 

this is how i have it.  If anyone knows of other Mods that conflict with it maybe? that's all i can think of now but i have no idea what could be conflicting with it, if so. 

Code:
for (int i = 0; i < NETWORK::NETWORK_GET_FRIEND_COUNT(); i++) {
            char* VBuf = new char[0x500];
            strcpy(VBuf, NETWORK::NETWORK_GET_FRIEND_NAME(i));
            if (NETWORK::NETWORK_IS_FRIEND_ONLINE(i) && !NETWORK::NETWORK_IS_FRIEND_IN_SAME_TITLE(NETWORK::NETWORK_GET_FRIEND_NAME(i)))
                strcat(VBuf, " ~g~[ONLINE]");
            if (NETWORK::NETWORK_IS_FRIEND_ONLINE(i) && NETWORK::NETWORK_IS_GAMER_IN_MY_SESSION(i))
                strcat(VBuf, " ~o~[SAME LOBBY]");
            if (NETWORK::NETWORK_IS_FRIEND_ONLINE(i) && NETWORK::NETWORK_IS_FRIEND_IN_MULTIPLAYER(NETWORK::NETWORK_GET_FRIEND_NAME(i)))
                strcat(VBuf, " ~o~[GTA ONLINE]");
            if (NETWORK::NETWORK_IS_FRIEND_ONLINE(i) && !NETWORK::NETWORK_IS_FRIEND_IN_MULTIPLAYER(NETWORK::NETWORK_GET_FRIEND_NAME(i)))
                strcat(VBuf, " ~o~[GTA STORY]");
            if (!NETWORK::NETWORK_IS_FRIEND_ONLINE(i))
                strcat(VBuf, " ~r~[OFFLINE]");
            AddOption(VBuf);
            delete[] VBuf;
        }
        break;
Reply
#7
(02-26-2019 - 06:47 AM)UNBOUND Wrote: Your code looks really bad. There is no need to create a buffer at all on either the heap or stack, because all you need it to do is display the player's name once you've got the network handle, you aren't really doing anything else with it. If you were to need the player's name again, just access the network structure, don't save the name in a buffer.

EDIT: Just realised that you aren't grabbing the network handle. either way, there is no point in creating a buffer in the loop; once one player has been displayed you're deallocating that memory (which is still being accessed by one of your previous loop iterations) and re-allocating it to somewhere else in data memory. This can cause all sorts of problems, not saying it is the sole cause, but it's worth looking at.


In short, grab the player's name from within the game's memory itself. This is more stable and uses up less memory on the data page of your modification.

Code:
for (int i = 0; i < NETWORK::NETWORK_GET_FRIEND_COUNT(); i++) {
            if (NETWORK::NETWORK_IS_FRIEND_INDEX_ONLINE(i)) {
                ADD_OPTION(AddStrings(NETWORK::NETWORK_GET_FRIEND_NAME(i), " ~g~[ONLINE]"));
            }
            if (!NETWORK::NETWORK_IS_FRIEND_INDEX_ONLINE(i)) {
                ADD_OPTION(AddStrings(NETWORK::NETWORK_GET_FRIEND_NAME(i), " ~r~[OFFLINE]"));
            }
        }
This is now How i have it. [TBV3 Had given me a hand] through this i found the main issue, It's when I'm trying to grab whether or not the client is In the same session or not.... Calling this  -- NETWORK::NETWORK_IS_FRIEND_ONLINE(i) && NETWORK::NETWORK_IS_GAMER_IN_MY_SESSION(i))  is where I'm assuming the issue is from. 
Reply
#8
(02-27-2019 - 04:20 AM)XBLxPhantom Wrote:
(02-26-2019 - 06:47 AM)UNBOUND Wrote: Your code looks really bad. There is no need to create a buffer at all on either the heap or stack, because all you need it to do is display the player's name once you've got the network handle, you aren't really doing anything else with it. If you were to need the player's name again, just access the network structure, don't save the name in a buffer.

EDIT: Just realised that you aren't grabbing the network handle. either way, there is no point in creating a buffer in the loop; once one player has been displayed you're deallocating that memory (which is still being accessed by one of your previous loop iterations) and re-allocating it to somewhere else in data memory. This can cause all sorts of problems, not saying it is the sole cause, but it's worth looking at.


In short, grab the player's name from within the game's memory itself. This is more stable and uses up less memory on the data page of your modification.

Code:
for (int i = 0; i < NETWORK::NETWORK_GET_FRIEND_COUNT(); i++) {
            if (NETWORK::NETWORK_IS_FRIEND_INDEX_ONLINE(i)) {
                ADD_OPTION(AddStrings(NETWORK::NETWORK_GET_FRIEND_NAME(i), " ~g~[ONLINE]"));
            }
            if (!NETWORK::NETWORK_IS_FRIEND_INDEX_ONLINE(i)) {
                ADD_OPTION(AddStrings(NETWORK::NETWORK_GET_FRIEND_NAME(i), " ~r~[OFFLINE]"));
            }
        }
This is now How i have it. [TBV3 Had given me a hand] through this i found the main issue, It's when I'm trying to grab whether or not the client is In the same session or not.... Calling this  -- NETWORK::NETWORK_IS_FRIEND_ONLINE(i) && NETWORK::NETWORK_IS_GAMER_IN_MY_SESSION(i))  is where I'm assuming the issue is from. 
Try edit native:
Code:
int NETWORK_GET_FRIEND_COUNT()
BOOL NETWORK_IS_FRIEND_INDEX_ONLINE(int friendIndex)
char *NETWORK_GET_FRIEND_NAME(Player player)
This account is currently banned
Ban reason: Leeching and Spamming is not allowed, please read the forum Rules upon your return.
Reply
#9
i got the code working lol
[Image: 60020559_453884585389778_848339054517393...e=5D6011C2]
Reply
#10
(05-10-2019 - 11:31 PM)BModzMasterTM Wrote: i got the code working lol
[Image: 60020559_453884585389778_848339054517393...e=5D6011C2]

nice design, it's clean.
add for (int i = 0; i NETWORK::NETWORK_GET_FRIEND_COUNT(); i++)
gor get all friend (even if there are offline).
This account is currently banned
Ban reason: Leeching and Spamming is not allowed, please read the forum Rules upon your return.
Reply

Users browsing: 4 Guest(s)