Jump to content

giullyan2

Members
  • Posts

    9
  • Joined

  • Last visited

Posts posted by giullyan2

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

     

  2. 11 hours ago, Ninja said:

    Maybe you can tell something about this script and how it works so someone can actually help you and maybe replicate the script for you?

    Sorry for my bad English , i just want a script who make the item buying going directly to storage like npc telma from battleground.

    For example:

    I buy 25.000 white potions and 900 speed potions on npc shop. Where are these items going? For storage.

    I realy want this script but the function "checkstorage" and "storeitem" on script.c don't work on my emulator (rathena 2017)

×
×
  • Create New...