Quantcast

Jump to content

» «
Photo

MP Ped/Player Instance

2 replies to this topic
MultiStrikeAUT
  • MultiStrikeAUT

    Player Hater

  • Members
  • Joined: 04 Aug 2013

#1

Posted 04 August 2013 - 07:30 PM

Is it possible to get a ped/player instance from another player in Multiplayer?
Im writing in C++ with the ScriptHook SDK.

LuigiPeace
  • LuigiPeace

    Player Hater

  • Members
  • Joined: 02 Aug 2013

#2

Posted 16 August 2013 - 04:03 PM

Yes it is, looking in script_network.img bring me to some code and native functions.
With what I saw, you basically loop for every possible player (from 0 to 31) thanks to the IsNetworkPlayerActive function to check if there is actually an active player for this number. Then you can get the player/ped instance as usual (with the i value of the loop as index) :
CODE

Player players[32];
Ped peds[32];

for (int i = 0; i < 32; i++) {
  if (IsNetworkPlayerActive(i)) {
     // Get the player instance
     players[i] = ConvertIntToPlayerIndex(i);
     
     // Get the ped instance
     GetPlayerChar(players[i], &(peds[i]));
  }
}

MultiStrikeAUT
  • MultiStrikeAUT

    Player Hater

  • Members
  • Joined: 04 Aug 2013

#3

Posted 28 August 2013 - 05:58 PM

Thanks for the answer.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users