[Release]Chair Vendor

Experienced Elementalist
Joined
May 29, 2008
Messages
258
Reaction score
0
Ok so heres a simple npc script that sells chairs

PHP:
//Kippieeej for the base of the script,Brianobb For editing it to this function
var status = 0;
 
function start() {
    status = -1;
    action(1, 0, 0);
}
 
function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.dispose();
            return;
        }
        if (mode == 1)
            status++;
        else
            status--;
        if (status == 0) {
                cm.sendSimple("Hello #h #, Welcome to #rSaphireMs#k\r\nWould you like to buy a chair\r\n \r\nWhich Chair would you like  \r\n#L1##bBuy a #v3010002##k#l \r\n \r\n#L2##bBuy 1 #v3010008# #k#l \r\n \r\n#L3##bBuy 1  #v3010012##l \r\n \r\n#L4##bBuy 1 #v3010014# #l \r\n \r\n#L5##bBuy 1 #v3010007##l \r\n \r\n#L6##bBuy 1 #v3011000# #l");
        //cm.dispose();
            } else if (status == 1) {
            if (selection == 1) {
    if (cm.itemQuantity(5200002) >= 50) {
    cm.sendOk(" I Think you have enough #v5200002# saved up, try spending some of your mesos, and cashing in a few #v5200002# before you buy more.");
    cm.dispose();
         }  else if (cm.getMeso() >= 100) {
                    cm.gainMeso(-100);                
                    cm.gainItem(3010002, 1); 
                    cm.dispose();
                } else {
                    cm.sendOk("You don't have enough #bMesos#k, are you trying to #eScam#k me!?");
                    cm.dispose();
                }     
                         
          } else if (selection == 2) {
    if (cm.itemQuantity(5200000) >= 50) {
    cm.sendOk(" I Think you have enough #v5200001# saved up, try spending some of your mesos, and cashing in a few #v5200001# before you buy more.");
    cm.dispose();
         }  else if (cm.getMeso() >= 100) {
                    cm.gainMeso(-100);                
                    cm.gainItem(3010008, 1); 
                    cm.dispose();
                } else {
                    cm.sendOk("You don't have enough #bMesos#k, are you trying to #eScam#k me!?");
                    cm.dispose();
                }     
                         
     } else if (selection == 3) {
    if (cm.itemQuantity(5200000) >= 50) {
    cm.sendOk(" I Think you have enough #v5200001# saved up, try spending some of your mesos, and cashing in a few #v5200001# before you buy more.");
    cm.dispose();
    } else if (cm.getMeso() >= 100) {
                    cm.gainMeso(-100);                
                    cm.gainItem(3010012, 1); 
                    cm.dispose();
                   }
     } else if (selection == 4) {
    if (cm.itemQuantity(5200000) >= 50) {
    cm.sendOk(" I Think you have enough #v5200001# saved up, try spending some of your mesos, and cashing in a few #v5200001# before you buy more.");
    cm.dispose();
    } else if (cm.getMeso() >= 100) {
                    cm.gainMeso(-100);                
                    cm.gainItem(3010014, 1); 
                    cm.dispose();
                   }
            } else if (selection == 5) {
    if (cm.itemQuantity(5200000) >= 50) {
    cm.sendOk(" I Think you have enough #v5200000# saved up, try spending some of your mesos, and cashing in a few #v5200000# before you buy more.");
    cm.dispose();
    } else if (cm.getMeso() >= 100) {
                    cm.gainMeso(-100);                
                    cm.gainItem(3010007, 1); 
                    cm.dispose();
            }
    } else if (selection == 6) {
    if (cm.itemQuantity(5200000) >= 50) {
    cm.sendOk(" I Think you have enough #v5200000# saved up, try spending some of your mesos, and cashing in a few #v5200000# before you buy more.");
    cm.dispose();
    } else if (cm.getMeso() >= 100) {
                    cm.gainMeso(-100);                
                    cm.gainItem(3011000, 1); 
                    cm.dispose();
                    }    
                }
            }
        }
    }

brianobb - [Release]Chair Vendor - RaGEZONE Forums

brianobb - [Release]Chair Vendor - RaGEZONE Forums
 
Last edited:
lol im gona use this it seems like an awesome idea+myshops r messed up cuz i tried to change it haha

i only take credits for adding the items and making the script adjusted i dont take credits for the base i used the meso bank script ^.^ im gonna be basing alot of shops on this^.^
 
tanku i worked an hour or so on this ask anyone on my server this is my first real complex npc i basicaly make game npcs and fun stuff

