Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

Issue with HoldingPlayerInGrabID

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Post Reply
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: 22

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: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 34

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: 22

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

Post Reply