Jump to content
  • 0

Help with Script please?


WillJocker

Question


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.01
  • Content Count:  33
  • Reputation:   0
  • Joined:  03/27/22
  • Last Seen:  

I started working on a script where the idea is for the player to be able to advertise their item in-game, and for someone else to see the catalog and be able to buy the item. However, I'm not able to make it work in relation to items with refinement, cards and the like. Can you help me, please?
Here is the section that needs review and correction:

            setarray .@item_data_array$[0], explode(",", .@item_data$);
            set .@identify, atoi(.@item_data_array$[0]); // Identificado (1 ou 0)
            set .@refine, atoi(.@item_data_array$[1]); // Nível de refino
            set .@attribute, atoi(.@item_data_array$[2]); // Atributo (0 ou 1)
            set .@card1, atoi(.@item_data_array$[3]); // Card1
            set .@card2, atoi(.@item_data_array$[4]); // Card2
            set .@card3, atoi(.@item_data_array$[5]); // Card3
            set .@card4, atoi(.@item_data_array$[6]); // Card4

            // Devolve o item ao comprador com os dados completos
            getitem2 .@item_id, 1, .@identify, .@refine, .@attribute, .@card1, .@card2, .@card3, .@card4;

error log:

[Error]:
script error on npc/testescrips/testez.txt line 49
    parse_line: expected ';'
    44 :                 mes "Preþo invßlido.";
    45 :                 close;
    46 :             }
    47 :
    48 :             // ObtÚm os dados completos do item (incluindo cartas, refino, etc.)
*   49 :             set .@card1, getinventorycardid'('.@item_index, 0); // Card1
    50 :             set .@card2, getinventorycardid(.@item_index, 1); // Card2
    51 :             set .@card3, getinventorycardid(.@item_index, 2); // Card3
    52 :             set .@card4, getinventorycardid(.@item_index, 3); // Card4
    53 :             set .@refine, getinventoryrefinerycnt(.@item_index); // Refino
    54 :             set .@identify, getinventoryidentify(.@item_index); // Identificado (1 ou 0)

image.thumb.png.eaeb9c6b2d1a051acd323a19d7eba0a5.png

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.11
  • Content Count:  11
  • Reputation:   0
  • Joined:  04/03/25
  • Last Seen:  

I would asume that this needs some source editing if you want the refinement to be also displayed.

I think whats happening is that your script is able to pull the base item cause it exists in the DB, like the actual file, but not with the refinement.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  224
  • Reputation:   96
  • Joined:  06/02/12
  • Last Seen:  

getinventorycardid getinventoryrefinerycnt getinventoryidentify do not exist.
Check getinventorylist for the correct usage.

*getinventorylist {<char_id>};

This command sets a bunch of arrays with a complete list of whatever the
invoking character has in their inventory, including all the data needed to
recreate these items perfectly if they are destroyed. Here's what you get:

@inventorylist_id[]                - array of item ids.
@inventorylist_idx[]               - array of item inventory index.
@inventorylist_amount[]            - their corresponding item amounts.
@inventorylist_equip[]             - on which position the item is equipped (see EQP_* constants)
                                     It will contain 0 if the item is not equipped.
@inventorylist_refine[]            - for how much it is refined.
@inventorylist_identify[]          - whether it is identified.
@inventorylist_attribute[]         - whether it is broken.
@inventorylist_card1[]             - These four arrays contain card data for the items.
@inventorylist_card2[]               These data slots are also used to store names
@inventorylist_card3[]               inscribed on the items, so you can explicitly check
@inventorylist_card4[]               if the character owns an item made by a specific
                                     craftsman.
