Two day ago i made this script for an npc. It did work but now when bought an item it take the money but those not give me the item why? can some explain what i need to do to fix it
Two day ago i made this script for an npc. It did work but now when bought an item it take the money but those not give me the item why? can some explain what i need to do to fix it
Can you post your NPC script.
Try cm.gainItem(ItemID, amount);
Example:
Code:if (selection == 0) { if (cm.getMesos() >= 100) { cm.getMesos(-100); cm.gainItem(4001126, 1); cm.dispose(); }
k here the code i don't seem to get it
var item = [01702044, 01442067, 01442076];
var status = 0;
function start() {
cm.sendSimple(" What do you want? They all cost 100 mesos. \r\n#L0# Toy Machine Gun #v01702044# \r\n#L1# Reverse Diesra #v 01442067# \r\n#L2# Aran polearm Maha #v01442076# ");
}
function action(mode, type, selection) {
if (mode < 1) {
cm.sendOk("#e#kOk, see you next time!");
cm.dispose();
return;
} else {
status++;
}
if (status == 1) {
if (cm.getMeso() >= 100) {
cm.gainItem(item[selection], 1);
cm.gainMeso(-100);
cm.sendOk("Thank you for your 100 #bMesos#k!");
cm.dispose();
} else {
cm.sendOk(" You do not have enough #bMesos#k. Please get some more then come back. ");
cm.dispose();
}
}
}
First of all, if you have items in an array, which the array you made is items = [];, you cannot just do a selection in the sendSimple and gain the item from the array because you are not even getting any elements from the array. Here's your NPC.
Code:items = [1702044, 1442067, 1442076]; function start() { var talk = "Which item do you want? They all cost 100 mesos.#b"; for (var i = 0; i < items.length; i++) { talk += "\r\n\t#L" + i + "#b#t" + items[i] + "##k ~ ##v" + items[i] + "##l"; } cm.sendSimple(talk); } function action(mode, type, selection) { if (mode > 0) { if (cm.getMeso() >= 100) { cm.gainItem(items[selection], 1); cm.gainMeso(-100); cm.sendOk("Thank you for your 100 #bMesos#k!"); } else { cm.sendOk(" You do not have enough #bMesos#k. Please get some more then come back. "); } } }
oh thx you to repeat what you said because i trying to learn and this is so new to me that when making an array you need to add sendsimple and not selection to get the item that i putted in the array thx for the explain