Jump to content
  • 0

Question

Posted

I have a function on my npc bg Stuffs who's get a item purchased and send direct to kafra:
1.png.8354aa17e563616678c0a50a57fd9da4.png

The problem is: this script work on my rathena 2013 , but my actualy emulator his don't work becouse the function "checkspace" and "storage" doesn't exist.
I suppose there is a function similar to "checkspace" or "storage" to replaced by those.

Does anyone know what this function whould be?

Error:

2.png.b794cbe763a8b3852301be67a85e94f7.png

NPC:

consumiveis_bg.txt

NPC Functions:
npc_comando.txt

Checkspace on bgStuffShop on npc_comando.txt:

 

//=================== Consul shop BG ====================
function	script	bgStuffShop	{
	if(!$@BG_SHOPS_READY) end;
	.@type = select(
		"Consumíveis",
		"Ferramentas"
	);
	switch(.@type){
		case 1: .@var$ = "$@BG_CONSUMABLES_NORMAL"; break;
		case 2: .@var$ = "$@BG_TOOLS_NORMAL"; break;
	}
	mes(
		"^777777======= Ferramentas BG =======",
		"^FFA500Qtd × ^ff0000Item ^0000ff- ^777777Preço",
		"^777777========================="
	);
	for(.@i=0; .@i<getarraysize(getd(.@var$)); .@i+=3){
		switch(getd(.@var$+"["+.@i+"]")){
			default:
				.@mName$ = getitemname(getd(.@var$+"["+.@i+"]"));
				.@mQuant = getd(.@var$+"["+(.@i+1)+"]");
				.@mPrice = getd(.@var$+"["+(.@i+2)+"]");
				.@menu$[getarraysize(.@menu$)] = "^FFA500"+.@mQuant+" × ^ff0000"+.@mName$+"^0000ff - ^777777"+.@mPrice;
				break;
		}
	}
	next();
	.@idx = ((select(implode(.@menu$,":"))-1) * 3);
	.@item = getd(.@var$+"["+.@idx+"]");
	.@quant = getd(.@var$+"["+(.@idx+1)+"]");
	.@price = getd(.@var$+"["+(.@idx+2)+"]");
	mes(
		"^777777======= Ferramentas BG =======",
		"^FFA500Qtd × ^ff0000Item ^0000ff- ^777777Preço",
		"^777777========================="
	);
	mes("^0000ffPacks de ^777777"+.@quant+" × ^FFA500"+getitemname(.@item));
	input(.@packs, 0, 30000);
	if(.@packs == 0){ mes("^ff0000Cancelado!"); close; }
	mes("^0000ffReceber no inventário ou armazém?");
	switch(select("Inventário", "Armazém")){
		case 1: .@destiny$ = "inventory"; break;
		case 2: .@destiny$ = "storage"; break;
	}
	if((.@destiny$ == "inventory" && checkweight(.@item, .@packs * .@quant)) ||
		 (.@destiny$ == "storage" && checkspace(.@item,.@packs * .@quant,1,0,0,0,0,0,0))){
		.@totalPrice = .@price * .@packs;
		mes("^0000ffModo de Pagamento");
		switch(select("Pagar com Emblemas de Bravura", "Pagar com Emblemas de Valor")){
			case 1: .@coin = 7828; break;
			case 2: .@coin = 7829; break;
		}
		if(countitem(.@coin) >= .@totalPrice){
			delitem(.@coin, .@totalPrice);
			if(.@destiny$ == "inventory")
				getitem(.@item,.@packs * .@quant);
			else if(.@destiny$ == "storage")
				storeitem(.@item,.@packs * .@quant);
			mes("^007700Finalizado!");
		} else {
			mes("^ff0000Você não possui ^FFA500"+getitemname(.@coin)+" ^ff0000suficiente.");
		}
	} else {
		if(.@destiny$ == "inventory")
			mes("^A58500Você não aguenta tanto peso");
		else if(.@destiny$ == "storage")
			mes("^A58500Seu armazém não tem espaço");
	}
	close;
}

 

Checkspace on script.c:

BUILDIN_FUNC(checkspace)
{
	int nameid = 0, amount;
	struct map_session_data *sd;
	
	if( (sd = script_rid2sd(st)) == NULL )
		script_pushint(st,0);
	else if( sd->status.storage.storage_amount > MAX_STORAGE )
		script_pushint(st,0); // Storage at max
	else
	{
		struct script_data *data = script_getdata(st,2);
		struct item_data *id;
		struct item it;
		int i;

		get_val(st,data);
		if( data_isstring(data) )
		{
			const char *name = conv_str(st,data);
			struct item_data *id = itemdb_searchname(name);
			if( id )
				nameid = id->nameid;
		}
		else
			nameid = conv_num(st,data);

		memset(&it,0,sizeof(it));
		amount = script_getnum(st,3);
		it.nameid = nameid;
		it.identify = script_getnum(st,4);
		it.refine = script_getnum(st,5);
		it.attribute = script_getnum(st,6);
		it.card[0] = (short)script_getnum(st,7);
		it.card[1] = (short)script_getnum(st,8);
		it.card[2] = (short)script_getnum(st,9);
		it.card[3] = (short)script_getnum(st,10);

		if( nameid < 500 || amount <= 0 || (id = itemdb_exists(nameid)) == NULL || !itemdb_canstore(&it, pc_get_group_level(sd)) || !itemdb_isstackable2(id) )
		{
			script_pushint(st,0);
			return 0;
		}

		if( itemdb_isstackable2(id) )
		{
			ARR_FIND(0,MAX_STORAGE,i,compare_item(&sd->status.storage.items[i],&it));
			if( i < MAX_STORAGE )
			{ // Item on Storage
				script_pushint(st,amount + sd->status.storage.items[i].amount > MAX_AMOUNT ? 0 : 1);
				return 0;
			}
		}

		ARR_FIND(0,MAX_STORAGE,i,sd->status.storage.items[i].nameid == 0);
		if( i >= MAX_STORAGE )
		{
			script_pushint(st,0);
			return 0;
		}
	
		script_pushint(st,1); // Can be Stored
	}

	return 0;
}

 

I really am researching a lot of time and would be very grateful to anyone at least consumiveis_bg.txttry to help :ani_swt3:

 

5 answers to this question

Recommended Posts

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...