[Solved]This npc script wont work

Results 1 to 15 of 15
  1. #1
    Apprentice AuraShadow is offline
    MemberRank
    Nov 2013 Join Date
    12Posts

    [Solved]This npc script wont work

    Hello everyone here at RageZone.
    I am pretty much a novice at coding and at the moment yes i am at the moment leeching alot of scripts to view and learn abit from.

    What i dont understand at this point is this script:

    var status;

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

    function
    action(mode, type, selection) {
    if (
    mode == 1) {
    status++;
    }else{
    status--;
    }
    if (
    status == 0) {
    cm.sendNext("I am the server skill maxer.");
    } else if (
    status == 1) {
    cm.sendSimple("Would you like me to max your skills? \r\n #L0# Yes. #l \r\n #L1# No. #l");
    } else if (
    status == 2) {
    if (
    selection == 0) {
    cm.maxMastery();
    cm.sendOk("Your skills have been maxed.");
    cm.dispose();
    } else if (
    selection == 1) {
    cm.sendOk("Hmph. Come back later.");
    cm.dispose();
    }
    }
    }

    Sure it puts up a dialog for the NPC i added it to BUT and yes it gives all skills but it doesnt max them, but it also steals all AP from the person who uses it.
    So why is it stealing the AP and wont max the skills?
    AM i missing something in this script?
    Cause as i said in the beginning i am really newb to scripting and i can absolutly nothing.
    But im trying to learn.

    Well hopefully someone can help me get the script working.

    And yes i have added in the bits i need in the npcconversationmanager.

    And if someone could help me create a player command it would also help alot.

    I dont know how to make the GM command !maxskills into a player command so all help is welcome.

    Im using moopledev rev 120.
    Last edited by AuraShadow; 10-05-15 at 12:00 PM.


  2. #2
    Moongran Saii is offline
    MemberRank
    Jan 2012 Join Date
    510Posts

    Re: This npc script wont work

    the script is fine, the problem is with the method its calling.
    cm.maxMastery();

    look for this method in NPCConversationManager or AbstractPlayerInteraction. the problem is there

  3. #3
    Apprentice AuraShadow is offline
    MemberRank
    Nov 2013 Join Date
    12Posts

    Re: This npc script wont work

    Quote Originally Posted by Saii View Post
    the script is fine, the problem is with the method its calling.
    cm.maxMastery();

    look for this method in NPCConversationManager or AbstractPlayerInteraction. the problem is there
    Yea it doesnt exist in any of the 2.

    How do i add the method?
    and also do i need to add it to both of the NPCConversationManager and AbstractPlayerInteraction?

  4. #4
    Moongran Saii is offline
    MemberRank
    Jan 2012 Join Date
    510Posts

    Re: This npc script wont work

    no. only one of them.
    if it doesn't exist, you should be getting the no such method exception in your bat files when talking to the npc.
    as to how to add, well you need to code this, no magic solution here, frankly.

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

    Re: This npc script wont work

    Looking at rev 120, it does have maxMastery defined in NPCConversationManager.java
    You should have this
    Code:
        public void maxMastery() {        
    for (MapleData skill_ : MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/" + "String.wz")).getData("Skill.img").getChildren()) {
                try {
                    Skill skill = SkillFactory.getSkill(Integer.parseInt(skill_.getName()));
                    getPlayer().changeSkillLevel(skill, (byte) 0, skill.getMaxLevel(), -1);
                } catch (NumberFormatException nfe) {
                    break;
                } catch (NullPointerException npe) {
                    continue;
                }
            }
        }
    This is from a clean rev.120, I can't see why you wouldn't have it.

  6. #6
    Apprentice AuraShadow is offline
    MemberRank
    Nov 2013 Join Date
    12Posts

    Re: This npc script wont work

    Quote Originally Posted by Cygnus View Post
    Looking at rev 120, it does have maxMastery defined in NPCConversationManager.java
    You should have this
    Code:
        public void maxMastery() {        
    for (MapleData skill_ : MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/" + "String.wz")).getData("Skill.img").getChildren()) {
                try {
                    Skill skill = SkillFactory.getSkill(Integer.parseInt(skill_.getName()));
                    getPlayer().changeSkillLevel(skill, (byte) 0, skill.getMaxLevel(), -1);
                } catch (NumberFormatException nfe) {
                    break;
                } catch (NullPointerException npe) {
                    continue;
                }
            }
        }
    This is from a clean rev.120, I can't see why you wouldn't have it.
    Yes i have that but the NPC still wont work so no idea what to do :(

  7. #7
  8. #8
  9. #9
    Apprentice AuraShadow is offline
    MemberRank
    Nov 2013 Join Date
    12Posts

    Re: This npc script wont work

    Seems i cant get it to work, i appreciate the help alot!

    Anyone know how i can change the GM skill !maxskills to a @maxskills for all players?

    I tried some different ways but none have worked.
    So all help will be more then welcome :3

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

    Re: This npc script wont work

    In client.command.Commands.java you'll find your commands (incase you didn't know.).
    In moople, all of your commands are by default in the same file. In Commands.java, find
    Code:
    else if (sub[0].equals("maxskills"))
    Now, this will be wrapped in a condition making it only available to players with gm levels greater than X (whatever gm level the command is set for). Now, copy everything within the brackets for maxskills, and find where your players commands are located (i.e by looking for dispose). You may need to adjust it slightly to make it fit, but it's good exercise and not very difficult.

  11. #11
    Apprentice AuraShadow is offline
    MemberRank
    Nov 2013 Join Date
    12Posts

    Re: This npc script wont work

    Quote Originally Posted by Cygnus View Post
    In client.command.Commands.java you'll find your commands (incase you didn't know.).
    In moople, all of your commands are by default in the same file. In Commands.java, find
    Code:
    else if (sub[0].equals("maxskills"))
    Now, this will be wrapped in a condition making it only available to players with gm levels greater than X (whatever gm level the command is set for). Now, copy everything within the brackets for maxskills, and find where your players commands are located (i.e by looking for dispose). You may need to adjust it slightly to make it fit, but it's good exercise and not very difficult.
    Yes im completely green and trying to learn but it doesnt go as good in the beginning hehe

    Yea i do have that.
    the command for the !maxskills looks like this:

    } else if (sub[0].equals("maxskills")&&(player.gmLevel() > 2)) {
    for (MapleData skill_ : MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/" + "String.wz")).getData("Skill.img").getChildren()) {
    try {
    Skill skill = SkillFactory.getSkill(Integer.parseInt(skill_.getName()));
    player.changeSkillLevel(skill, (byte) skill.getMaxLevel(), skill.getMaxLevel(), -1);
    } catch (NumberFormatException nfe) {
    break;
    } catch (NullPointerException npe) {
    continue;
    }
    }

    Edit:

    I know im asking to pretty much be "spoon feeded" but right now im clueless....
    Last edited by AuraShadow; 10-05-15 at 10:55 AM.

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

    Re: This npc script wont work

    Quote Originally Posted by AuraShadow View Post
    Yes im completely green and trying to learn but it doesnt go as good in the beginning hehe

    Yea i do have that.
    the command for the !maxskills looks like this:

    } else if (sub[0].equals("maxskills")&&(player.gmLevel() > 2)) {
    What this says is basically if you call !maxskills, and your gmLevel is above 2, it will max your skills, otherwise it wont. You just remove the requirement of gmLevel above 2, and it will allow players to use it. I'm not sure how Moople does commands, but I would imagine, rather than having a check for gmLevel for each command, it's commands are divided into subcategories with a single check for gmLevel for each command group. So you may have to move it as well.

  13. #13
    Apprentice AuraShadow is offline
    MemberRank
    Nov 2013 Join Date
    12Posts

    Re: This npc script wont work

    Quote Originally Posted by Cygnus View Post
    What this says is basically if you call !maxskills, and your gmLevel is above 2, it will max your skills, otherwise it wont. You just remove the requirement of gmLevel above 2, and it will allow players to use it. I'm not sure how Moople does commands, but I would imagine, rather than having a check for gmLevel for each command, it's commands are divided into subcategories with a single check for gmLevel for each command group. So you may have to move it as well.
    I think i would be better of if i actually try find a coder who understand more then me xD
    At this point all i understand is simple NPC code wich i try play around with.
    This seems abit out of hand for me at this moment (Since i gotta learn more)
    I am greatfull for the help, i dont think i will be able to do this hehe

    yea way out of my league atm :(

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

    Re: This npc script wont work

    Quote Originally Posted by AuraShadow View Post
    I think i would be better of if i actually try find a coder who understand more then me xD
    At this point all i understand is simple NPC code wich i try play around with.
    This seems abit out of hand for me at this moment (Since i gotta learn more)
    I am greatfull for the help, i dont think i will be able to do this hehe

    yea way out of my league atm :(
    It's not that complicated. If you post your Commands.java on pastebin and send me a pm, I can set it up for you.

  15. #15
    Apprentice AuraShadow is offline
    MemberRank
    Nov 2013 Join Date
    12Posts

    Re: This npc script wont work

    Quote Originally Posted by Cygnus View Post
    It's not that complicated. If you post your Commands.java on pastebin and send me a pm, I can set it up for you.
    Oh really thank you <33
    Will do

    - - - Updated - - -

    Thanks @Cygnus this has now been fixed :D



Advertisement