Npc cm.gainItem disconnect

Results 1 to 4 of 4
  1. #1
    Member SAINTmade is offline
    MemberRank
    Jul 2013 Join Date
    USALocation
    65Posts

    Npc cm.gainItem disconnect

    Please help. I'm having an issue. I have an NPC that trades Plastic crowns (dojo currency) for IoC's. Some IoC's make me disconnect when I buy them from the npc. the item works though. I can !item it, and !drop it, and wear it. But if I put it in with cm.gainItem, I disconnect. My maplestory gets that "MapleStory has stopped working..." error. No bat errors.

    My server has all working v140 items, stylists, effects, etc. Here's my code:

    Code:
    var status = 0;var map = Array(240010501);
    
    
    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();
            if (mode == 1)
                status++;
            else
                status--;
            if (status == 0) {
                cm.sendSimple("Hello, I am the Timeless items seller. Do you want to trade in 25 #b#v4000100##ks for a Timeless item?\r\n\r\n#e#dMagician Equips#n#k\r\n#L0#I would like to buy #i01003387##l\r\n#L1#I would like to buy #i01003386##l\r\n\#L2#I would like to buy #i01003390##l\r\n#L3#I would like to buy #i01003518##l\r\n#L4#I would like to buy #i01003238##l\r\n#L5#I would like to buy #i01003082##l\r\n#L6#I would like to buy #i01003093##l\r\n#L7#I would like to buy #i01003402##l\r\n#L8#I would like to buy #i01003402##l\r\n#L9#I would like to buy #i1052158##l\r\n#L10#I would like to buy #i1092059##l\r\n#L11#I would like to buy #i1072358##l\r\n#L12#I would like to buy #i1332073##l\r\n#L13#I would like to buy #i1332074##l\r\n#L14#I would like to buy #i1472068##l\r\n\r\n#e#dWarrior Equips#n#k\r\n#L15#I would like to buy #i1002776##l\r\n#L16#I would like to buy #i1082234##l\r\n#L17#I would like to buy #i1052155##l\r\n#L18#I would like to buy #i1092058##l\r\n#L19#I would like to buy #i1072355##l\r\n#L20#I would like to buy #i1302081##l\r\n#L21#I would like to buy #i1312037##l\r\n#L22#I would like to buy #i1322060##l\r\n#L23#I would like to buy #i1402046##l\r\n#L24#I would like to buy #i1412033##l\r\n#L25#I would like to buy #i1422037##l\r\n#L26#I would like to buy #i1442063##l\r\n#L27#I would like to buy #i1332073##l\r\n#L28#I would like to buy #i1432047##l\r\n\r\n#e#dArcher Equips#n#k\r\n#L29#I would like to buy #i1002778##l\r\n#L30#I would like to buy #i1082236##l\r\n#L31#I would like to buy #i1052157##l\r\n#L32#I would like to buy #i1072357##l\r\n#L33#I would like to buy #i1452057##l\r\n#L34#I would like to buy #i1462050##l\r\n\r\n#e#dPirate Equips#n#k\r\n#L35#I would like to buy #i1002780##l\r\n#L36#I would like to buy #i1082238##l\r\n#L37#I would like to buy #i1052159##l\r\n#L38#I would like to buy #i1072359##l\r\n#L39#I would like to buy #i1482023##l\r\n#L40#I would like to buy #i1492023##l\r\n\r\n#e#dCommon Equips#n#k\r\n#L41#I would like to buy #i1032031##l\r\n#L42#I would like to buy #i1122012##l\r\n#L43#I would like to buy #i1102172##l");
            } else if (status == 1) {
                if (selection == 0) { //Start of Magician Equips
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(01003387,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks!");
                    cm.dispose();
                } else if (selection == 1) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(01003386,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 2) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(01003390,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 3) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(01003518,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 4) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(01003238,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 5) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(01003082,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 6) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(01003093,1);
    					 cm.getPlayer().message("You have recieved your NULL item.");
    					cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 7) { //Start of Thief Equips
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(01003402,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 8) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1092059,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 9) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1052158,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 10) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1092059,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 11) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1072358,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 12) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1332073,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 13) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1332074,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 14) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1472068,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 15) { //Start of Warrior Equips
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1002776,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks!");
                    cm.dispose();
                } else if (selection == 16) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1082234,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 17) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1052155,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 18) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1092058,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 19) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1072355,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 20) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1302081,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 21) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1312037,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 22) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1322060,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 23) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1402046,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 24) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1412033,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 25) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1422037,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 26) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1442063,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 27) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1332073,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 28) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1432047,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 29) { //Start of Archer Equips
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1002778,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 30) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1082236,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 31) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1052157,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks!");
                    cm.dispose();
                } else if (selection == 32) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1072357,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 33) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1452057,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 34) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1462050,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 35) { //Start of Pirate Equips
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1002780,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 36) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1082238,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 37) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1052159,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 38) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1072359,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 39) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1482023,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 40) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1492023,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 41) { //Start of Common Equips
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1032031,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 42) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1122012,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
                } else if (selection == 43) {
                    if(cm.haveItem(4000100, 25)) {
                        cm.gainItem(1102172,1);
                        cm.gainItem(4000100,-25);
                        cm.sendOk("Thank you for your 25 #b#v4000100##ks!");
                    } else
                        cm.sendOk("Sorry, you don't have 25 #b#v4000100##ks");
                    cm.dispose();
    	}
    	    else
                    cm.sendOk("Alright. Come back later!");
            }
        }
    }
    Selection 7 which is : cm.gainItem(01003402, 1);
    disconnects me. The item works though. Please help? thank you!


  2. #2
    Member SAINTmade is offline
    MemberRank
    Jul 2013 Join Date
    USALocation
    65Posts

    Re: Npc cm.gainItem disconnect

    bump~~ Please help need answers desperately :(

  3. #3
    Member divinesam is offline
    MemberRank
    May 2004 Join Date
    singaporeLocation
    97Posts

    Re: Npc cm.gainItem disconnect

    if (selection == 0) { //Start of Magician Equips
    if(cm.haveItem(4000100, 25)) {
    cm.gainItem(01003387,1);
    cm.gainItem(4000100,-25);
    cm.sendOk("Thank you for your 25 #b #v4000100##ks!");
    } else
    cm.sendOk("Sorry, you don't have 25 #b #v4000100##ks!");
    cm.dispose();
    }

    Is terribly wrong. Its not the problem with gainItem it works perfectly fine, its your coding.

    You did not open a { after 'else' function, nor did you close it with }.

    And your use of dispose isn't exactly right either. Read any source and learn from NPC scripting, You can find samples of such NPCs easily. Learn to leech CORRECTLY..

  4. #4
    Member SAINTmade is offline
    MemberRank
    Jul 2013 Join Date
    USALocation
    65Posts

    Re: Npc cm.gainItem disconnect

    Quote Originally Posted by divinesam View Post
    if (selection == 0) { //Start of Magician Equips
    if(cm.haveItem(4000100, 25)) {
    cm.gainItem(01003387,1);
    cm.gainItem(4000100,-25);
    cm.sendOk("Thank you for your 25 #b #v4000100##ks!");
    } else
    cm.sendOk("Sorry, you don't have 25 #b #v4000100##ks!");
    cm.dispose();
    }

    Is terribly wrong. Its not the problem with gainItem it works perfectly fine, its your coding.

    You did not open a { after 'else' function, nor did you close it with }.

    And your use of dispose isn't exactly right either. Read any source and learn from NPC scripting, You can find samples of such NPCs easily. Learn to leech CORRECTLY..
    I solved it. It wasn't the coding. It was the ID had a 0 infront of it. Removing the 0 somehow made the item work.



Advertisement