- Joined
- Oct 15, 2008
- Messages
- 2,898
- Reaction score
- 1,131
This script is officially 100% working now.
I apologize for the previous release not working. Everything has been sorted now, as well as an additional function with a cm.sendOk that will display the item you won.
Ok... this NPC is pretty basic. When you talk to the NPC, you will see 6 Presents. Out of the 6 presents, only 1 of them has a rare/really good item, like a chaos scroll or w/e you choose to best fit your server. 2 of them have decent items, such as 60% scrolls, or again... whatever you think would best fit your server. Lastly, 3 of them will have crap items, usually red/white/blue potions. All items are customizable to best fit your server in the above vars.
NOTE: YOU ARE NOT LIMITED TO THE AMOUNT OF ITEMS IT HAS. YOU CAN ADD AS MANY AS YOU WANT, BUT IT'S ALL DONE AT A MATH RANDOM.
The NPC will always change what position the prizes are in every time you talk to it as well. Here's an example:
and so on and so forth... In short, it's a gambling NPC. You need a specific item to use it. It takes the item and shows you the presents. If you are going to use this for your server, I suggest using an item that is semi hard to get to be able to use this NPC. Example: If you have a Maple Leaf trading system, make this NPC take Maple Leafs.
Here is the script.
Screenshots are below.
Credits: Me (bboy242 aka Shawn)
Special Thanks: Osiris, for teaching me, and helping me alot with math randoms. Thank you Osiris for fixing the boolean error. There were other errors after that, but I fixed them xD
@Off Topic: I have never seen anything like this before, only similar things, so if this by some random chance has been released before, feel free to let me know.
@Off-Off Topic: This is my 3rd Release o.0 Go ahead and flame if you wish. You don't need to use it if you don't want to, plain and simple.
Thank you all that choose to use this and please leave proper credits.
Please thank me if you like/use this xD
Screenshots
I apologize for the previous release not working. Everything has been sorted now, as well as an additional function with a cm.sendOk that will display the item you won.
Ok... this NPC is pretty basic. When you talk to the NPC, you will see 6 Presents. Out of the 6 presents, only 1 of them has a rare/really good item, like a chaos scroll or w/e you choose to best fit your server. 2 of them have decent items, such as 60% scrolls, or again... whatever you think would best fit your server. Lastly, 3 of them will have crap items, usually red/white/blue potions. All items are customizable to best fit your server in the above vars.
NOTE: YOU ARE NOT LIMITED TO THE AMOUNT OF ITEMS IT HAS. YOU CAN ADD AS MANY AS YOU WANT, BUT IT'S ALL DONE AT A MATH RANDOM.
The NPC will always change what position the prizes are in every time you talk to it as well. Here's an example:
Code:
[B]First time talking to NPC
[crap] [crap]
[good] [crap]
[rare] [good][/B]
Code:
[B]Second time talking to NPC
[rare] [good]
[crap] [crap]
[good] [crap][/B]
Here is the script.
PHP:
/**
Gift Box NPC
Based off of Gachapon
Coded by: bboy242 of RageZone aka Shawn with help from X-Tasis aka Osiris
Special Thanks: X-Tasis aka Osiris for attempting to teach me randoms and arrays better xD
**/
var status;
var boxes = [4000422, 4000423, 4000424, 4000425, 4031168, 4031169]; // Boxes to choose from
var prize = [[crapitem, crapitem, crapitem, crapitem, crapitem, crapitem], [gooditem, gooditem, gooditem, gooditem], [rareitem, rareitem]]; // Add your prizes here
var rand = Math.floor(Math.random()*100);
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
}else{
if (status >= 5 && mode == 0) {
cm.sendOk("See you next time!.");
cm.dispose();
return;
}
if (mode == 1) {
status++;
}else{
status--;
}
if (status == 0) {
if (cm.haveItem(itemid, 1)) { // You choose what item.
cm.gainItem(itemid, -1); // You choose what item, same as above
cm.sendNext("Step right up and test your luck. See if you can win an amazing prize by guessing the correct box!");
}else{
cm.sendOk("You don't have the right item.");
cm.dispose();
}
} else if (status == 1) {
cm.sendNext("Do you feel lucky?");
} else if (status == 2) {
for(var i = 0, text = "Choose one of the prize below.\r\n\r\n"; i < boxes.length; text += "\t\t#L" + i + "##i" + boxes[i] + "##l" + ((i+1) % 2 == 0 ? "\r\n" : ""), i++);
cm.sendSimple(text);
} else if (status == 3) {
cm.sendYesNo("Do you want to choose #i" + boxes[selection] + "#?");
} else if (status == 4) {
var rand2;
if ((rand >= 1) && (rand <= 50)) {
rand2 = Math.floor(Math.random() * prize[0].length);
} else if ((rand >= 51) && (rand <= 90)) {
rand2 = Math.floor(Math.random() * prize[1].length);
}else{
rand2 = Math.floor(Math.random() * prize[2].length);
}
cm.gainItem([rand >= 1 && rand <= 50 ? prize[0][rand2] : rand >= 51 && rand <= 90 ? prize[1][rand2] : prize[2][rand2]]);
cm.sendOk("You have won a #v" + [rand >= 1 && rand <= 50 ? prize[0][rand2] : rand >= 51 && rand <= 90 ? prize[1][rand2] : prize[2][rand2]] + "#");
cm.dispose();
}
}
}
Credits: Me (bboy242 aka Shawn)
Special Thanks: Osiris, for teaching me, and helping me alot with math randoms. Thank you Osiris for fixing the boolean error. There were other errors after that, but I fixed them xD
@Off Topic: I have never seen anything like this before, only similar things, so if this by some random chance has been released before, feel free to let me know.
@Off-Off Topic: This is my 3rd Release o.0 Go ahead and flame if you wish. You don't need to use it if you don't want to, plain and simple.
Thank you all that choose to use this and please leave proper credits.
Please thank me if you like/use this xD
Screenshots
Last edited:

