Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

Happy Holidays from the GTANet team!

PlayerID RNG?


crackdawg
 Share

Recommended Posts

I've been messing with player IDs and noticed they start at 0 and go to random numbers like 32 etc. Trying to scan them crashes the thread after a short run..I guess because of timing or something. Buffer is 24 for the record.

 

 

 if ((GetAsyncKeyState(VK_F8) & 1) != 0) { 	if(NetworkIsSessionStarted()) 	{   for(u32 i=0; i<=1000; i++){   	playerIndex = ConvertIntToPlayerIndex(i);   	if(GetPlayerName(playerIndex) != "**Invalid**")   	{     LogInfo(GetPlayerName(playerIndex));     itoa(playerIndex,buffer,10);     LogInfo(buffer);   	}   } 	} }

 

 

Last scan was like this before it crashed the thread:

 

0,24,25,26,27,28,31

 

 

I think there was more but it crashed.

Edited by crackdawg
Link to comment
Share on other sites

Well it's kind of obvious that in MP those are indeed random, in SP the playerid is always 0.

 

This is how I get playernames:

 

const ch *name1 =GetPlayerName(1); where playerindex is a value between 0 and 31 (there are a maximum of 32 slots in MP.

 

The player that runs the mod is easily picked up using:

 

u32 playerIndex = ConvertIntToPlayerIndex(GetPlayerId());

const ch *name =GetPlayerName(playerIndex);

 

To get the current host:

 

int host =GetHostId();

 

There is nothing more to it really, and never crashes for me.

 

Oh and no surpise it crashed after 31, as that would be the maximum possible value.

 

 

Link to comment
Share on other sites

 

Well it's kind of obvious that in MP those are indeed random, in SP the playerid is always 0.

 

This is how I get playernames:

 

const ch *name1 =GetPlayerName(1); where playerindex is a value between 0 and 31 (there are a maximum of 32 slots in MP.

 

The player that runs the mod is easily picked up using:

 

u32 playerIndex = ConvertIntToPlayerIndex(GetPlayerId());

  const ch *name =GetPlayerName(playerIndex);

 

To get the current host:

 

int host =GetHostId();

 

There is nothing more to it really, and never crashes for me.

 

Oh and no surpise it crashed after 31, as that would be the maximum possible value.

It wasn't making it even pass 10 on most runs. It was 1000 because I didn't know how far the random addition jumped and was brute forcing it. I know they start with 0 then do addition with a random integer. They also seem to do divide for a factor based on the total players which is why there was a sequence of 20s.

 

Unless you use names and compare to blips I don't think there is a way to get players coordinates without brute forcing the pool with a loop and some check. I read somewhere blips where returning 0 on coordinates though. I think it was intentionally done like this in the sdk. Some people are using the functionality, but they're getting info off IRC where the devs hang out. It's not worth the time to find the algorithm in a debugger or script editor. It'll eventually be made public if R* doesn't fix their import table handling first and make it where inline patching would be mandatory.

Edited by crackdawg
Link to comment
Share on other sites

Getting players coordinates is dead easy, as discussed before the playerid's on an MP game run from 0 to 31, to get player coords, use the playerindex to get the playerped, that will yield their coordinates. No need to use blips. Incidentially the blips coords problem has been fixed from hook 0.2.5 onwards, so these now also return correct coordinates.

 

As said, I can get all names in MP without any crash, maybe your buffer isn't big enough, don't know what the maxium GFWL username lenght is tbh. note the usage of const char as opposed to a char buffer.

 

 

 

 

Link to comment
Share on other sites

 

if(GetPlayerName(playerIndex) != "**Invalid**")

 

 

if that's intended to compare those two strings.. then you should be doing something like this:

 

 

if( strcmp( GetPlayerName(playerIndex), "**Invalid**" ) == 0 )

 

 

or this:

 

 

if( std::string(GetPlayerName(playerIndex)) != "**Invalid**" )

 

 

Also, only run your scan from 0 to 31... not any higher. There may not be any safeguards in the game regarding which player pool slot its accessing, and thus why its crashing.

 

Might also help if you post a dump of the registers/stack/version # of GTAIV when the crash occurs if you can obtain that without XLive complaining too much.

 

You can also do this and save yourself some itoa trouble:

 

 

LogInfo("%s %u", GetPlayerName(playerIndex), (u32) playerIndex);

 

Link to comment
Share on other sites

Thanks Aru.

 

I found using blips saves a lot of trouble. I haven't tested how well they work as far as returning coordinates go yet, I'm about to go do it now.

 

Here is what I cam up with for players. Not sure is the type cast will work:

 

   blip = GetFirstBlipInfoId(BLIP_PLAYER);   while(DoesBlipExist(blip))   {   	GetBlipCoords(blip,&coords);   	LogInfo((char)coords);   	blip = GetNextBlipInfoId(BLIP_PLAYER);   }

 

Edited by crackdawg
Link to comment
Share on other sites

That's not going to work I bet, since blip coords are vector 3.

 

something like:

 

Vector3 coords;

Getblipcoords(blip, &coords);

LogInfo("X %G",coords.X);

 

 

 

Link to comment
Share on other sites

 

That's not going to work I bet, since blip coords are vector 3.

 

something like:

 

Vector3 coords;

Getblipcoords(blip, &coords);

LogInfo("X %G",coords.X);

Yeah I know, I put it to "Vector3",coords before I tested it ^^ and I got the Vector3 in the log...I think f32 will work on each vector. I actually got what I wanted, I'm sure this will make good reference to other people.

Edited by crackdawg
Link to comment
Share on other sites

Well in any case, if all you want to do is get players coords, I would simply rely on playerid, primarily because it seems some people are able to remove their blip, hence you loose the ability to get their coords this way, simply using their playerid will be a sure way to get their coords, as I am pretty sure, there's no hiding the playerid.

 

 

Link to comment
Share on other sites

 

Well in any case, if all you want to do is get players coords, I would simply rely on playerid, primarily because it seems some people are able to remove their blip, hence you loose the ability to get their coords this way, simply using their playerid will be a sure way to get their coords, as I am pretty sure, there's no hiding the playerid.

Thanks. Also what's with things reoccurring from key state branches? I have my things set to F5-8 and I can execute something, and without pressing the buttons again the event reoccurs shortly after. I looked for something in the headers to reset a state or clear a keystate buffer but didn't see anything. It happens even with the most trivial code.

 

I'm using if ((GetAsyncKeyState(VK_F5) & 1) != 0) for example in statedefault just like the sample. I'll tap F5 to execute a branch and shortly after it'll do it again without pressing anything.

Link to comment
Share on other sites

 

Well in any case, if all you want to do is get players coords, I would simply rely on playerid, primarily because it seems some people are able to remove their blip, hence you loose the ability to get their coords this way, simply using their playerid will be a sure way to get their coords, as I am pretty sure, there's no hiding the playerid.

Thanks. Also what's with things reoccurring from key state branches? I have my things set to F5-8 and I can execute something, and without pressing the buttons again the event reoccurs shortly after. I looked for something in the headers to reset a state or clear a keystate buffer but didn't see anything. It happens even with the most trivial code.

 

I'm using if ((GetAsyncKeyState(VK_F5) & 1) != 0) for example in statedefault just like the sample. I'll tap F5 to execute a branch and shortly after it'll do it again without pressing anything.

Whatever you do don't use F8, I stopped using it shortly after patch 3 came out as it seems the any code that was assinged to that key would execute even if F8 wasn't pressed, not only with Aru's hook, also people using Alice reported the same problem, not sure if this is still an issue in patch 4 though, it might easily be.

 

VK_F5 always works correctly for me, but I use something like :

 

else if ((GetAsyncKeyState(MoneyKey1) & 1) != 0) where moneykey1 actually simply is VK_F5 read from an ini file, never had problems with using it like that (and I use a sh*t load of keys smile.gif )

Only F8 is a problem since patch 3.

 

 

 

Edited by sjaak327
Link to comment
Share on other sites

Well in any case, if all you want to do is get players coords, I would simply rely on playerid, primarily because it seems some people are able to remove their blip, hence you loose the ability to get their coords this way, simply using their playerid will be a sure way to get their coords, as I am pretty sure, there's no hiding the playerid.

Thanks. Also what's with things reoccurring from key state branches? I have my things set to F5-8 and I can execute something, and without pressing the buttons again the event reoccurs shortly after. I looked for something in the headers to reset a state or clear a keystate buffer but didn't see anything. It happens even with the most trivial code.

 

I'm using if ((GetAsyncKeyState(VK_F5) & 1) != 0) for example in statedefault just like the sample. I'll tap F5 to execute a branch and shortly after it'll do it again without pressing anything.

Whatever you do don't use F8, I stopped using it shortly after patch 3 came out as it seems the any code that was assinged to that key would execute even if F8 wasn't pressed, not only with Aru's hook, also people using Alice reported the same problem, not sure if this is still an issue in patch 4 though, it might easily be.

 

VK_F5 always works correctly for me, but I use something like :

 

else if ((GetAsyncKeyState(MoneyKey1) & 1) != 0) where moneykey1 actually simply is VK_F5 read from an ini file, never had problems with using it like that (and I use a sh*t load of keys smile.gif )

Only F8 is a problem since patch 3.

Yeah it was F8 for me too. The rest are good.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.