@inventorylist_expire[]            - expire time (Unix time stamp). 0 means never expires.
@inventorylist_bound[]             - the bound type of the items (see BOUND_* constants)
@inventorylist_enchantgrade[]      - the enchantgrade of the items
@inventorylist_count               - the number of items in these lists.
@inventorylist_option_id1[]        - first array of random option IDs
@inventorylist_option_value1[]     - first array of random option values
@inventorylist_option_parameter1[] - first array of random option parameters
@inventorylist_option_id2[]        - second array of random option IDs
@inventorylist_option_value2[]     - second array of random option values
@inventorylist_option_parameter2[] - second array of random option parameters
@inventorylist_option_id3[]        - third array of random option IDs
@inventorylist_option_value3[]     - third array of random option values
@inventorylist_option_parameter3[] - third array of random option parameters
@inventorylist_option_id4[]        - fourth array of random option IDs
@inventorylist_option_value4[]     - fourth array of random option values
@inventorylist_option_parameter4[] - fourth array of random option parameters
@inventorylist_option_id5[]        - fifth array of random option IDs
@inventorylist_option_value5[]     - fifth array of random option values
@inventorylist_option_parameter5[] - fifth array of random option parameters
@inventorylist_tradable            - Returns if an item is tradable or not (Pass item_db.yml, bound, and rental restrictions).
@inventorylist_favorite            - Returns if an item is favorite or not

I made an example for you:

prontera,173,176,4	script	CatalogoVendaTeste	4_M_FAIRYKID6,{
	mes "Vai colocar qual item no catálogo de venda?";
	next;

	getinventorylist;
	for(.@i = 0; .@i < @inventorylist_count; .@i++) {
		
		//ignorar items que não são equipamentos
		.@type = getiteminfo(@inventorylist_id[.@i], ITEMINFO_TYPE);
		if (.@type != IT_ARMOR && .@type != IT_WEAPON && .@type != IT_SHADOWGEAR)
			continue;
		//coloca o item no menu
		.@n$ = "";
		.@item_id = @inventorylist_id[.@i];
		.@item_ref = getarraysize(.@equipment_id_list);
		if (countinarray(.@equipment_id_list, .@item_id))
			continue;
		.@equipment_id_list[.@item_ref] = @inventorylist_id[.@i];
		if (@inventorylist_refine[.@i])
			.@n$ += "+" + @inventorylist_refine[.@i] + " ";
		.@n$ += getitemname(@inventorylist_id[.@i]);
		if (getiteminfo(@inventorylist_id[.@i], ITEMINFO_SLOT))
			.@n$ += " [" + getiteminfo(@inventorylist_id[.@i], ITEMINFO_SLOT) + "]";
		.@menu_labels$[.@item_ref] = .@n$;
	}
	if (!.@equipment_id_list[0]) {
		mes "Você não tem nenhum equipamento no seu inventário.";
		close;
	}
	.@index = select(implode(.@menu_labels$, ":")) - 1;
	.@item = .@equipment_id_list[.@index];
	mes "Você quer colocar " + getitemname(.@item) + " no catálogo?";	
	getinventorylist;
	.@i2 = inarray(@inventorylist_id, .@item);
	.@refine = @inventorylist_refine[.@i2];
	.@card0 = @inventorylist_card1[.@i2];
	.@card1 = @inventorylist_card2[.@i2];
	.@card2 = @inventorylist_card3[.@i2];
	.@card3 = @inventorylist_card4[.@i2];
	.@grade = @inventorylist_enchantgrade[.@i2];
	for(.@i = 0; .@i < (MAX_ITEM_RDM_OPT); .@i++) {
		.@r_id[.@i] = getd("@inventorylist_option_id" + (.@i + 1) + "[" + .@i2 + "]");
		.@r_v[.@i] = getd("@inventorylist_option_value" + (.@i + 1) + "[" + .@i2 + "]");
		.@r_p[.@i] = getd("@inventorylist_option_parameter" + (.@i + 1) + "[" + .@i2 + "]");
	}
	
	mes "Salvei as informaçoes do item:";
	mes "refino: +" + .@refine;
	mes "slot 1: " + (.@card0>0?getitemname(.@card0):"vazio");
	mes "slot 2: " + (.@card1>0?getitemname(.@card1):"vazio");
	mes "slot 3: " + (.@card2>0?getitemname(.@card2):"vazio");
	mes "slot 4: " + (.@card3>0?getitemname(.@card3):"vazio");
	setarray .@grade_names$,"Sem grade","[D]","[C]","[B]","[A]";
	mes "Grade: " + .@grade_names$[.@grade];
	next;
	mes "Use getitem4 para dar uma cópia exata para o comprador.";
	//Devolve o item ao comprador com os dados completos
	getitem4 .@item, 1, 1, .@refine, 0, .@card0, .@card1, .@card2, .@card3, .@grade, .@r_id, .@r_v, .@r_p;
	end;
}

 

Link to comment
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.   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.

×
×
  • Create New...