[Help] Npc script

Results 1 to 14 of 14
  1. #1
    Enthusiast Karan Singh is offline
    MemberRank
    Oct 2012 Join Date
    42Posts

    [Help] Npc script

    ok so i want to make a npc script where it gives you a golden maple leaf (4000313) if you have 1mil+ and it will close if you dont and not give you the leaf...the problem is the script i made a while ago took the mesos and give you the leaf but if you have less than 1mil then it will give you the leaf either way...i want it to be like if you dont have mesos it closes i: can someone please give me a script similar to that if they have one? i want to try and remake it or show me the correct way to code it? i am new and i looked at shaws tutorial wasn't really much help for me so can someone help me out?


  2. #2
    Nae-un <33 Thane Krios is offline
    MemberRank
    Jun 2012 Join Date
    CaliforniaLocation
    568Posts

    Re: [Help] Npc script

    Code:
    var cost = 1000000;
    var m = 4000313;
    
    function start() {
    	if (cm.getMeso()<cost) {
    		cm.sendOk("You don't have enough mesos.");
    	} else {
    		cm.gainMeso(-cost);
    		cm.gainItem(m);
    	}
    	cm.dispose();
    }
    Very basic. It doesn't let you choose how many leaves you want. Instead it only gives 1 leaf per million mesos.

  3. #3
    Enthusiast Karan Singh is offline
    MemberRank
    Oct 2012 Join Date
    42Posts

    Re: [Help] Npc script

    Quote Originally Posted by Thane Krios View Post
    Code:
    var cost = 1000000;
    var m = 4000313;
    
    function start() {
    	if (cm.getMeso()<cost) {
    		cm.sendOk("You don't have enough mesos.");
    	} else {
    		cm.gainMeso(-cost);
    		cm.gainItem(m);
    	}
    	cm.dispose();
    }
    Very basic. It doesn't let you choose how many leaves you want. Instead it only gives 1 leaf per million mesos.
    it doesnt give any leafs ._. just takes your mesos
    Last edited by Karan Singh; 11-11-12 at 09:07 PM.

  4. #4
    Nae-un <33 Thane Krios is offline
    MemberRank
    Jun 2012 Join Date
    CaliforniaLocation
    568Posts

    Re: [Help] Npc script

    Did you make sure your inventory can hold the leaves?

  5. #5
    Enthusiast Karan Singh is offline
    MemberRank
    Oct 2012 Join Date
    42Posts

    Re: [Help] Npc script

    Quote Originally Posted by Thane Krios View Post
    Did you make sure your inventory can hold the leaves?
    i already have some in my inv >_>

  6. #6
    Nae-un <33 Thane Krios is offline
    MemberRank
    Jun 2012 Join Date
    CaliforniaLocation
    568Posts

    Re: [Help] Npc script

    I don't know what to say. The code is right there.

  7. #7
    Enthusiast Karan Singh is offline
    MemberRank
    Oct 2012 Join Date
    42Posts

    Re: [Help] Npc script

    Quote Originally Posted by Thane Krios View Post
    I don't know what to say. The code is right there.
    how a meso exchange code? like exchange mesos for it?

  8. #8
    Nae-un <33 Thane Krios is offline
    MemberRank
    Jun 2012 Join Date
    CaliforniaLocation
    568Posts

    Re: [Help] Npc script

    Quote Originally Posted by Karan Singh View Post
    how a meso exchange code? like exchange mesos for it?
    The script takes 1 million from you, and gives you 1 leaf. It's right there.
    Code:
    var cost = 1000000;
    var m = 4000313;
    
    function start() {
    	if (cm.getMeso()<cost) {
    		cm.sendOk("You don't have enough mesos.");
    	} else {
    		cm.gainMeso(-cost); Gives you negative of cost, which is 1000000. In sense, it gives you -1000000 mesos. In English, you have lost 1 million mesos.
    		cm.gainItem(m); Gives you positive m, which in this case is a placeholder for 4000313, your golden maple leaf. It gives you one golden maple leaf.
    	}
    	cm.dispose();
    }

  9. #9
    Enthusiast Karan Singh is offline
    MemberRank
    Oct 2012 Join Date
    42Posts

    Re: [Help] Npc script

    Quote Originally Posted by Thane Krios View Post
    The script takes 1 million from you, and gives you 1 leaf. It's right there.
    Code:
    var cost = 1000000;
    var m = 4000313;
    
    function start() {
    	if (cm.getMeso()<cost) {
    		cm.sendOk("You don't have enough mesos.");
    	} else {
    		cm.gainMeso(-cost); Gives you negative of cost, which is 1000000. In sense, it gives you -1000000 mesos. In English, you have lost 1 million mesos.
    		cm.gainItem(m); Gives you positive m, which in this case is a placeholder for 4000313, your golden maple leaf. It gives you one golden maple leaf.
    	}
    	cm.dispose();
    }
    yes, yes i know that but i meant like people can select the amount

  10. #10
    Alpha Member TiredGuy is offline
    MemberRank
    Mar 2012 Join Date
    Behind YouLocation
    1,527Posts

    Re: [Help] Npc script

    cm.gainItem(m, amount);

    put this on top
    var amount = 1; change to whatever u want

  11. #11
    Enthusiast Karan Singh is offline
    MemberRank
    Oct 2012 Join Date
    42Posts

    Re: [Help] Npc script

    Quote Originally Posted by TiredGuy View Post
    cm.gainItem(m, amount);

    put this on top
    var amount = 1; change to whatever u want
    ty so much both of :) also tired long time no see bro~

  12. #12
    Proficient Member MtSaEt is offline
    MemberRank
    Aug 2010 Join Date
    167Posts

    Re: [Help] Npc script

    Here's a complete script of what you want! :)
    PHP Code:
    var status 0
    var 
    amount;
    var 
    mesos 1000000;
    var 
    golden 4000313;

    function 
    start() {
        
    status = -1
        
    action(100); 


    function 
    action(modetypeselection) {

        if (
    mode == -1) {
            
    cm.dispose(); 
        } else if (
    mode == 0){
            
    cm.dispose(); 
        } else {            
            if (
    mode == 1
                
    status++; 
            else 
                
    status--; 
            if (
    status == 0) {
                
    cm.sendNext("Hi there! I am the #b#t"golden +"##k seller!");
            } else if (
    status == 1) {
                if (
    cm.getPlayer().getMeso() < mesos) {
                    
    cm.sendOk("You don't have enough mesos! You need atleast #b#e1,000,000#k#n mesos");
                    
    cm.dispose();
                }
                
    cm.sendGetNumber("#rHow many #t"golden +"#'s#k do you want?#k\r\n(1 million mesos each)."01cm.getPlayer().getMeso() / mesos);

            } else if (
    status == 2) {
                
    amount selection;
                
    cm.sendYesNo("Are you sure you want #r"amount +"#k #b#t"golden +"##k?");
            } else if (
    status == 3) {
                if (
    cm.getPlayer().getMeso() >= amount mesos) {
                    
    cm.gainItem(goldenamount);
                    
    cm.gainMeso(- amount*mesos);
                    
    cm.sendOk("There you go!");
                    
    cm.dispose();
                } else {
                    
    cm.sendOk("You don't have enough mesos!");
                    
    cm.dispose();
                }
            }
        }


  13. #13
    Valued Member nickblaster is offline
    MemberRank
    Jun 2011 Join Date
    behind youLocation
    134Posts

    Re: [Help] Npc script

    why is everyone defining the variables for such a short script -.-

  14. #14
    Nae-un <33 Thane Krios is offline
    MemberRank
    Jun 2012 Join Date
    CaliforniaLocation
    568Posts

    Re: [Help] Npc script

    Quote Originally Posted by nickblaster View Post
    why is everyone defining the variables for such a short script -.-

    I define variables for convenience. Also, I like to include them in my script for easy manipulation. When the script is seen by others they can find information without difficulty. To me it doesn't matter how short the script is, although it is important, but also as an easier way for my mind to integrate and absorb information.



Advertisement