[Solved]NPC Script status problems

Results 1 to 6 of 6
  1. #1
    Novice InDepth is offline
    MemberRank
    Apr 2015 Join Date
    3Posts

    [Solved]NPC Script status problems

    The NPC exists and nothing shows up after I press next at selection 0.

    I am fairly new to npc scripting.
    Using MoopleDEV revision 120, so no errors on bat.
    If anyone could explain to me how to proceed my code from selection 0 that would be great, I am sort of confused with the whole status mechanism.
    PHP Code:
    var status;

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

    function 
    action(modetypeselection) {
        if (
    mode == 1) {
            
    status++;
        }else{
            
    status--;
        }
        if (
    status == 0) {  // NPC Start
            
    cm.sendNext("#bWelcome,#k I am here to tell you about perfect pitch!\r\n #v4310000# ");
        } else if (
    status == 1) { // Second stage
            
    cm.sendSimple("Would you like to get started? \r\n #L0# #bYes #l \r\n #L1# #rNo #l");
        } else if (
    status == 2) { // Third Stage
            
    if (selection == 0) { // selections of status 1 necessary to be under 3rd stage
                
    cm.sendNext("Here I am, watching good ol' fake taxi, when the driver's face tells me, I should make a game currency.");
                
    cm.dispose();
            } else if (
    selection == 1) { // Another selection of status 1  
                
    cm.sendOk(" You're missing good information :) ");
                
    cm.dispose();
            } else if (
    status == 3) {  // Fourth Stage
                
    cm.sendNext("And then I thought of the Perfect Pitch currency. Yep, now take this and enjoy, spend the pitch at the brown market next door, and don't come back!");
                
    cm.giveItem(4310000);            
            }
        }

    Last edited by InDepth; 14-04-15 at 11:25 PM.


  2. #2
    Moderator Eric is offline
    ModeratorRank
    Jan 2010 Join Date
    DEV CityLocation
    3,188Posts

    Re: NPC Script status problems

    the npc isn't supposed to do anything after clicking next at selection 0. you literally dispose the npc, so you've ended it correctly?

    EDIT: OH, nevermind. Your brackets are messed up. The } else if status == 3 should be the bracket below! Like this:

    PHP Code:
    var status;

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

    function 
    action(modetypeselection) {
        if (
    mode == 1) {
            
    status++;
        }else{
            
    status--;
        }
        if (
    status == 0) {  // NPC Start
            
    cm.sendNext("#bWelcome,#k I am here to tell you about perfect pitch!\r\n #v4310000# ");
        } else if (
    status == 1) { // Second stage
            
    cm.sendSimple("Would you like to get started? \r\n #L0# #bYes #l \r\n #L1# #rNo #l");
        } else if (
    status == 2) { // Third Stage
            
    if (selection == 0) { // selections of status 1 necessary to be under 3rd stage
                
    cm.sendNext("Here I am, watching good ol' fake taxi, when the driver's face tells me, I should make a game currency.");
                
    cm.dispose();
            } else if (
    selection == 1) { // Another selection of status 1  
                
    cm.sendOk(" You're missing good information :) ");
                
    cm.dispose();
            }
        } else if (
    status == 3) {  // Fourth Stage
            
    cm.sendNext("And then I thought of the Perfect Pitch currency. Yep, now take this and enjoy, spend the pitch at the brown market next door, and don't come back!");
            
    cm.giveItem(4310000);            
        }


  3. #3
    Novice InDepth is offline
    MemberRank
    Apr 2015 Join Date
    3Posts

    Re: NPC Script status problems

    Strange! still doesn't work :C
    Nothing happens after I press next.
    Thanks for helping though :)

  4. #4
    :l Cygnus is offline
    MemberRank
    Mar 2015 Join Date
    f425Location
    237Posts

    Re: NPC Script status problems

    Code:
    var status;
    
    function start() {
        status = -1;
        action(1, 0, 0);
    }
    
    
    function action(mode, type, selection) {
        if (mode == 1) {
            status++;
        }else{
            status++;
        }
        if (status == 0) {  // NPC Start
            cm.sendNext("#bWelcome,#k I am here to tell you about perfect pitch!\r\n#v4310000#");
        } else if (status == 1) { // Second stage
            cm.sendSimple("Would you like to get started? \r\n #L1# #bYes #l \r\n #L0# #rNo #l");
        } else if (status == 2) { // Third Stage
           if (selection == 0) { // Another selection of status 1  
                cm.sendOk(" You're missing good information :) ");
                cm.dispose();
           }
            else if (selection == 1) { // selections of status 1 necessary to be under 3rd stage 
                cm.sendNext("Here I am, watching good ol' fake taxi, when the driver's face tells me, I should make a game currency.");
            }
            } else if (status == 3) {  // Fourth Stage
                cm.sendNext("And then I thought of the Perfect Pitch currency. Yep, now take this and enjoy, spend the pitch at the brown market next door, and don't come back!");
                cm.giveItem(4310000);   
                cm.dispose();
            }
        }
    Not sure if giveItem is correct? I use cm.gainItem for my source.
    Last edited by Cygnus; 14-04-15 at 07:53 AM.

  5. #5
    Moderator Eric is offline
    ModeratorRank
    Jan 2010 Join Date
    DEV CityLocation
    3,188Posts

    Re: NPC Script status problems

    Quote Originally Posted by InDepth View Post
    Strange! still doesn't work :C
    Nothing happens after I press next.
    Thanks for helping though :)
    Oh sorry, take out "cm.dispose" in every "selection", and then put cm.dispose after cm.giveItem. Afterwards, change giveItem to gainItem as giveItem doesn't exist in OdinMS sources.

  6. #6
    Novice InDepth is offline
    MemberRank
    Apr 2015 Join Date
    3Posts

    Re: NPC Script status problems

    Thanks guys <3
    It works!
    cm.giveItem is indeed a non-existant command.
    Last time I scripted was 3 years ago ^_^



Advertisement