Edit: Added pictures / tooken by one of my gms

LOL you picked the nubchair maker npc
hmm... i should make them a quest haha
 
Arrays are better in this case.

not to mention, that if you select any option but the first 2, and you don't have 100 mesos.. it will crash.

PHP:
var status = -1;
var chair = Array(3010002,3010008,3010012,3010014,3010007,3011000);
function start() {
    action(1, 0, 0);
}
 
function action(mode, type, selection) {
    if (mode != 1) {
        cm.dispose();
		return;
    } else 
        status++;
    if (status == 0) {
        var text = "Hello #h #, Welcome to #rSaphireMs#k\r\nWould you like to buy a chair\r\n \r\nWhich Chair would you like?";
		for(var i = 0; i < chair.length() ; i++)
		    text += "\r\n#L" + i + "##b #i" + chair[i] + "# #t"+ chair[i] +  "##l";
	    cm.sendSimple(text);
    } else if (status == 1) {
            if (cm.getMeso() >= 100) {
                cm.gainMeso(-100);                
                cm.gainItem(chair[selection], 1);
            }else
                cm.sendOk("You don't have enough #bMesos#k, are you trying to #eScam#k me!?");
            cm.dispose();
    }
}
 
Last edited:
Code:
//Sora of YourStory
var status = 0;
var love = Array(3010002, 3010008, 3010012, 3010014, 3010007, 3011000);
var money = Array(-200, -200, -200, -200, -200, -200);
function start() {
    status = -1;
    action(1, 0, 0);
}
 
function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.sendOk("comback");
			cm.dispose();
            return;
        }
        if (mode == 1)
            status++;
        else
            status--;
        if (status == 0) {
                cm.sendSimple("Hello #h #, Welcome to #rSaphireMs#k\r\nWould you like to buy a chair\r\n \r\nWhich Chair would you like  \r\n#L0##bBuy a #v3010002##k#l \r\n \r\n#L1##bBuy 1 #v3010008# #k#l \r\n \r\n#L2##bBuy 1  #v3010012##l \r\n \r\n#L3##bBuy 1 #v3010014# #l \r\n \r\n#L4##bBuy 1 #v3010007##l \r\n \r\n#L5##bBuy 1 #v3011000# #l");
        //cm.dispose();
            } else if (status == 1) {
            if (cm.getMeso() >= 200) {
	cm.gainItem(love[selection]);
	cm.gainMeso(money[selection]);
	cm.sendOk(" Hope you like  #v" + love[selection] + "# chair.");
    cm.dispose();
         } else {
                    cm.sendOk("You don't have enough #bMesos#k, are you trying to #eScam#k me!?");
                    cm.dispose();
                }     
                         
          
            }
        }
    }
even better
 
Arrays are better in this case.

not to mention, that if you select any option but the first 2, and you don't have 100 mesos.. it will crash.

PHP:
var status = -1;
var chair = Array(3010002,3010008,3010012,3010014,3010007,3011000);
function start() {
    action(1, 0, 0);
}
 
function action(mode, type, selection) {
    if (mode != 1) {
        cm.dispose();
		return;
    } else 
        status++;
    if (status == 0) {
        var text = "Hello #h #, Welcome to #rSaphireMs#k\r\nWould you like to buy a chair\r\n \r\nWhich Chair would you like?";
		for(var i = 0; i < chair.length() ; i++)
		    text += "\r\n#L" + i + "##b #i" + chair[i] + "# #t"+ chair[i] +  "##l";
	    cm.sendSimple(text);
    } else if (status == 1) {
            if (cm.getMeso() >= 100) {
                cm.gainMeso(-100);                
                cm.gainItem(chair[selection], 1);
            }else
                cm.sendOk("You don't have enough #bMesos#k, are you trying to #eScam#k me!?");
            cm.dispose();
    }
}

Correct me if I am wrong but shouldn't "var status = -1;" be "var status = 0;"?
And can you do } else not } else { ?
And why can't you do cm.sendSimple(Hello #h #, Welcome to #rSaphireMs#k\r\nWould you like to buy a chair\r\n \r\nWhich Chair would you like?); instead of using var?
 
Correct me if I am wrong but shouldn't "var status = -1;" be "var status = 0;"?
And can you do } else not } else { ?
And why can't you do cm.sendSimple(Hello #h #, Welcome to #rSaphireMs#k\r\nWould you like to buy a chair\r\n \r\nWhich Chair would you like?); instead of using var?

Wrong.
 
Back