The npc display NULL because of the non existent item. I thought your item ID existed so I didn't add a check
prontera,152,170,4 script Custom Headgear Trader 797,{
function AddItem;
mes "[Custom Headgear Trader]";
mes "Hello " +strcharinfo(0)+ ", I can exchange your Custom Headgear. That means if you're ever bored of your current Custom Headgear sprite, I can easily give you another!";
next;
mes "[Custom Headgear Trader]";
mes "This service however is not free, if you want to change your Custom Headgear, I require:";
mes "1x Custom Headgear";
mes "3x Cash Points";
next;
if (select("Continue, please.:I'm not interested.") - 1) close;
if(#CASHPOINTS < 3) {
mes "[Custom Headgear Trader]";
mes "I'm sorry You do not meet the requirements. For you to use my service, I need 3 Cash Points and a Custom Headgear.";
close;
}
mes "[Custom Headgear Trader]";
mes "Very well, let's proceed with the process. Select the Customized Headgear that you want to exchange:";
getinventorylist;
for (.@i = 0; .@i < @inventorylist_count; .@i++) {
if ( getiteminfo( @inventorylist_id[.@i],5 ) & ( 1|256|512 ) == 0 ) continue;// not an headgear
for ( .@j = 0; .@j <= .num_total/128; .@j++ ) {
if ( compare( getd( ".itemidcompare"+ .@j +"$" ), ":"+ @inventorylist_id[.@i] +":" ) ) {
setd ".@arraymenu_"+ ( .@count/10 ) +"$["+ ( .@count%10 ) +"]", getitemname( @inventorylist_id[.@i] );
setd ".@itemid_"+ ( .@count/10 ) +"["+ ( .@count%10 ) +"]", @inventorylist_id[.@i];
setd ".@refine_"+ ( .@count/10 ) +"["+ ( .@count%10 ) +"]", @inventorylist_refine[.@i];
setd ".@attribute_"+ ( .@count/10 ) +"["+ ( .@count%10 ) +"]", @inventorylist_attribute[.@i];
setd ".@identify_"+ ( .@count/10 ) +"["+ ( .@count%10 ) +"]", @inventorylist_identify[.@i];
setd ".@card1_"+ ( .@count/10 ) +"["+ ( .@count%10 ) +"]", @inventorylist_card1[.@i];
setd ".@card2_"+ ( .@count/10 ) +"["+ ( .@count%10 ) +"]", @inventorylist_card2[.@i];
setd ".@card3_"+ ( .@count/10 ) +"["+ ( .@count%10 ) +"]", @inventorylist_card3[.@i];
setd ".@card4_"+ ( .@count/10 ) +"["+ ( .@count%10 ) +"]", @inventorylist_card4[.@i];
.@count++;
}
}
}
if ( .@count == 0 ) {
sleep2 2000;
mes "...Oh, it appears that you have no Custom Headgear, sorry but I can't help you.";
close;
}
while(1) {
.@menu$ = ( .@page ? "^777777Back^000000:" : ":" ) + implode( getd( ".@arraymenu_"+ .@page +"$" ), ":" ) + ( .@page == .@count/10 ? "":":^777777Next Page^000000" );
.@s = select( .@menu$ ) -2;
if ( .@s == -1 && .@page )
.@page--;
else if ( .@s == 10 )
.@page++;
else
break;
}
.@item_name$ = getd( ".@arraymenu_"+ .@page +"$["+ .@s +"]" );
.@myitem_id = getd( ".@itemid_"+ .@page +"["+ .@s +"]" );
mes "You've selected your ^FF0000" + getd( ".@arraymenu_"+ .@page +"$["+ .@s +"]" ) + "^000000, is that correct?";
next;
if (select("Yes, it is.:No.") - 1) close;
next;
mes "[Custom Headgear Trader]";
mes "Very well then, now select the item you want to exchange your " + .@item_name$ + " for:";
mes "^FF0000To see a list of available sprites, please talk to the Headgear NPC!^000000";
for ( .@j = 0; .@j < .num_total; .@j += 10 ) {
.@menu$ = ( .@j/10 ? "^777777Back^000000:" : ":" );
for ( .@i = .@j; .@i < .@j +10; .@i++ ) {
.@item_id = getd( ".itemid"+ ( .@i/128 ) +"["+ ( .@i%128 ) +"]" );
if ( .@item_id )
.@item_name2$ = getitemname( .@item_id );
else
.@item_name2$ = ":";
.@menu$ = .@menu$ + .@item_name2$ +":";
}
.@menu$ = .@menu$ + ( .@j/10 != .num_total/10 ? "^777777Next Page^000000" : "" );
.@s2 = select( .@menu$ ) -2;
if ( .@s2 == -1 && .@j/10 )
.@j -= 20;
else if ( .@s2 != 10 )
break;
}
.@tradeid = getd( ".itemid"+ ( ( .@j + .@s2 ) /128 ) +"["+ ( .@j + .@s2 )%128 +"]" );
next;
mes "[Custom Headgear Trader]";
mes "Please confirm that you want to use 3 Cash Points for trading your ^FF0000" + .@item_name$ + "^000000 for a ^FF0000" + getitemname(.@tradeid)+ "^000000:";
next;
if (select("Confirm:Cancel") - 1) close;
if (countitem( .@myitem_id ) == 0 || #CASHPOINTS < 3) {
mes "[Custom Headgear Trader]";
mes "It appears that you don't meet the requirements. In order to use my service, you need to have a Custom Headgear and 3 Cash Points.";
close;
}
.@identify = getd( ".@identify_"+ .@page +"["+ .@s +"]" );
.@refine = getd( ".@refine_"+ .@page +"["+ .@s +"]" );
.@attribute = getd( ".@attribute_"+ .@page +"["+ .@s +"]" );
.@card1 = getd( ".@card1_"+ .@page +"["+ .@s +"]" );
.@card2 = getd( ".@card2_"+ .@page +"["+ .@s +"]" );
.@card3 = getd( ".@card3_"+ .@page +"["+ .@s +"]" );
.@card4 = getd( ".@card4_"+ .@page +"["+ .@s +"]" );
delitem2 .@myitem_id,1, .@identify, .@refine, .@attribute, .@card1, .@card2, .@card3, .@card4;
getitem2 .@tradeid,1, .@identify, .@refine, .@attribute, .@card1, .@card2, .@card3, .@card4;
set #CASHPOINTS,#CASHPOINTS - 3;
mes "[Custom Headgear Trader]";
mes "===================================";
mes "Official Receipt";
mes "===================================";
mes "From : " + .@item_name$;
mes "To : " +getitemname(.@tradeid);
mes "===================================";
dispbottom "3 Cash Points have been deducted. Current Balance = "+#CASHPOINTS+" Cash Points.";
next;
mes "[Custom Headgear Trader]";
mes "Thank you for using my Custom Headgear trading system, " +strcharinfo(0)+ ". Have a nice day!";
close;
OnInit:
AddItem( 8005,8006,8015,8016,8017,8018,8019,8020,8021,8022,8023,8024,8025,8026,8027,8028,8029,8030,8031,8032,8033,8034,8035,8036,8037,8038,8039,8040,8041,8042,8043,8044,8045,8046,8047,8052,8053,8054,8055,8056,8057,8058,8059,8060,8062,8063,8064,8065,8066,8067,8068,8069,8070,8071,8072,8073,8074,8075,8076,8077,8078,8079,8080,8081,8082,8083,8084,8085,8086,8087,8094,8095,8098,8100,8102,8103,8104,8105,8106,8107,8108,8109,8110,8111,8112,8113,8114,8115,8116,8112,8117,8118,8119,8120,8121,8122,8123,8124,8125,8126,8127,8128,8130,8131,8132,8133,20051,20052,20053,20054,20055,20056,20057,20058,20059,20060,20061,20062,20063,20064,20065,20066,20067,20068,20069,20070,20071,20072,20073,20074,20075,20076,20077 );
// AddItem( 5009,5010,5011,5012,5013,5014,5015,5016,5017,5018,5019 );
// AddItem( 601,... );
end;
function AddItem {
.@amount = .num_total + getargcount();
.@i = .@tmp = .num_total;
while( .@i < .@amount ) {
.@arg = getarg( .@i - .@tmp );
if ( getitemname( .@arg ) != "NULL" ) {
setd ".itemid"+ ( .num_total/128 ) +"["+ ( .num_total%128 ) +"]", .@arg;
setd ".itemidcompare"+ ( .num_total/128 ) +"$", getd( ".itemidcompare"+ ( .num_total/128 ) +"$" ) +":"+ .@arg;
.num_total += 1;
if ( .num_total%128 == 0 )
setd ".itemidcompare"+ ( .num_total/128 -1 ) +"$", getd( ".itemidcompare"+ ( .num_total/128 -1 ) +"$" ) +":";
else if ( .num_total == .@amount )
setd ".itemidcompare"+ ( .num_total/128 ) +"$", getd( ".itemidcompare"+ ( .num_total/128 ) +"$" ) +":";
}
.@i++;
}
}
}
this version skip the non existent item ID