getequipistradable & getitemistradable [Help]

Lord Ganja

New member
Messages
161
Points
0
Age
34
Location
Ganja World
i'm trying to create a custom script command that checks if the currently equipped item is  'tradable' or 'untradable(either it is 'bounded' or has the 'notrade' flag)'

I comeup with my own script but it doesn't work. I don't know how can I declare the itemdb_cantrade :/

I have hunch that it wouldn't work in the first place but I still tried LOL

BUILDIN(getequipistradable){ int i = -1,num; TBL_PC *sd; num = script_getnum(st,2); sd = script->rid2sd(st); if( sd == NULL ) return true; if( num > 0 && num <= ARRAYLENGTH(script->equip) ) i = pc->checkequip(sd,script->equip[num-1]); if( i >= 0 && itemdb_cantrade(sd->inventory_data) ) // I also tried this one if( i >= 0 && sd->inventory_data->itemdb_cantrade ) script_pushint(st,1); else script_pushint(st,0); return true;}


The other one is a custom script command that checks if an item is 'tradable' or 'untradable(either it is 'bounded' or has the 'notrade' flag)'

I don't know if it can possibly check if an item is 'bounded' when it is not equipped. Please let me know.

but im trying to create a script works like 'getitemistradable <item_id>;' If it can't check bounded items that are not currently equipped, but can detect the 'notrade' flag, it would work fine for me..

I comeup with this script but same problem from getequipistradable.

BUILDIN(getitemistradable){ int item_id; struct item_data *i_data; item_id=script_getnum(st,2); i_data = itemdb->exists(item_id); if ( itemdb_cantrade(i_data) ) script_pushint(st,1); else script_pushint(st,0); return true;}


Anybody can help me to make this script work? Thanks in advance!

 
Well, I see few problems with checking if item is bound, since you'll need to check some specific item, as it is stored inside item itself. If you plan to delete it afterward you'll need to delete it by its index, and I believe there's no command to do that by default. And that there can be both bound and non-bound item inside player inventory does not make it easier. Albeit delitem prefers normal items over bound/carded ones, but don't take my word for it.

For the flag checking you can use this command that was made for me by a friend long ago:

/* [List of Restrictions] ITR_NONE 0 ITR_NODROP 1 ITR_NOTRADE 2 ITR_PARTNEROVERRIDE 4 ITR_NOSELLTONPC 8 ITR_NOCART 16 ITR_NOSTORAGE 32 ITR_NOGSTORAGE 64 ITR_NOMAIL 128 ITR_NOAUCTION 256 ITR_ALL 511 Usage in scripts: chk_restrictions(ItemID);*/BUILDIN(chk_restrictions) { struct item_data *item_info; int item_id, item_tradable; item_id = script_getnum(st,2); //Value sent by the script (Item ID) if(itemdb->exists(item_id)) item_info = itemdb->search(item_id); else { script_pushint(st,-1); //If the ID is invalid it stops here and returns -1 return true; } item_tradable = item_info->flag.trade_restriction; script_pushint(st, item_tradable); //Returns the sum of restrictions return true;}
It returns combined value of restrictions on item, so if you want to check if it's tradeable, then

chk_restrictions(item)&2

must be 0.

Makes it easy to use inside ifs:

Code:
if( chk_restrictions(item)&2 ) {    // Item is non-tradeable, prevent script from advancing}
 
Last edited by a moderator:
Thank you @@Garr! Let me try this and i'll let you know if this works..

btw should i put it like this:

BUILDIN_DEF(chk_restrictions,"v"),

            or like this?

BUILDIN_DEF(chk_restrictions,"i"),

I have no idea what is 'v' and what is 'i' LOL

 
Both would do, I think.

"i" stands for one integer as argument.

"v" stands for variable, as my guess (you can input either integer or constant)

"s" is text

"?" is unknown, one argument

"*" is unknown, unlimited arguments.

 
Last edited by a moderator:
Alright! Thanks @@Garr
default_no1.gif


 
Back
Top