vp_user_attributes_by_id

From Virtual Paradise Wiki
Revision as of 23:31, 30 July 2018 by Sleepy E (talk | contribs) (Added warning about failed requests)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Method call snippet vp_user_attributes_by_id(instance, user_id);

Request user attributes by user ID.

Parameters

These are the parameters that this method requires:

Parameter Usage
VPInstance
instance
Pointer to the instance this method call is intended for
int
user_id
User id

Returns

This method returns a return code integer, which indicates whether the call was successful or errored for any reason:

Return code Cause
VP_RC_SUCCESS Successful call (for methods that have a registered callback, it only means the request has been sent)

Behavior

The user attributes will be returned in the VP_EVENT_USER_ATTRIBUTES event. See vp_event_set().

Caveats

If the request fails then there will be no response from the server (e.g. if the user id doesn't exist).

Examples

void handle_user_attributes(VPInstance sdk)
{
  int user_id;
  const char *name;

  user_id = vp_int(sdk, VP_USER_ID);
  name = vp_string(sdk, VP_USER_NAME);

  if (user_id == vp_int(sdk, VP_MY_USER_ID))
  {
    printf("The name of my owner is \"%s\"\n", name);
  }
}

int main(int argc, const char* argv[])
{
  //...

  vp_event_set(sdk, VP_EVENT_USER_ATTRIBUTES, handle_user_attributes);
  vp_user_attributes_by_id(sdk, vp_int(sdk, VP_MY_USER_ID));

  //...
}

See also