[NPC] can't for the love of god get this working right

Results 1 to 3 of 3
  1. #1
    (O_o(o_O(O_O)o_O)O_o) Novak is offline
    MemberRank
    Apr 2009 Join Date
    The NetherlandsLocation
    1,120Posts

    [NPC] can't for the love of god get this working right

    So yeah, i can't get it to both print a message for wildhunters, and warp them to the map. It's either one thing, or the other.

    I tried as many things as i could imagine, just can't get it working.

    Don't mind the way it looks now, this is one of the last things I tried to make it work.
    I know it can be a lot shorter.

    PHP Code:
    /* 
        NPC Name:         Shanks
        Map(s):         Maple Road : Southperry (60000)
        Description:     Select job and warp to Victoria Island
    */
    var job = [ 
    [[
    100"Warrior"], [200"Magician"], [300"Bowman"], [400"Thief"], [500"Pirate"]], 
    [[
    1100"Dawn Warrior"], [1200"Blaze Wizard"], [1300"Wind Archer"], [1400"Night Walker"], [1500"Thunder Breaker"]], 
    [[
    3200"Battle Mage"], [3300"Wild Hunter"], [3500"Mechanic"]], 
    [[
    110"Fighter"], [120"Page"], [130"Spearman"]], 
    [[
    210"Wizard (F/P)"], [220"Wizard (I/L)"], [230"Cleric"]], 
    [[
    310"Hunter"], [320"Crossbow Man"]], 
    [[
    410"Assassin"], [420"Bandit"]], 
    [[
    510"Brawler"], [520"Gunslinger"]],
    [[
    3100"Demon Slayer"], [3101"Demon Avenger"]]]; 
    var 
    status 0
    var 
    select;
    var 
    destination = [2010000310010000]; //Lith Harbor

    function jobSelection(index) { 
        var 
    choose "Please, select your job:" 
        
    for (var 0job[index].lengthi++) 
            
    choose += "\r\n#L" job[index][i][0] + "#" job[index][i][1] + "#l"
        
    cm.sendSimple(choose); 
    }  

    function 
    starterpack() { 
        
    cm.gainItem(11020411); // Pink Advent Cape 
        
    cm.gainItem(11020421); // Purple Advent Cape 
        
    cm.gainItem(30100001); // Beginner Chair 
        
    cm.gainItem(200000550); // 50 Power Elixir
        
    cm.gainItem(10821461); // Yellow WG 
        
    leave();
    }

    function 
    leave() {
            switch(
    status){
                case 
    4:
                    
    cm.maxSkillsByJob();
                    
    cm.sendNextNoESC(cm.getPlayer().getJob() == 3300 "You will now be transported to the resistance HQ.\r\n\r\n#rIn here, talk to Belle. #bShe gives you the catch jaguar skill#k\r\n\r\nThen please #rspeak to Black Jack and enter a room.\r\n\r\n#bThen get down the HP of a jaguar, and use your catch skill to obtain the mount." "Welcome to Victoria Island! Enjoy your stay!~");
                    break;
                case 
    5:
                    
    cm.warp(cm.getPlayer().getJob() == 3300 destination[1] : destination[0], 0);
                    
    cm.dispose();
                    break;
                default:
                    
    cm.sendOk("something went wrong, we could not warp you. Please inform us on the forums.\r\n"
                                
    "status:" status ".");
                    
    cm.dispose();
                    break;
                }
    }

    function 
    proccespackage() {
         switch (
    cm.getPlayer().getJob()) { 
                case 
    100:
                case 
    1100:
                case 
    2000:
                case 
    2100:
                case 
    3100:
                case 
    5100:
                case 
    6000//warriors (aran/ demons/ Kaiser/ mihile included)
                    
    cm.gainItem(14420711); // Seraphim Polearm 
                    
    cm.gainItem(14420501); // Seraphim Spear 
                    
    cm.gainItem(14020531); // Seraphim 2-H Sword 
                    
    cm.gainItem(14120351); // Seraphim 2-H Axe 
                    
    cm.gainItem(14220391); // Seraphim 2-H Blunt Weapon (Mace) 1302033
                    
    cm.gainItem(13020331); // 1-H sword 
                    
    starterpack();
                    break; 
                case 
    200:
                case 
    1200:
                case 
    2200:
                case 
    2201:
                case 
    3200//mages (evan/ BM included)
                    
    cm.gainItem(13720461); // Seraphim Wand 
                    
    cm.gainItem(13820621); // Seraphim Staff
                    
    starterpack();
                    break;
                case 
    300:
                case 
    1300:
                case 
    3300:
                case 
    2300//archers (mercedes, WH included)
                    
    cm.gainItem(14520621); // Seraphim Bow 
                    
    cm.gainItem(14620561); // Seraphim Cross bow 
                    
    cm.gainItem(20600015000); // Arrows   
                    
    cm.gainItem(20610035000); // X-Box arrows.
                    
    cm.gainItem(13520001); // magic arrows. 
                    
    cm.gainItem(15220001); // dual bowgun
                    
    starterpack();
                    break;
                case 
    400:
                case 
    1400:
                case 
    430:
                case 
    431//thieves (dual blade included)
                    
    cm.gainItem(20700015000); // Stars   
                    
    cm.gainItem(13320811); // Seraphim Dagger 
                    
    cm.gainItem(14720771); // Seraphim Claw 
                    
    cm.gainItem(13420471); // katara
                    
    starterpack();
                    break;
                case 
    500:
                case 
    1500:
                case 
    3500
                case 
    530:
                case 
    507
                case 
    508//pirates (mech/ cannoneer included)
                    
    cm.sendOk("You are obliged to receive the Pirate package!");
                    
    cm.gainItem(14820291); // Seraphim Knuckles 
                    
    cm.gainItem(14920001); // pistol
                    
    cm.gainItem(2300000100); // bullets
                    
    cm.gainItem(2300000100); // bullets
                    
    cm.gainItem(2300000100); // bullets
                    
    cm.gainItem(15320001); // cannon
                    
    starterpack();
                    break;
                case 
    2400//phantom
                    
    cm.gainItem(13620001); // cane
                    
    cm.gainItem(13521001); // carte magique
                    
    cm.maxSkillsByJob();
                    
    starterpack();    
                    break;
                case 
    6500//angelic buster
                    
    cm.gainItem(12220621); // Soul Shooter
                    
    cm.gainItem(13526011); // Soul ring
                    
    starterpack();
                case 
    2710//luminous
                    
    cm.gainItem(12120861); // Lumi Stick thingy (expires after relog)
                    
    cm.gainItem(12120011); // Lumi Stick thingy
                    
    cm.gainItem(13524001); // Light orb
                    
    starterpack();
                    break;
                case 
    3600//Xenon
                    
    cm.gainItem(12420011); // xenon blade thingy
                    
    starterpack();
                    break;
                case 
    4100://hayato
                    
    cm.gainItem(15420491); // katana
                    
    starterpack();
                case 
    4200://kanna
                    
    cm.gainItem(15520001); // fan
                    
    starterpack();
                default:
                    
    cm.sendOk("Hi there! Something went wrong in giving you a starter package and warping you! This might be because you are a job that is currently unknown to us, if so, report it at the forums!")
                    
    cm.dispose();
         }
    }

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


    function 
    action(modetypeselection) { 
        if (
    mode == 1
            
    status++; 
        else if (
    mode == -1
            
    status--; 
        else { 
            
    cm.dispose(); 
            return; 
        } 
        if (
    status == 0) { 
            if (
    cm.getPlayer().getLevel() >= 10 && cm.getPlayer().getLevel() < 50 
                
    cm.sendYesNo("Oh hello there! Here comes a though decision:\r\n\r\nEither stay on your current path, or change it by selecting a different job."); 
            else { 
                
    cm.sendOk("You may not advance yet. You must be at least lvl 10 and below lvl 50 to proceed."); 
                
    cm.dispose(); 
            } 
        } else if (
    status == 1) { 
            
    cm.sendSimple("Please, pick a job:\r\n\r\n" 
            
    "#L0#Adventurer#l\r\n" +
            
    "#L1000#Knight of Cygnus#l\r\n" +
            
    "#L3000#Resistance#l\r\n" 
            
    "#L3001#Demon#l\r\n" +
            
    "#L501#Cannoneer#l\r\n" +
            
    "#L2000#Aran#l\r\n" +
            
    "#L2001#Evan#l\r\n" +
            
    "#L2002#Mercedes#l\r\n" +
            
    "#L2003#Phantom#l\r\n" +
            
    "#L2004#Luminous#l\r\n" +
            
    "#L3002#Xenon#l\r\n" +
            
    "#L6000#Kaiser#l\r\n" 
            
    "#L6001#Angelic Buster#l\r\n" +
            
    "#L2000#Aran#l\r\n" +
            
    "#L4001#Hayato#l\r\n" +
            
    "#L4002#Kanna#l\r\n" +
            
    "#L5000#Mihile#l\r\n" +
            
    "#L2000#Aran#l\r\n" +
            
    "#L10000#Zero#l\r\n" +
            
    "#L430#Dual Blade#l\r\n");
        }else if (
    status == 2) {
            switch (
    selection) { 
                case 
    0// Adventurer
                    
    jobSelection(0); 
                    break; 
                case 
    1000// Cygnus knight
                    
    jobSelection(1); 
                    break; 
                case 
    3000// Resistance
                    
    jobSelection(2); 
                    break; 
                case 
    3001// Demon 
                    
    jobSelection(8); 
                    break; 
                
    //Special Jobs 
                
    case 501// Pirate(Cannoneer) 
                    
    cm.getPlayer().changeJob(530); 
                    
    proccespackage();
                    break; 
                case 
    2000// Legend(Aran) 
                    
    cm.getPlayer().changeJob(2100); 
                    
    proccespackage(); 
                    break; 
                case 
    2001// Farmer(Evan) 
                    
    cm.getPlayer().changeJob(2200); 
                    
    proccespackage(); 
                    break; 
                case 
    2002// Mercedes 
                    
    cm.getPlayer().changeJob(2300); 
                    
    proccespackage(); 
                    break; 
                case 
    2003// Phantom Jr. 
                    
    cm.getPlayer().changeJob(2400); 
                    
    proccespackage();
                    break;
                case 
    2004// Luminous
                    
    cm.getPlayer().changeJob(2710); 
                    
    proccespackage();
                    break; 
                case 
    3002// Xenon 
                    
    cm.getPlayer().changeJob(3600); 
                    
    proccespackage(); 
                    break;
                case 
    6000// Kaiser 
                    
    cm.getPlayer().changeJob(6100); 
                    
    proccespackage(); 
                    break; 
                case 
    6001// Angelic Buster 
                    
    cm.getPlayer().changeJob(6500); 
                    
    proccespackage();
                    break;
               
    /* case 11000: // Beast Tamer  
                    cm.getPlayer().changeJob(11200); 
                    proccespackage();
                    break; */
                
    case 4001// Hayato  
                    
    cm.getPlayer().changeJob(4100); 
                    
    proccespackage();
                    break;
                case 
    4002// Kanna
                    
    cm.getPlayer().changeJob(4200); 
                    
    proccespackage();
                    break;
                case 
    5000// Mihile
                    
    cm.getPlayer().changeJob(5100); 
                    
    proccespackage();
                    break; 
                case 
    10000// Zero
                    
    cm.getPlayer().changeJob(10000);
                    
    proccespackage();
                    break;
                case 
    430// Dual Blade
                    
    cm.getPlayer().changeJob(430);
                    
    proccespackage();
                    break;
            }
        } else if (
    status == 3) { 
            
    select selection
            
    cm.sendYesNo("Are you sure you want to Job Advance?"); 
        } else if (
    status == 4) { 
            
    cm.getPlayer().changeJob(select); 
            
    proccespackage();
        } 



  2. #2
    Proficient Member Twdtwd is offline
    MemberRank
    Apr 2008 Join Date
    USALocation
    162Posts

    Re: [NPC] can't for the love of god get this working right

    As far as I can tell in that mess, it looks like your leave() function is only getting called when the status is equal to 4, from the starterpack method, inside of the process method, which is called in the main switch.

    So it would only run the code for status being equal to 4, not the rest.

  3. #3
    (O_o(o_O(O_O)o_O)O_o) Novak is offline
    MemberRank
    Apr 2009 Join Date
    The NetherlandsLocation
    1,120Posts

    Re: [NPC] can't for the love of god get this working right

    Quote Originally Posted by Twdtwd View Post
    As far as I can tell in that mess, it looks like your leave() function is only getting called when the status is equal to 4, from the starterpack method, inside of the process method, which is called in the main switch.

    So it would only run the code for status being equal to 4, not the rest.
    Allright, that makes sense. I'm going to try this now, where it runs it through the main function.

    PHP Code:
    /* 
        NPC Name:         Shanks
        Map(s):         Maple Road : Southperry (60000)
        Description:     Select job and warp to Victoria Island
    */
    var job = [ 
    [[
    100"Warrior"], [200"Magician"], [300"Bowman"], [400"Thief"], [500"Pirate"]], 
    [[
    1100"Dawn Warrior"], [1200"Blaze Wizard"], [1300"Wind Archer"], [1400"Night Walker"], [1500"Thunder Breaker"]], 
    [[
    3200"Battle Mage"], [3300"Wild Hunter"], [3500"Mechanic"]], 
    [[
    110"Fighter"], [120"Page"], [130"Spearman"]], 
    [[
    210"Wizard (F/P)"], [220"Wizard (I/L)"], [230"Cleric"]], 
    [[
    310"Hunter"], [320"Crossbow Man"]], 
    [[
    410"Assassin"], [420"Bandit"]], 
    [[
    510"Brawler"], [520"Gunslinger"]],
    [[
    3100"Demon Slayer"], [3101"Demon Avenger"]]]; 
    var 
    status 0
    var 
    select;
    var 
    destination = [2010000310010000]; //Lith Harbor

    function jobSelection(index) { 
        var 
    choose "Please, select your job:" 
        
    for (var 0job[index].lengthi++) 
            
    choose += "\r\n#L" job[index][i][0] + "#" job[index][i][1] + "#l"
        
    cm.sendSimple(choose); 
    }  

    function 
    starterpack() { 
        
    cm.gainItem(11020411); // Pink Advent Cape 
        
    cm.gainItem(11020421); // Purple Advent Cape 
        
    cm.gainItem(30100001); // Beginner Chair 
        
    cm.gainItem(200000550); // 50 Power Elixir
        
    cm.gainItem(10821461); // Yellow WG 
    }

    function 
    proccespackage() {
         switch (
    cm.getPlayer().getJob()) { 
                case 
    100:
                case 
    1100:
                case 
    2000:
                case 
    2100:
                case 
    3100:
                case 
    5100:
                case 
    6000//warriors (aran/ demons/ Kaiser/ mihile included)
                    
    cm.gainItem(14420711); // Seraphim Polearm 
                    
    cm.gainItem(14420501); // Seraphim Spear 
                    
    cm.gainItem(14020531); // Seraphim 2-H Sword 
                    
    cm.gainItem(14120351); // Seraphim 2-H Axe 
                    
    cm.gainItem(14220391); // Seraphim 2-H Blunt Weapon (Mace) 1302033
                    
    cm.gainItem(13020331); // 1-H sword 
                    
    break; 
                case 
    200:
                case 
    1200:
                case 
    2200:
                case 
    2201:
                case 
    3200//mages (evan/ BM included)
                    
    cm.gainItem(13720461); // Seraphim Wand 
                    
    cm.gainItem(13820621); // Seraphim Staff
                    
    break;
                case 
    300:
                case 
    1300:
                case 
    3300:
                case 
    2300//archers (mercedes, WH included)
                    
    cm.gainItem(14520621); // Seraphim Bow 
                    
    cm.gainItem(14620561); // Seraphim Cross bow 
                    
    cm.gainItem(20600015000); // Arrows   
                    
    cm.gainItem(20610035000); // X-Box arrows.
                    
    cm.gainItem(13520001); // magic arrows. 
                    
    cm.gainItem(15220001); // dual bowgun
                    
    break;
                case 
    400:
                case 
    1400:
                case 
    430:
                case 
    431//thieves (dual blade included)
                    
    cm.gainItem(20700015000); // Stars   
                    
    cm.gainItem(13320811); // Seraphim Dagger 
                    
    cm.gainItem(14720771); // Seraphim Claw 
                    
    cm.gainItem(13420471); // katara
                    
    break;
                case 
    500:
                case 
    1500:
                case 
    3500
                case 
    530:
                case 
    507
                case 
    508//pirates (mech/ cannoneer included)
                    
    cm.sendOk("You are obliged to receive the Pirate package!");
                    
    cm.gainItem(14820291); // Seraphim Knuckles 
                    
    cm.gainItem(14920001); // pistol
                    
    cm.gainItem(2300000100); // bullets
                    
    cm.gainItem(2300000100); // bullets
                    
    cm.gainItem(2300000100); // bullets
                    
    cm.gainItem(15320001); // cannon
                    
    break;
                case 
    2400//phantom
                    
    cm.gainItem(13620001); // cane
                    
    cm.gainItem(13521001); // carte magique
                    
    cm.maxSkillsByJob();
                    break;
                case 
    6500//angelic buster
                    
    cm.gainItem(12220621); // Soul Shooter
                    
    cm.gainItem(13526011); // Soul ring
                
    case 2710//luminous
                    
    cm.gainItem(12120861); // Lumi Stick thingy (expires after relog)
                    
    cm.gainItem(12120011); // Lumi Stick thingy
                    
    cm.gainItem(13524001); // Light orb
                    
    break;
                case 
    3600//Xenon
                    
    cm.gainItem(12420011); // xenon blade thingy
                    
    break;
                case 
    4100://hayato
                    
    cm.gainItem(15420491); // katana
                
    case 4200://kanna
                    
    cm.gainItem(15520001); // fan
                
    default:
                    
    cm.sendOk("Hi there! Something went wrong in giving you a starter package and warping you! This might be because you are a job that is currently unknown to us, if so, report it at the forums!")
                    
    cm.dispose();
         }
    }

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


    function 
    action(modetypeselection) { 
        if (
    mode == 1
            
    status++; 
        else if (
    mode == -1
            
    status--; 
        else { 
            
    cm.dispose(); 
            return; 
        } 
        if (
    status == 0) { 
            if (
    cm.getPlayer().getLevel() >= 10 && cm.getPlayer().getLevel() < 50 
                
    cm.sendYesNo("Oh hello there! Here comes a though decision:\r\n\r\nEither stay on your current path, or change it by selecting a different job."); 
            else { 
                
    cm.sendOk("You may not advance yet. You must be at least lvl 10 and below lvl 50 to proceed."); 
                
    cm.dispose(); 
            } 
        } else if (
    status == 1) { 
            
    cm.sendSimple("Please, pick a job:\r\n\r\n" 
            
    "#L0#Adventurer#l\r\n" +
            
    "#L1000#Knight of Cygnus#l\r\n" +
            
    "#L3000#Resistance#l\r\n" 
            
    "#L3001#Demon#l\r\n" +
            
    "#L501#Cannoneer#l\r\n" +
            
    "#L2000#Aran#l\r\n" +
            
    "#L2001#Evan#l\r\n" +
            
    "#L2002#Mercedes#l\r\n" +
            
    "#L2003#Phantom#l\r\n" +
            
    "#L2004#Luminous#l\r\n" +
            
    "#L3002#Xenon#l\r\n" +
            
    "#L6000#Kaiser#l\r\n" 
            
    "#L6001#Angelic Buster#l\r\n" +
            
    "#L2000#Aran#l\r\n" +
            
    "#L4001#Hayato#l\r\n" +
            
    "#L4002#Kanna#l\r\n" +
            
    "#L5000#Mihile#l\r\n" +
            
    "#L2000#Aran#l\r\n" +
            
    "#L10000#Zero#l\r\n" +
            
    "#L430#Dual Blade#l\r\n");
        }else if (
    status == 2) {
            switch (
    selection) { 
                case 
    0// Adventurer
                    
    jobSelection(0); 
                    break; 
                case 
    1000// Cygnus knight
                    
    jobSelection(1); 
                    break; 
                case 
    3000// Resistance
                    
    jobSelection(2); 
                    break; 
                case 
    3001// Demon 
                    
    jobSelection(8); 
                    break; 
                
    //Special Jobs 
                
    case 501// Pirate(Cannoneer) 
                    
    cm.getPlayer().changeJob(530); 
                    
    proccespackage();
                    break; 
                case 
    2000// Legend(Aran) 
                    
    cm.getPlayer().changeJob(2100); 
                    
    proccespackage(); 
                    break; 
                case 
    2001// Farmer(Evan) 
                    
    cm.getPlayer().changeJob(2200); 
                    
    proccespackage(); 
                    break; 
                case 
    2002// Mercedes 
                    
    cm.getPlayer().changeJob(2300); 
                    
    proccespackage(); 
                    break; 
                case 
    2003// Phantom Jr. 
                    
    cm.getPlayer().changeJob(2400); 
                    
    proccespackage();
                    break;
                case 
    2004// Luminous
                    
    cm.getPlayer().changeJob(2710); 
                    
    proccespackage();
                    break; 
                case 
    3002// Xenon 
                    
    cm.getPlayer().changeJob(3600); 
                    
    proccespackage(); 
                    break;
                case 
    6000// Kaiser 
                    
    cm.getPlayer().changeJob(6100); 
                    
    proccespackage(); 
                    break; 
                case 
    6001// Angelic Buster 
                    
    cm.getPlayer().changeJob(6500); 
                    
    proccespackage();
                    break;
               
    /* case 11000: // Beast Tamer  
                    cm.getPlayer().changeJob(11200); 
                    proccespackage();
                    break; */
                
    case 4001// Hayato  
                    
    cm.getPlayer().changeJob(4100); 
                    
    proccespackage();
                    break;
                case 
    4002// Kanna
                    
    cm.getPlayer().changeJob(4200); 
                    
    proccespackage();
                    break;
                case 
    5000// Mihile
                    
    cm.getPlayer().changeJob(5100); 
                    
    proccespackage();
                    break; 
                case 
    10000// Zero
                    
    cm.getPlayer().changeJob(10000);
                    
    proccespackage();
                    break;
                case 
    430// Dual Blade
                    
    cm.getPlayer().changeJob(430);
                    
    proccespackage();
                    break;
            }
        } else if (
    status == 3) { 
            
    select selection
            
    cm.sendYesNo("Are you sure you want to Job Advance?"); 
        } else if (
    status == 4) { 
            
    cm.getPlayer().changeJob(select); 
            
    proccespackage();
            
    starterpack();
            
    cm.sendNextNoESC(cm.getPlayer().getJob() == 3300 "You will now be transported to the resistance HQ.\r\n\r\n#rIn here, talk to Belle. #bShe gives you the catch jaguar skill#k\r\n\r\nThen please #rspeak to Black Jack and enter a room.\r\n\r\n#bThen get down the HP of a jaguar, and use your catch skill to obtain the mount." "Welcome to Victoria Island! Enjoy your stay!~");
        } else if (
    status == 5) {
            
    cm.warp(cm.getPlayer().getJob() == 3300 destination[1] : destination[0], 0);
            
    cm.dispose();
        }

    - - - Updated - - -

    Yeah that fixed it lol. xD



Advertisement