shop custom_seller21 -1,673:1000000 // Create our dummy shop.
prontera,150,150,4 script [Máquina Cartas] 564,{
// This code runs when the user clicks our npc.
mes "[^FF2400Cuidado^000000] Escolha um item!"; // Let the user know about our shop.
callshop "custom_seller21",1; // Summon our dummy shop filled with custom items.
npcshopattach "custom_seller21"; // Attach the shop to this npc.
end;
// This code runs when a user purchases an item from out shop.
OnBuyItem:
.@len = getarraysize(.customs); // Get the number of customs we're adding.
.@b_len = getarraysize(@bought_nameid); // Get the number of purchased items.
for( set @i, 0; @i < .@len; set @i, @i+1 ) {
for( set @d,0; @d < .@b_len; set @d, @d+1 ) {
if( @bought_nameid[@d] == .customs[@i] ) { // Check if the purchased item equals our custom item.
if( countitem(.CoinID) >= .Price[@i] * @bought_quantity[@d] ) { // Check if the user has the correct funds.
delitem .CoinID,.Price[@i]*@bought_quantity[@d];
getitem @bought_nameid[@d],@bought_quantity[@d];
}
}
}
}
deletearray @bought_quantity, getarraysize(@bought_quantity); // Remove the array.
deletearray @bought_nameid, getarraysize(@bought_nameid); // Remove the array.
close;
// Npc walks every 10 sec
OnTimer10000:
.@x = .npc_x + rand( -10,10 );
.@y = .npc_y + rand( -10,10 );
npcwalkto .@x,.@y;
setnpctimer 0;
end;
// This code runs first. When the server is started.
OnInit:
setarray .customs[0],4035,4060,4063; // An array of out custom items.
set .CoinID,1226; // ID da Moeda em uso.
setarray .Price[0],500,500,500; // The amount of coins needed for our items. (For example: Item 12103 = 20 coins)
npcshopitem "custom_seller21",0,0; // Remove all items from our dummy shop.
for( set .@i, 0; .customs[.@i]; set .@i, .@i+1 ) // Loop through our custom items.
npcshopadditem "custom_seller10",.customs[.@i],.Price[.@i]; // Add our custom items to the cleared dummy shop.
npcspeed 200;
getmapxy( .npc_map$, .npc_x, .npc_y,1 );
initnpctimer;
end;
end;
}