Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[HELP] npc

Newbie Spellweaver
Joined
Aug 29, 2009
Messages
45
Reaction score
2
i use this npc

Code:
importPackage (Packages.client);
importPackage (Packages.server);
importPackage (Packages.constants);
importPackage (Packages.net.channel);
importPackage (Packages.tools);
importPackage (Packages.scripting)
var cserv, c, p, list, meh, type, slot, lulz, equip, item2;
//cserv = Player's channel server
//c= Player's client 
//list = The list/array of all character names in the world
//meh = whether you have chosen to edit inventory (1) or lookup stats (2)
//type = The inventory type of the chosen item
//slot = The slot of the chosen item
//lulz = The selection of what you want to edit in an item (or send/remove etc)
//equip = a boolean that determines if the item you wish to CREATE is an equip or not
//item2 = Simply the item when creating a new item
var ugh=false;
//ugh = the boolean used to make sure we don't redeclare the slot of an item you selected
var wigger;
//the player selected
var item;
//the item selected
var hah = ["Weapon Attack", "Magic Attack", "Strength", "Dexterity", "Intelligence", "Luck", "", "", "Owner", "", "Quantity"];
//the array containing all of the names of stats that is called when asking "What do you want to change ____ to" and "___ has been changed to ___"
var citemid;
//the item id of the item you wish to create
var FUCKINGPLAYERS="";
//the list of all the players including #L (selections)
var st=-1;
//status
function start() {
    if (cm.getPlayer().gmLevel() <3){
        cm.sendOk("duck off.");
        cm.dispose();
        return;
    }
    p=cm.getPlayer();
    c=p.getClient();
    cserv=c.getChannelServer();
    meh=1;
    var playerStr;
    try {
        playerStr = cserv.getWorldInterface().getAllPlayerNames(p.getWorld());
    } catch (e) {
        c.getChannelServer().reconnectWorld();
    }
    list=playerStr.split(", ");
    for (var i=0;i<list.length;i++){
        FUCKINGPLAYERS+= "#L"+i+"#"+list[i]+"\r\n";
    }
    cm.sendSimple("WHICH wigga YOU GONNA STALK?\r\n"+FUCKINGPLAYERS+"#l");
}
function action(m,t,s) {
   if (m<1){
        cm.dispose();
        return;
    }
    if (st==3 && s<0 && meh==1)
        st=2;
    st++;
    if (st==0){
            for (var i=1; i<ServerConstants.CHANNEL_NUMBER+1; i++){
                var cserv_= ChannelServer.getInstance(i);
                var ret = cserv_.getPlayerStorage().getCharacterByName(list[s]);
                if (ret != null) {
                    wigger = ret;
                    break;
                }
            }
            if (wigger==null){
                cm.sendOk("Error 404! Player not found! ;_;")
                cm.dispose();
            }else
        cm.sendSimple(wigger.getName()+" is a wigger alright. Watcha wanna do?\r\n"+
        "#L1#Edit Inventory#l\r\n#L2#Lookup Stats#l");
    } else if (st==1){
        meh=s;
        if (meh==1){
            
            cm.sendSimple("Watcha wanna see?\r\n"+
            "#L0#Equips\r\n#L1#Use\r\n#L2#Setup\r\n#L3#ETC\r\n#L4#Cash\r\n#L5#Equipped\r\n#L6#Create Item#l");

        } else if (meh==2){
           cm.sendOk(wigger.getName()+"'s stats:\r\n"+
           "Dex: "+wigger.getDex()+"/Dex w/ Items: "+wigger.getTotalDex()+
           "\r\nStr: "+wigger.getStr()+"/Str w/ Items: "+wigger.getTotalStr()+
           "\r\nInt: "+wigger.getInt()+"/Int w/ Items: "+wigger.getTotalInt()+
           "\r\nLuk: "+wigger.getLuk()+"/Luk w/ Items: "+wigger.getTotalLuk()+
           "\r\nWepAtk w/ Items: "+wigger.getTotalWatk()+
           "\r\nMagAtk w/ Items: "+wigger.getTotalMagic()+
           "\r\nLevel: "+wigger.getLevel()+
           "\r\nJob: "+wigger.getJob());
        }
    } else if (st==2){
        if (meh==1){
            type = MapleInventoryType.getByType(s!=5?s+1:-1);
            if (s==6){
                cm.sendGetText("What is the Item ID?");
                st=15;
            }
            else {
            var herpaderp="";

            for (var i=(type.getType()!=-1?0:-20); i<(type.getType()!=-1?wigger.getInventory(type).getSlotLimit(): 20); i++){
                item = wigger.getInventory(type).getItem(i);
                if (item ==null)
                    continue;
                if (type.getType != 3)
                herpaderp+="#L"+item.getPosition()+"##v"+item.getItemId()+"##l";
            else
                herpaderp+=""+item.getPosition()+"##v"+item.getItemId()+"#";
            }
            if (herpaderp==""){
                cm.sendOk("There are no items in this inventory.");
                cm.dispose();
            }
            else if (s==0||s==5){
                cm.sendSimple("Equip list r is:"+herpaderp);
            } else {
                cm.sendSimple("Item list r is:"+herpaderp);
            }
        }
        }
    } else if (st ==3){
        if (meh==1){
            if (!ugh){
            slot=s;
            ugh=true;
        }
            item = wigger.getInventory(type).getItem(slot);
           var isequip=( MapleItemInformationProvider.getInstance().isEquip(item.getItemId()));
           if (!isequip){
                cm.sendSimple("#t"+item.getItemId()+"# - #v"+item.getItemId()+"# ("+item.getItemId()+")\r\n"+
                "#L10#Quantity: "+item.getQuantity()+
                "\r\n#L8#Owner: "+item.getOwner()+
                "\r\n\r\n#L6##rApply Changes#l\r\n "+
                "\r\n#L7#Send this item to another player.#l"+
                "\r\n#L9#Remove Item#l");

           } else {
                item = cm.getEquip(slot, wigger);
                if (type.getType()==-1){
                    item =cm.getEquipped(slot, wigger);
                }
                cm.sendSimple("#t"+item.getItemId()+"# - #v"+item.getItemId()+"# ("+item.getItemId()+")\r\n"+
                "#L0#Wep Attack: "+item.getWatk()+
                "\r\n#L1#Magic Attack: "+item.getMatk()+
                "\r\n#L2#Str: "+item.getStr()+
                "\r\n#L3#Dex: "+item.getDex()+
                "\r\n#L4#Int: "+item.getInt()+
                "\r\n#L5#Luk: "+item.getLuk()+
                "\r\n#L8#Owner: "+item.getOwner()+
                "\r\n\r\n#L6##rApply Changes#l\r\n "+
                "#L7#Send this item to another player.#l"+
                "\r\n#L9#Remove Item");
            }
        }
    } else if (st==4){
        lulz=s;
        if (s==9){
            MapleInventoryManipulator.removeFromSlot(wigger.getClient(), type, slot, item.getQuantity(), false);
            p.dropMessage("Item removed.");
            cm.dispose();
            return;
        } else if (s==7){
                cm.sendSimple("Who do you want to send this to??\r\n"+FUCKINGPLAYERS+"#l");
            }
            else if (s!=6)
            cm.sendGetText("What would you like to change "+hah[s]+" to?");
            else {
                wigger.equipChanged();
                wigger.getClient().getSession().write(MaplePacketCreator.getCharInfo(wigger));
                wigger.getMap().removePlayer(wigger);
                wigger.getMap().addPlayer(wigger);
                cm.dispose();
            }
    } else if (st ==5){
        if (meh ==1) {
            if (lulz==7){
                for (var i=1; i<ServerConstants.CHANNEL_NUMBER+1; i++){
                var cserv_= ChannelServer.getInstance(i);
                var ret = cserv_.getPlayerStorage().getCharacterByName(list[s]);
                if (ret != null) {
                    wigger = ret;
                    break;
                }
            }
            if (wigger==null){
                cm.sendOk("Error 404! Player not found! ;_;")
                cm.dispose();
                return;
            }
            MapleInventoryManipulator.addFromDrop(wigger.getClient(), item.copy(), false);
            p.dropMessage("Item copied and sent.");
            wigger.dropMessage("Item recieved from "+p.getName());
            cm.dispose();
            return;
            }
            var variable=parseInt(cm.getText());
            if ((isNaN(variable) || variable<0|| variable>32767) && lulz !=8){
                cm.sendOk("That is not a legal number."+lulz);
            }else{
                switch(lulz){
                    case 0: item.setWatk(variable); break;
                    case 1: item.setMatk(variable); break;
                    case 2: item.setStr(variable); break;
                    case 3: item.setDex(variable); break;
                    case 4: item.setInt(variable); break;
                    case 5: item.setLuk(variable); break;
                    case 8: item.setOwner(cm.getText()); break;
                    case 10:item.setQuantity(variable); break;
                    default: cm.dispose(); return;
                }

                cm.sendOk(hah[lulz]+" set to "+cm.getText()+".");
                st-=2;
            }
        }
    }


    else if (st==16){
        var numba=parseInt(cm.getText());
        equip=MapleItemInformationProvider.getInstance().isEquip(numba);
        citemid=numba;
        if (isNaN(numba)){
            cm.sendOk("That ain't a numba.");
            cm.dispose();
            return;
        }
        if(!equip){
            cm.sendGetText("How many?");
        } else {
            item2= MapleItemInformationProvider.getInstance().getEquipById(citemid);
            if (item2 == null){
                cm.sendOk("Bad item id.");
                cm.dispose();
                return;
            }
            cm.sendSimple("ugh I don't want to do this, #t"+citemid+"# #v"+citemid+"#\r\n"+
            "#L0#Wep Attack: "+item2.getWatk()+
            "\r\n#L1#Magic Attack: "+item2.getMatk()+
            "\r\n#L2#Str: "+item2.getStr()+
            "\r\n#L3#Dex: "+item2.getDex()+
            "\r\n#L4#Int: "+item2.getInt()+
            "\r\n#L5#Luk: "+item2.getLuk()+
            "\r\n\r\n#L6##rSend Item#l\r\n ");
        }
    }else if (st==17){
        if (equip){
            lulz=s;
            if (s!=6)
            cm.sendGetText("What would you like to change "+hah[s]+" to?");
            else{

            }
        }else{
          MapleInventoryManipulator.addById(wigger.getClient(), citemid, parseInt(cm.getText()));
          c.getSession().write(MaplePacketCreator.getShowItemGain(citemid, parseInt(cm.getText()), true));
          p.dropMessage(parseInt(cm.getText())+" "+citemid+"s have been sent to "+wigger.getName()+" successfully!");
          wigger.dropMessage("You have gained an item from GM "+p.getName());
          cm.dispose();
        }

    } else if (st==18){
        var variable=parseInt(cm.getText());
            if (isNaN(variable) || variable<0|| variable>32767){
                cm.sendOk("That is not a legal number.");
            }else{
                switch(lulz){
                    case 0: item2.setWatk(variable); break;
                    case 1: item2.setMatk(variable); break;
                    case 2: item2.setStr(variable); break;
                    case 3: item2.setDex(variable); break;
                    case 4: item2.setInt(variable); break;
                    case 5: item2.setLuk(variable); break;
                    default: cm.dispose(); return;
                }

                cm.sendOk(hah[lulz]+" set to "+cm.getText()+".");
                st-=3;
        }
    }

}


and i get this error

"ServerConstants" is not defined.

how do i fix it?
 
Have Fun!
Joined
Nov 2, 2008
Messages
481
Reaction score
70
Let's do a little modification then. Replace the following line in the script:
PHP:
for (var i=1; i<ServerConstants.CHANNEL_NUMBER+1; i++){
With this:
PHP:
for (var i=1; i<ChannelServer.getAllInstances().size(); i++){
And see if it works.
 
Upvote 0
Newbie Spellweaver
Joined
Aug 29, 2009
Messages
45
Reaction score
2
Let's do a little modification then. Replace the following line in the script:
PHP:
for (var i=1; i<ServerConstants.CHANNEL_NUMBER+1; i++){
With this:
PHP:
for (var i=1; i<ChannelServer.getAllInstances().size(); i++){
And see if it works.

i tried it and it say "ChannelServer" is not defined.
 
Upvote 0
Back
Top