diff options
Diffstat (limited to 'npc')
-rw-r--r-- | npc/dev/test.txt | 10 | ||||
-rw-r--r-- | npc/other/Global_Functions.txt | 37 |
2 files changed, 47 insertions, 0 deletions
diff --git a/npc/dev/test.txt b/npc/dev/test.txt index c2f07ab2f..2822ee65c 100644 --- a/npc/dev/test.txt +++ b/npc/dev/test.txt @@ -775,6 +775,16 @@ function script HerculesSelfTestHelper { callsub(OnCheck, "Getdatatype (getarg integer value)", callsub(OnTestGetdatatype, 5), DATATYPE_INT); callsub(OnCheck, "Getdatatype (getarg string)", callsub(OnTestGetdatatype, "foo"), DATATYPE_STR | DATATYPE_CONST); + callsub(OnCheck, "data_to_string (NIL)", data_to_string(), ""); + callsub(OnCheck, "data_to_string (empty string)", data_to_string(""), ""); + callsub(OnCheck, "data_to_string (string)", data_to_string("foo"), "foo"); + callsub(OnCheck, "data_to_string (integer)", data_to_string(5), "5"); + callsub(OnCheck, "data_to_string (parameter)", data_to_string(Hp), "Hp"); + callsub(OnCheck, "data_to_string (constant)", data_to_string(DATATYPE_CONST), "DATATYPE_CONST"); + callsub(OnCheck, "data_to_string (label)", data_to_string(OnTestGetdatatype), "OnTestGetdatatype"); + callsub(OnCheck, "data_to_string (string variable)", data_to_string(.@x$), ".@x$"); + callsub(OnCheck, "data_to_string (integer variable)", data_to_string(.@x), ".@x"); + if (.errors) { debugmes "Script engine self-test [ \033[0;31mFAILED\033[0m ]"; debugmes "**** The test was completed with " + .errors + " errors. ****"; diff --git a/npc/other/Global_Functions.txt b/npc/other/Global_Functions.txt index 9882e9d71..904ed7165 100644 --- a/npc/other/Global_Functions.txt +++ b/npc/other/Global_Functions.txt @@ -438,3 +438,40 @@ function script F_ShuffleNumbers { function script F_MesColor { return sprintf("^%06X", min(getarg(0), 0xFFFFFF)); } + +//== Function F_GetTradeRestriction ======================== +// Function to get item trade restriction +// Examples: +// mes "Red Potion Restriction: "+ callfunc("F_GetTradeRestriction", Red_Potion); +function script F_GetTradeRestriction { + .@trade = getiteminfo(getarg(0), ITEMINFO_TRADE); + + if (.@trade == 0) { + return "None"; + } + .@trade$ = ""; + if (.@trade & ITR_NODROP) { + .@trade$ += "NoDrop|"; + } + if (.@trade & ITR_NOTRADE) { + .@trade$ += "NoTrade|"; + } + if (.@trade & ITR_PARTNEROVERRIDE) { + .@trade$ += "PartnerOverride|"; + } + if (.@trade & ITR_NOSELLTONPC) { + .@trade$ += "NoSellToNpc|"; + } + if (.@trade & ITR_NOSTORAGE) { + .@trade$ += "NoStorage|"; + } + if (.@trade & ITR_NOGSTORAGE) { + .@trade$ += "NoGuildStorage|"; + } + if (.@trade & ITR_NOMAIL) { + .@trade$ += "NoMail|"; + } + if (.@trade & ITR_NOAUCTION) { + .@trade$ += "NoAuction|"; + } +} |