Skip to content

User API

MasterGeneral156 edited this page Feb 7, 2019 · 30 revisions

The User API

The User API is useful when you need to interact with users directly.

Available Functions

UserHasCurrency();
UserGiveItem();
UserTakeItem();
UserGiveCurrency();
UserTakeCurrency();
UserEquippedItem();
UserStatus();
UserStatusSet();
UserMemberLevelGet();
UserInfoGet();
UserInfoSet();
UserHasItem();
UserInfoSetStatic();

UserHasCurrency();

UserHasCurrency(); is a function to test for if the user has at least the minimum amount of currency specified. This function takes three variables.
$api->UserHasCurrency($user,$currency,$qty);
$user - Integer. Specifies the user testing on.
$currency - Text. Currency Type. Valid inputs are primary and secondary.
$qty - Integer. Minimum currency the user in $currency has.

This function returns true if the user has more than or equal to the minimum currency required. Function will return false if user does not have the minimum currency, user does not exist, or attempting to test against a non-existent currency.

UserGiveItem();

UserGiveItem(); is a function used to give the specified user a quantity of an item to their inventory. This function takes three variables.
$api->UserGiveItem($user,$itemid,$qty);
$user - Integer. Specifies the user testing on.
$itemid - Integer. Item ID.
$qty - Integer. Quantity of $itemid you wish to give.

This function returns true if the item was given to the user, and false if it did not.

UserTakeItem();

UserTakeItem(); is a function used to give the specified user a quantity of an item to their inventory. This function takes three variables.
$api->UserTakeItem($user,$itemid,$qty);
Variable #1 - Integer. Specifies the user testing on.
Variable #2 - Integer. Item ID.
Variable #3 - Integer. Quantity of Variable 2 you wish to remove.

This function returns true if the item was taken from the user, and false if it did not.

UserGiveCurrency();

UserGiveCurrency(); is a function used to give the specified user a quantity of currency. This function takes three variables.
$api->UserGiveCurrency($var1,$var2,$var3);
Variable #1 - Integer. Specifies the user testing on.
Variable #2 - Text. Currency Type. Valid inputs are Primary and Secondary
Variable #3 - Integer. Amount of currency given to the user in variable 1.

This function returns true if the currency was given to the user, and false if it did not.

UserTakeCurrency();

UserTakeCurrency(); is a function used to take a quantity of currency from the specified user. This function takes three variables.
$api->UserTakeCurrency($var1,$var2,$var3);
Variable #1 - Integer. Specifies the user testing on.
Variable #2 - Integer. Currency Type. Valid inputs are Primary and Secondary
Variable #3 - Integer. Amount of currency taken from the user in variable 1.

This function returns true if the currency was taken from the user, and false if it did not.

UserEquippedItem();

UserEquippedItem(); is a function used to test what the specified user has equipped in the specified slot. Optionally, you can test for if they have nothing equipped, anything equipped or a specified item equipped. This function takes three variables.
$api->UserEquippedItem($var1,$var2,$var3);
Variable #1 - Integer. Specifies the user testing on.
Variable #2 - Text. Equipment slot. Valid inputs are Primary, Secondary and Armor
Variable #3 - Integer. Item ID to test for. Specify -1 for any item. 0 for no item, and any number above 0 for a specific weapon.

Returns true if the user has the specified item in the specified slot. Returns false if otherwise.

UserStatus();

UserStatus(); is a function used to test whether or the not the user specified is in the infirmary or dungeon. (Can be specified) This function takes only two variables. $api->UserStatus($var1,$var2);
Variable #1 - Integer. Specifies the user testing on.
Variable #2 - Text. Place to test for. Valid inputs are Infirmary and Dungeon.

Returns true if the user is in the spot specified. Returns false if not.

UserStatusSet();

UserStatusSet(); is a function used to set a user's infirmary or dungeon time. Can be used to both remove and add time. This function takes four variables.
$api->UserStatus($var1,$var2,$var3,$var4);
Variable #1 - Integer. Specifies the user testing on.
Variable #2 - Text. Place to test for. Valid inputs are Infirmary and Dungeon
Variable #3 - Integer. Time (in minutes) is added/removed from infirmary time. Negative number removes time.
Variable #4 - Text. Reason user is placed in the dungeon/infirmary.

Returns true if the user's time is updated, false if not.

UserMemberLevelGet();

UserMemberLevelGet(); is a function used to get a user's member level. Can be used to test for all member levels or just a specific one. (Allowing a Web Dev access, but not an admin, for example) This takes two required variables, and one optional
$api->UserMemberLevelGet($var1,$var2,$var3);
Variable #1 - Integer. Specifies the user testing on.
Variable #2 - Text. Member level to test for.
Variable #3 - Boolean. Optional. Set true to test for exact user level, or false for those above specified user level. [Default = false]

Returns true if user has the member level. False if not.

UserInfoGet();

UserInfoGet(); is a function used to get a user's information from the user table. This function is very powerful as it allows you to return any value inside the user database table. Optionally, you may return this number as a percent. Will cause a query error, however, if the row you're looking for does not have a max. This function takes three variables, one of which is optional.
$api->UserInfoGet($var1,$var2,$var3);
Variable #1 - Integer. Specifies the user testing on.
Variable #2 - Text. Data table's row to return.
Variable #3 - Boolean. Optional. Set true to test to return as a percent. Setting this to true while using a row that does not have a max will cause a query error. [Default = false]

Returns the value of the data table row. Will output an error if the API call is trying to change a private row, such as password, email, ip, etc.

UserInfoSet();

UserInfoSet(); is a function used to set a user's information on the user table. This function is very powerful as it allows you to change any value inside the user database table. Optionally, you may update this number as a percent. Will cause a query error, however, if the row you're looking for does not have a max. This function takes four variables, one of which is optional.
$api->UserInfoSet($var1,$var2,$var3,$var4);
Variable #1 - Integer. Specifies the user testing on.
Variable #2 - Text. Data table's row to return.
Variable #3 - Integer. The number you wish to remove/add to the user's info.
Variable #4 - Boolean. Optional. Set true to test to return as a percent. Setting this to true while using a row that does not have a max will cause a query error. [Default = false]

Returns true when the user's data is updated. Returns false otherwise. Will output an error if the API call is trying to change a private row, such as password, email, ip, etc.

UserHasItem();

UserHasItem(); is a function used to test the specified user for a quantity of an item in their inventory. This function takes three variables, one of which is optional.
$api->UserHasItem($var1,$var2,$var3);
Variable #1 - Integer. Specifies the user testing on.
Variable #2 - Integer. Item ID.
Variable #3 - Integer. Optional. Quantity of Variable 2 you wish to test for. [Default: 1]

Returns true if the user has the item and quantity, false if they do not.

UserInfoSetStatic();

UserInfoSetStatic(); is a function used to set a specified user's stat to a specific value. No adding/subtracting. This accepts three variables.
$api->UserInfoSetStatic($var1,$var2,$var3);
Variable #1 - Integer. Specifies the user testing on.
Variable #2 - Integer/Text. Stat to update.
Variable #3 - Integer. Value to set stat to.

Returns true if the stat was updated, false if otherwise.

Clone this wiki locally