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
 1389

need some advice / help with Getip in gta menu

by clbmodzlive - 07-25-2018 - 12:00 AM
#1
For some reason its shows the wrong ip for me and shows the same ip for everyone else in a online session wondering why its doing that cant seem to figure out why any advice would be appreciated.

heres the Getip im using for info box...

Code:
char* GetIP(int playerId)
{
    {
        if (PLAYER::IS_PLAYER_PLAYING(playerId)) {
            char* pName = PLAYER::GET_PLAYER_NAME(selectedPlayer);
            char output[76];
            unsigned char ip[4];
            ip[0] = (UINT16)(pName - 0x49);
            ip[1] = (UINT16)(pName - 0x48);
            ip[2] = (UINT16)(pName - 0x47);
            ip[3] = (UINT16)(pName - 0x46);
            sprintf(output, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
            printf("%s", output);
            return output;
        }
    } return "0.0.0.0";
}
Reply
#2
Code:
char playersIP[15];
snprintf(playersIP, sizeof(playersIP), "Players IP Address : %s", getIP(); //use getIP(selectedPlayer) or getIIP(i); if using a for statement
then print it out somewhere
drawnorifitcation(playersIP);

%s is for a string
%f is for a float
and %i is for in integer

cant get any simpler than that
Reply
#3
correct code:

char* GetIP(int playerId)
{
if (PLAYER::IS_PLAYER_PLAYING(playerId)) {
char* pName = PLAYER::GET_PLAYER_NAME(selectedPlayer);
char output[76];
unsigned char ip[4];
ip[0] = (UINT16)(pName - 0x49);
ip[1] = (UINT16)(pName - 0x48);
ip[2] = (UINT16)(pName - 0x47);
ip[3] = (UINT16)(pName - 0x46);
sprintf(output, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
printf("%s", output);
return output;
}
}
Reply
#4
(07-25-2018 - 12:00 AM)clbmodzlive Wrote: For some reason its shows the wrong ip for me and shows the same ip for everyone else in a online session wondering why its doing that cant seem to figure out why any advice would be appreciated.

heres the Getip im using for info box...

Code:
char* GetIP(int playerId)
{
    {
        if (PLAYER::IS_PLAYER_PLAYING(playerId)) {
            char* pName = PLAYER::GET_PLAYER_NAME(selectedPlayer);
            char output[76];
            unsigned char ip[4];
            ip[0] = (UINT16)(pName - 0x49);
            ip[1] = (UINT16)(pName - 0x48);
            ip[2] = (UINT16)(pName - 0x47);
            ip[3] = (UINT16)(pName - 0x46);
            sprintf(output, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
            printf("%s", output);
            return output;
        }
    } return "0.0.0.0";
}

Variables of type integer (int) we put %d, variables of type float we put %f, variables of type char we put %c, of type string (char *) we put %s
This account is currently banned
Ban reason: Leeching and Spamming is not allowed, please read the forum Rules upon your return.
Reply
#5
Ah ok. Got now lol. thanks for all of your help appreciate it.
Reply

Users browsing: 1 Guest(s)