Jump to content
  • 0

getcostumeitem


Question

Posted

Hello, everyone. Not sure if this one should go here or to Source Request.

I hope someone could correct this script command. I tried to edit it, but it also create non-headgears.

Anyway, here's the code:

// Costume Item System [GreenBox - Cronus]
BUILDIN_FUNC(getcostumeitem)
{
int nameid,amount,get_count,i,flag = 0;
struct item it;
TBL_PC *sd;
struct script_data *data;

data=script_getdata(st,2);
get_val(st,data);
if( data_isstring(data) )
{// "<item name>"
	const char *name=conv_str(st,data);
	struct item_data *item_data = itemdb_searchname(name);
	if( item_data == NULL ){
		ShowError("buildin_getcostumeitem: Nonexistant item %s requested.n", name);
		return 1; //No item created.
	}
	nameid=item_data->nameid;
} else if( data_isint(data) )
{// <item id>
	nameid=conv_num(st,data);
	//Violet Box, Blue Box, etc - random item pick
	if( nameid < 0 ) {
		nameid=itemdb_searchrandomid(-nameid);
		flag = 1;
	}
	if( nameid <= 0 || !itemdb_exists(nameid) ){
		ShowError("buildin_getcostumeitem: Nonexistant item %d requested.n", nameid);
		return 1; //No item created.
	}
} else {
	ShowError("buildin_getcostumeitem: invalid data type for argument #1 (%d).", data->type);
	return 1;
}

// <amount>
if( (amount=script_getnum(st,3)) <= 0)
	return 0; //return if amount <=0, skip the useles iteration

memset(&it,0,sizeof(it));
it.nameid=nameid;
if(!flag)
	it.identify=1;
else
	it.identify=itemdb_isidentified(nameid);

if (!(it.equip&EQP_HEAD_LOW) ||
	!(it.equip&EQP_COSTUME_HEAD_LOW) ||
	!(it.equip&EQP_HEAD_MID) ||
	!(it.equip&EQP_COSTUME_HEAD_MID) ||
	!(it.equip&EQP_HEAD_TOP) ||
	!(it.equip&EQP_COSTUME_HEAD_TOP)
	)
{
	ShowError("buildin_getcostumeitem: this item can't be a costume.");
	return 0;
}

if( script_hasdata(st,4) )
	sd=map_id2sd(script_getnum(st,4)); // <Account ID>
else
	sd=script_rid2sd(st); // Attached player

if( sd == NULL ) // no target
	return 0;

//Check if it's stackable.
if (!itemdb_isstackable(nameid))
	get_count = 1;
else
	get_count = amount;

it.nameid=nameid;
it.identify=1;
it.refine=0;
it.attribute=5;
it.card[0]=0;
it.card[1]=0;
it.card[2]=0;
it.card[3]=0;

for (i = 0; i < amount; i += get_count)
{
	// if not pet egg
	if (!pet_create_egg(sd, nameid))
	{
		if ((flag = pc_additem(sd, &it, get_count, LOG_TYPE_SCRIPT)))
		{
			clif_additem(sd, 0, 0, flag);
			if( pc_candrop(sd,&it) )
				map_addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
		}
	}
}

return 0;
}

Tia.

3 answers to this question

Recommended Posts

Posted (edited)

Yes, I know. You already told me on my other topic. O:

That script command isn't working properly. I hope someone could give me the fix.

Anyways, thanks for telling me again, Arcenciel. :P

Are we allowed to bump our thread on this section? If so, this is me bumping my thread. Thanks.

Bump.

EDIT:

Nvm. Fixed it. Close the thread, thanks.

Edited by Legato

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...