This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Forum rules

Issue with HoldingPlayerInGrabID

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Locked
Qunas
Meatbag
Posts: 2
Joined: Wed Jul 24, 2019 11:46 pm
SFD Account: Qunas
Started SFD: PreAlpha 1.4.0 or so
Location: Ukraine
Gender:
Age: 24

Issue with HoldingPlayerInGrabID

Post by Qunas » Thu Jul 25, 2019 12:33 am

How can I use HoldingPlayerInGrabID, if it is not even the same as UserID or UserIdentifier. What I want to do, is to get IPlayer object, that other player is holding and I can't figure out how. To me HoldingPlayerInGrabID, CaughtByPlayerInGrabID etc. seem to be some random numbers, that I can't use.
Please, help me out with this.

Here is screenshot of some dubugging
Image
0 x

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1887
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 36

Post by Gurt » Thu Jul 25, 2019 9:47 am

HoldingPlayerInGrabID refers to the player ID - not the User ID. IUser is not to be confused with IPlayer.
Use Game.GetPlayer(IPlayer.HoldingPlayerInGrabID) to get the player instance.
Bots spawned in a map for example have no IUser bound to them.

Code: Select all

IPlayer grabbedPlayer = Game.GetPlayer(IPlayer.HoldingPlayerInGrabID);
if (grabbedPlayer != null) {
    // grabbedPlayer.UniqueID
}
IPlayer.HoldingPlayerInGrabID refers to the IPlayer.UniqueID which is inherited from IObject.

(Note: IUser.UserID is the same as IUser.UserIdentifier)
0 x
Gurt

Qunas
Meatbag
Posts: 2
Joined: Wed Jul 24, 2019 11:46 pm
SFD Account: Qunas
Started SFD: PreAlpha 1.4.0 or so
Location: Ukraine
Gender:
Age: 24

Post by Qunas » Thu Jul 25, 2019 2:47 pm

Thank you! I shoud've searched better for this in documentetion.
Gurt wrote:
Thu Jul 25, 2019 9:47 am
(Note: IUser.UserID is the same as IUser.UserIdentifier)
Yea, I see that

And now I see how IDs can be used with Game.GetPlayer() or Game.GetActiveUser()
Thx with that.
0 x

Locked