Jump to content
  • 0
Sign in to follow this  
Lord Ganja

getequipistradable & getitemistradable [Help]

Question

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]) )	// I also tried this one if( i >= 0 && sd->inventory_data[i]->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!

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

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:

if( chk_restrictions(item)&2 ) {    // Item is non-tradeable, prevent script from advancing}
Edited by Garr

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

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.

Edited by Garr

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.