This module provides client request functionality to manipulate user attributes.

It is available only on Snipe Kit server.

Constructor

Methods

dec (c:ClientGame, params:Params):Dynamic

kit/attr.dec

Checks for permissions and decreases user attribute value. Works only with numbers.

Input:

  • key - String. User attribute string ID.
  • val - Int or Float. User attribute decrement value.

Output:

  • errorCode - String. Operation error code.
  • key - String. User attribute string ID.
  • val - Int or Float. Resulting user attribute value. Returned only on success.

Error codes:

  • ok - Operation successful.
  • noSuchAttribute - No such user attribute defined.
  • selfLocked - Client is currently in progress of an action.
  • wrongValueType - This value type is not allowed.

get (c:ClientGame, params:Params):Dynamic

kit/attr.get

Checks for permissions and returns user attribute value. Accepts either userID, userName or login/provider as target user. If none of these are given, the caller user is used.

Note: This method can be called without logging in.

Input:

  • key - String. User attribute string ID.
  • login - (optional) String. Target user auth login.
  • provider - (optional) String. Target user auth provider.
  • userID - (optional) Int. Target user ID.
  • userName - (optional) String. Target user name.

Output:

  • errorCode - String. Operation error code.
  • key - String. User attribute string ID.
  • login - String. Target user auth login. Returned only if given in request.
  • provider - String. Target user auth provider. Returned only if given in request.
  • tag - String. Given request tag.
  • userID - Int. Target user ID. Returned only if given in request.
  • userName - Int. Target user name. Returned only if given in request.
  • val - Dynamic. User attribute value. Returned only on success.

Error codes:

  • ok - Operation successful.
  • noPermission - No permission to do the operation.
  • noSuchAttribute - No such user attribute defined.
  • noSuchUser - No such user.

getAll (c:ClientGame, params:Params):Dynamic

kit/attr.getAll

Returns all private and public user attribute values. Only works for caller user.

Input:

Output:

  • errorCode - String. Operation error code.
  • data - Array<{ key: String, val: Dynamic }>. User attributes string IDs and values. Returned only on success.

Error codes:

  • ok - Operation successful.

getMulti (c:ClientGame, params:Params):Dynamic

kit/attr.getMulti

Checks for permissions and returns multiple user attribute values. Accepts either userID, userName or login/provider as target user. If none of these are given, the caller user is used.

If any of the requested attributes are not allowed due to permissions, the whole request fails.

Input:

  • keys - Array<String>. Array of user attribute string IDs.
  • login - (optional) String. Target user auth login.
  • provider - (optional) String. Target user auth provider.
  • tag - (optional) String. Request tag. Will return to the client.
  • userID - (optional) Int. Target user ID.
  • userName - (optional) String. Target user name.

Output:

  • errorCode - String. Operation error code.
  • data - Array<{ key: String, val: Dynamic }>. User attributes string IDs and values. Returned only on success.
  • key - String. Problematic user attribute string ID. Returned only in case of an error.
  • login - String. Target user auth login. Returned only if given in request.
  • provider - String. Target user auth provider. Returned only if given in request.
  • tag - String. Given request tag.
  • userID - Int. Target user ID. Returned only if given in request.
  • userName - Int. Target user name. Returned only if given in request.

Error codes:

  • ok - Operation successful.
  • noPermission - No permission to do the operation.
  • noSuchAttribute - No such user attribute defined.
  • noSuchUser - No such user.

getPrivate (c:ClientGame, params:Params):Dynamic

kit/attr.getPrivate

Returns all private user attribute values. Only works for caller user.

Input:

Output:

  • errorCode - String. Operation error code.
  • data - Array<{ key: String, val: Dynamic }>. User attributes string IDs and values. Returned only on success.

Error codes:

  • ok - Operation successful.

getPublic (c:ClientGame, params:Params):Dynamic

kit/attr.getPublic

Returns public user attribute values. Accepts either userID, userName or login/provider as target user. If none of these are given, the caller user is used.

Input:

  • login - (optional) String. Target user auth login.
  • provider - (optional) String. Target user auth provider.
  • userID - (optional) Int. Target user ID.
  • userName - (optional) String. Target user name.

Output:

  • errorCode - String. Operation error code.
  • data - Array<{ key: String, val: Dynamic }>. User attributes string IDs and values. Returned only on success.

Error codes:

  • ok - Operation successful.
  • noSuchAttribute - No such user attribute defined.
  • noSuchUser - No such user.

inc (c:ClientGame, params:Params):Dynamic

kit/attr.inc

Checks for permissions and increases user attribute value. Works only with numbers.

Input:

  • key - String. User attribute string ID.
  • val - Int or Float. User attribute increment value.

Output:

  • errorCode - String. Operation error code.
  • key - String. User attribute string ID.
  • val - Int or Float. Resulting user attribute value. Returned only on success.

Error codes:

  • ok - Operation successful.
  • noSuchAttribute - No such user attribute defined.
  • selfLocked - Client is currently in progress of an action.
  • wrongValueType - This value type is not allowed.

set (c:ClientGame, params:Params):Dynamic

kit/attr.set

Checks for permissions and sets user attribute value.

Input:

  • key - String. User attribute string ID.
  • val - Int, Float, Bool or String. User attribute value. String values are checked for maximum length (1024 bytes).

Output:

  • errorCode - String. Operation error code.
  • key - Int, Float, Bool or String. User attribute string ID.
  • val - Dynamic. User attribute value. Returned only on success.

Error codes:

  • ok - Operation successful.
  • noSuchAttribute - No such user attribute defined.
  • selfLocked - Client is currently in progress of an action.
  • stringTooLong - Maximum string length exceeded.
  • wrongValueType - This value type is not allowed.

setMulti (c:ClientGame, params:Params):Dynamic

kit/attr.setMulti

Checks for permissions and changes multiple user attribute values depending on the given action.

If any of the requested changes are not allowed due to permissions, the whole request fails.

Input:

  • data - Array<{ key: String, val: Dynamic, action: String }. User attribute data. Action must be one of the following: "set", "inc", "dec". Values have to be one of the following classes: Int, Float, Bool, String. String values are checked for maximum length (1024 bytes). Increment and decrement only work on numbers.

Output:

  • errorCode - String. Operation error code.
  • data - Array<{ key: String, val: Dynamic }>. Resulting user attributes string IDs and values. Returned only on success.
  • key - String. Problematic user attribute string ID. Returned only in case of an error.

Error codes:

  • ok - Operation successful.
  • noSuchAttribute - No such user attribute defined.
  • selfLocked - Client is currently in progress of an action.
  • stringTooLong - Maximum string length exceeded.
  • wrongAction - This action is not supported.
  • wrongValueType - This value type is not allowed.