diff options
author | gumi <git@gumi.ca> | 2020-07-20 12:26:02 -0400 |
---|---|---|
committer | gumi <git@gumi.ca> | 2020-07-20 12:26:02 -0400 |
commit | 80f552c29bd471806da1f2ad6dd750cd12933b2c (patch) | |
tree | e41866b881ba2d9fd464ca006443ad6969a4f917 /npc | |
parent | 03b2023e72364675159447dc4b328ab8c775e3bd (diff) | |
download | serverdata-80f552c29bd471806da1f2ad6dd750cd12933b2c.tar.gz serverdata-80f552c29bd471806da1f2ad6dd750cd12933b2c.tar.bz2 serverdata-80f552c29bd471806da1f2ad6dd750cd12933b2c.tar.xz serverdata-80f552c29bd471806da1f2ad6dd750cd12933b2c.zip |
add functions to get legacy storage and inventory items
Diffstat (limited to 'npc')
-rw-r--r-- | npc/functions/legacy.txt | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/npc/functions/legacy.txt b/npc/functions/legacy.txt index 029d2ed4..5f5ad026 100644 --- a/npc/functions/legacy.txt +++ b/npc/functions/legacy.txt @@ -160,3 +160,79 @@ function script setfakelegacyaccount { bitwise_set(getvariableofpc(LEGACY[1], .@acc), 0x7FFFFF00, 8, getarg(2, 5000)); return true; } + +/** + * gets the inventory the attached or provided char had on the Legacy server at + * snapshot time + * + * Example: + * .@size = getlegacyinventory(.@item, .@amount); + * + * @param 0 - a reference to an array variable to hold the item ids + * @param 1 - a reference to an array variable to hold the item qty + * @param 2? - char name / account id (defaults to attached player) + * @return number of entries added to the arrays + */ +function script getlegacyinventory { + .@char = getlegacycharid(getarg(2, "")); + + if (.@char < 1) { + consolemes(CONSOLEMES_ERROR, "getlegacyinventory: target legacy character not found"); + return 0; + } + + if ((getdatatype(getarg(0)) & (DATATYPE_VAR | DATATYPE_INT)) == 0) { + consolemes(CONSOLEMES_ERROR, "getlegacyinventory: first argument should be an integer array"); + return 0; + } + + if ((getdatatype(getarg(1)) & (DATATYPE_VAR | DATATYPE_INT)) == 0) { + consolemes(CONSOLEMES_ERROR, "getlegacyinventory: second argument should be an integer array"); + return 0; + } + + freeloop(true); + .@rows = query_sql(sprintf("SELECT nameid, amount FROM legacy.inventory WHERE char_id = '%d';", .@char), + getarg(0), getarg(1)); + freeloop(false); + + return .@rows; +} + +/** + * gets the storage the attached or provided account had on the Legacy server at + * snapshot time + * + * Example: + * .@size = getlegacystorage(.@item, .@amount); + * + * @param 0 - a reference to an array variable to hold the item ids + * @param 1 - a reference to an array variable to hold the item qty + * @param 2? - char name / account id (defaults to attached player) + * @return number of entries added to the arrays + */ +function script getlegacystorage { + .@acc = getlegacyaccountid(getarg(2, "")); + + if (.@acc < 1) { + consolemes(CONSOLEMES_ERROR, "getlegacystorage: target legacy account not found"); + return 0; + } + + if ((getdatatype(getarg(0)) & (DATATYPE_VAR | DATATYPE_INT)) == 0) { + consolemes(CONSOLEMES_ERROR, "getlegacystorage: first argument should be an integer array"); + return 0; + } + + if ((getdatatype(getarg(1)) & (DATATYPE_VAR | DATATYPE_INT)) == 0) { + consolemes(CONSOLEMES_ERROR, "getlegacystorage: second argument should be an integer array"); + return 0; + } + + freeloop(true); + .@rows = query_sql(sprintf("SELECT nameid, amount FROM legacy.storage WHERE account_id = '%d';", .@acc), + getarg(0), getarg(1)); + freeloop(false); + + return .@rows; +} |