Help in Scripting!

Results 1 to 18 of 18
  1. #1
    Account Upgraded | Title Enabled! mixtamal6 is offline
    MemberRank
    Mar 2013 Join Date
    686Posts

    Help in Scripting!

    hi , I could help me as I can add a change of music in eventscript ?

    i have this...

    Code:
    importPackage(java.lang);
    importPackage(Packages.tools.packet);
    
    
    
    function scheduledTimeout(eim,player) {
    
    player.getClient().getSession().write(CField.musicChange("nameMusic"));
    
    
    eim.broadcastPlayerMsg(6, "Music Change");
    
    
    }



    but cant work u.u , show message in console:

    Code:
    Event nameMYQUEST, Instance name : Quest142, method Name : scheduledTimeout:
    javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: TypeError: Cannot call method "getClient" of undefined



    need help, thank you :D


  2. #2
    not a programmer eshays is offline
    MemberRank
    Mar 2015 Join Date
    532Posts

    Re: Help in Scripting!

    eim.changeMusic(songName); //"BGM14/Ariant"

  3. #3
    ・ARC:+200 Yuuroido is offline
    MemberRank
    Jul 2010 Join Date
    Saitama, JPLocation
    333Posts

    Re: Help in Scripting!

    and remove 'player'
    Code:
    function scheduledTimeout(eim,player) {

  4. #4
    Account Upgraded | Title Enabled! mixtamal6 is offline
    MemberRank
    Mar 2013 Join Date
    686Posts

    Re: Help in Scripting!

    Thanks guys! :D

    - - - Updated - - -

    cant work guys

    i use this:

    Code:
    function scheduledTimeout(eim) {
    
    
    eim.changeMusic("Bgm00/Florallife"); 
    }
    and show this problem:


    Code:
    Event nameMIQUEST, Instance name : Quest142, method Name : scheduledTimeout:
    javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: TypeError: Cannot find function changeMusic in object scripting.EventInstanceManager@59c9491. (<Unknown source>#123) in <Unknown source>
    so i create the function in EventInstanceM

    Code:
    public void changeMusic(final MapleCharacter chr) {
             //"Bgm00/Florallife"
           chr.getClient().getSession().write(CField.musicChange(name));
        }
    bump...
    Last edited by mixtamal6; 24-09-15 at 07:49 AM.

  5. #5
    ・ARC:+200 Yuuroido is offline
    MemberRank
    Jul 2010 Join Date
    Saitama, JPLocation
    333Posts

    Re: Help in Scripting!

    then
    Code:
    eim.broadcastPacket(CField.musicChange(songName));

  6. #6
    Account Upgraded | Title Enabled! mixtamal6 is offline
    MemberRank
    Mar 2013 Join Date
    686Posts

    Re: Help in Scripting!

    dont work.... :c
    Code:
    Event nameMIQUEST, Instance name : Quest142, method Name : scheduledTimeout:
    javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "CField" is not defined. (<Unknown source>#119)
    use this:

    Code:
    function scheduledTimeout(eim) {
    eim.broadcastPacket(CField.musicChange(Bgm08/PlotOfPixie));
    }

  7. #7
    ・ARC:+200 Yuuroido is offline
    MemberRank
    Jul 2010 Join Date
    Saitama, JPLocation
    333Posts

    Re: Help in Scripting!

    oh, sorry.
    hmm... didn't you delete
    Code:
    importPackage(Packages.tools.packet);
    ?

  8. #8
    Account Upgraded | Title Enabled! mixtamal6 is offline
    MemberRank
    Mar 2013 Join Date
    686Posts

    Re: Help in Scripting!

    Quote Originally Posted by Yuuroido View Post
    oh, sorry.
    hmm... didn't you delete
    Code:
    importPackage(Packages.tools.packet);
    ?
    delete or add?

  9. #9
    ・ARC:+200 Yuuroido is offline
    MemberRank
    Jul 2010 Join Date
    Saitama, JPLocation
    333Posts

    Re: Help in Scripting!

    I mean do not delete it.
    Quote Originally Posted by mixtamal6 View Post
    hi , I could help me as I can add a change of music in eventscript ?

    i have this...

    Code:
    importPackage(java.lang);
    importPackage(Packages.tools.packet);
    ~~~

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

    Re: Help in Scripting!

    Quote Originally Posted by mixtamal6 View Post
    Code:
    public void changeMusic(final MapleCharacter chr) {
             //"Bgm00/Florallife"
           chr.getClient().getSession().write(CField.musicChange(name));
        }
    That will never ever work. Where is name comming from? You don't specify a var for text.

    Code:
    public void changeMusic(final MapleCharacter chr, String name) {
             //"Bgm00/Florallife"
           chr.getClient().getSession().write(CField.musicChange(name));
        }
    followed by eim.changeMusic(chr, name);

    also make sure you indeed import the proper packages. Why doesn't your compiler throw these issues?

    EDIT as for doing it without an internal addition (the void musicChange) i think simply importing MapleCharacter in the script on your first post should do the trick... At least on java 7

  11. #11
    not a programmer eshays is offline
    MemberRank
    Mar 2015 Join Date
    532Posts

    Re: Help in Scripting!

    AbstractPlayerInteraction has:
    PHP Code:
        public final void changeMusic(final String songName) {
            
    getPlayer().getMap().broadcastMessage(CField.musicChange(songName)); } 
    So you can use with npc/reactor/portal(cm/rm/pi).changeMusic("Bgm00/Florallife") because they extends AbstractPlayerInteraction but EventInstanceManager does not.

    @Novak
    Do you know what the differences are?
    EventInstanceManager:
    PHP Code:
        public final void changeMusic(final MapleCharacter chr, final String songName) {
            
    //chr.getClient().getSession().write(CField.musicChange(songName)); whats the difference?
            
    chr.getMap().broadcastMessage(CField.musicChange(songName)); } 
    Event Script:
    1.
    PHP Code:
    importPackage(Packages.client.MapleCharacter);
    function 
    scheduledTimeout(eim) {
    eim.changeMusic(chrCField.musicChange("Bgm00/Florallife"));
    eim.broadcastPlayerMsg(6"Music Change"); } 
    Is better than these?
    2.
    PHP Code:
    importPackage(Packages.client.MapleCharacter);
    function 
    scheduledTimeout(eim) {
            
    //chr.getClient().getSession().write(CField.musicChange("Bgm00/Florallife")); whats the difference?
            
    chr.getMap().broadcastMessage(CField.musicChange("Bgm00/Florallife"));
            
    eim.broadcastPlayerMsg(6"Music Change"); } 
    3.
    PHP Code:
    function scheduledTimeout(eim) {
    eim.broadcastPacket(CField.musicChange("Bgm00/Florallife"));
    eim.broadcastPlayerMsg(6"Music Change"); } 
    4. add "player"?
    https://forum.ragezone.com/f566/help...8/#post8502078 or?
    4.1. add "player"?
    PHP Code:
      public void timeOut(final long delay, final EventInstanceManager eim, final MapleCharacter player) {
    ...
    em.getIv().invokeFunction("scheduledTimeout"eimplayer); }

        public 
    void restartEventTimer(long timeMapleCharacter player) {
            ...
                
    timeOut(timethisplayer); }

        public 
    void startEventTimer(long timeMapleCharacter player) {
            
    restartEventTimer(timeplayer); } 
    PHP Code:
    function scheduledTimeout(eimplayer) {
    eim.changeMusic(playerCField.musicChange("Bgm00/Florallife"));
    eim.broadcastPlayerMsg(6"Music Change"); } 
    5. add "mapid"
    PHP Code:
      public void timeOut(final long delay, final EventInstanceManager eim, final int mapid) {
    ...
    em.getIv().invokeFunction("scheduledTimeout"eimmapid); }

        public 
    void restartEventTimer(long timeint mapid) {
            ...
                
    timeOut(timethismapid); }

        public 
    void startEventTimer(long timeint mapid) {
            
    restartEventTimer(timemapid); } 
    PHP Code:
    function scheduledTimeout(eimmapid) {
    var 
    map eim.getMapInstance(mapid);
    //or var map = getMap(eim);?
    //or var map = em.getChannelServer().getMapFactory().getMap(mapid);?
    map.broadcastMessage(CField.musicChange("Bgm00/Florallife"));
    eim.broadcastPlayerMsg(6"Music Change"); } 
    Last edited by eshays; 26-09-15 at 02:11 PM.

  12. #12
    Account Upgraded | Title Enabled! mixtamal6 is offline
    MemberRank
    Mar 2013 Join Date
    686Posts

    Re: Help in Scripting!

    Ok, i try when go my home n.n

    - - - Updated - - -

    hi,thanks for replys, when use import


    Code:
    importPackage(Packages.client.MapleCharacter);
    



    have error when loading server...

    i try use this:

    Code:
    function scheduledTimeout(eim,player) {
    eim.changeMusic(player, "Bgm08/PlotOfPixie");
    eim.broadcastPlayerMsg(6, "Music Change");
    }
    
    
     public final void changeMusic(final MapleCharacter chr, final String songName) {
            chr.getMap().broadcastMessage(CField.musicChange(songName));
        }
    have this problem now:
    Code:
    Event nameMIQUEST, Instance name : Quest142, method Name : scheduledTimeout:
    javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: Can't find method scripting.EventInstanceManager.changeMusic(sun.org.mozilla.javascript.internal.Undefined,string).
    
    

    Last edited by mixtamal6; 24-09-15 at 10:17 PM.

  13. #13
    ・ARC:+200 Yuuroido is offline
    MemberRank
    Jul 2010 Join Date
    Saitama, JPLocation
    333Posts

    Re: Help in Scripting!

    use this (as I mentioned)
    Code:
    importPackage(java.lang);
    importPackage(Packages.tools.packet);
    
    function scheduledTimeout(eim) {
        eim.broadcastPacket(CField.musicChange("Bgm08/PlotOfPixie"));
        eim.broadcastPlayerMsg(6, "Music Change");
    }
    I tested it and worked fine.

    ------
    Quote Originally Posted by mixtamal6 View Post
    ~~~
    Code:
    Event nameMIQUEST, Instance name : Quest142, method Name : scheduledTimeout:
    javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: Can't find method scripting.EventInstanceManager.changeMusic(sun.org.mozilla.javascript.internal.Undefined,string).
    
    

    Of course you'll get this error because you haven't defined "MapleCharacter(player)".
    Quote Originally Posted by mixtamal6 View Post
    Code:
    function scheduledTimeout(eim,player) {
    eim.changeMusic(player, "Bgm08/PlotOfPixie");
    eim.broadcastPlayerMsg(6, "Music Change");
    }
    There is no
    Code:
    scheduledTimeout(eim,player)
    just
    Code:
    em.getIv().invokeFunction("scheduledTimeout", eim);
    so if you want to do that, then you have to add "player"
    Code:
    em.getIv().invokeFunction("scheduledTimeout", eim, player);
    Code:
      public void timeOut(final long delay, final EventInstanceManager eim, MapleCharacter player) {

  14. #14
    Account Upgraded | Title Enabled! mixtamal6 is offline
    MemberRank
    Mar 2013 Join Date
    686Posts

    Re: Help in Scripting!

    Thanks so much! work now! n.n

    - - - Updated - - -

    @Yuuroido

    bro, how to use other method in maplecharacter, but example.

    i have this method in maplecharacter

    Code:
    public void StageT(){
                if (getMonsterCount(getMapId())== 0) {
                //action...1
    //but example show new message
                   dropMessage(-1,"Hi i am action 1");
                } else {
                   //action 2
                 dropMessage(-1,"Sorry i am action 2");
                }
           
        }
    use this??

    Code:
    function scheduledTimeout(eim) {
    
    
    eim.broadcastPacket(StageT()); 
    
    
    }
    already use in npcConversation

    cm.StageT();

    and work fine n.n! but i dont know how to use in EventManager

  15. #15
    ・ARC:+200 Yuuroido is offline
    MemberRank
    Jul 2010 Join Date
    Saitama, JPLocation
    333Posts

    Re: Help in Scripting!

    no, eim.broadcastPacket(); is only used for packet(bytes)
    Code:
    function scheduledTimeout(eim) {
        var players = eim.getPlayers();
        for (i = 0; i < players.size(); i++) {
            players.get(i).StageT();
        }
    }

  16. #16
    Account Upgraded | Title Enabled! mixtamal6 is offline
    MemberRank
    Mar 2013 Join Date
    686Posts

    Re: Help in Scripting!

    Quote Originally Posted by Yuuroido View Post
    no, eim.broadcastPacket(); is only used for packet(bytes)
    Code:
    function scheduledTimeout(eim) {
        var players = eim.getPlayers();
        for (i = 0; i < players.size(); i++) {
            players.get(i).StageT();
        }
    }
    sorry if I am very confused , but never had encoded EventScript, i understand, but how to use this method in eventscript?
    //MapleCharacter defined
    public final void STAGE_Start(){
    getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(9801016),new Point(88, 78));
    }
    Last edited by mixtamal6; 24-09-15 at 10:51 PM.

  17. #17
    ・ARC:+200 Yuuroido is offline
    MemberRank
    Jul 2010 Join Date
    Saitama, JPLocation
    333Posts

    Re: Help in Scripting!

    Quote Originally Posted by mixtamal6 View Post
    //MapleCharacter defined
    public final void STAGE_Start(){
    getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(9801016),new Point(88, 78));
    }
    ...You really want to use it?
    in eventscript
    PHP Code:
    function setup() {//depends on startInstance(EventManager)
        
    var eim em.newInstance(/*eventName*/);
        var 
    map eim.setInstanceMap(/*mapID*/);//register the map to EventInstanceManager
        
    var mob em.getMonster(9801016);//return MapleLifeFactory.getMonster(id)
        
    eim.registerMonster(mob);//register the monster to EventInstanceManager
        
    map.spawnMonsterOnGroudBelow(mob,new java.awt.Point(8878));

    Last edited by Yuuroido; 24-09-15 at 11:53 PM.

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

    Re: Help in Scripting!

    Quote Originally Posted by eshays View Post
    AbstractPlayerInteraction has:
    PHP Code:
        public final void changeMusic(final String songName) {
            
    getPlayer().getMap().broadcastMessage(CField.musicChange(songName)); } 
    So you can use with npc/reactor/portal(cm/rm/pi).changeMusic("Bgm00/Florallife") because they extends AbstractPlayerInteraction but EventInstanceManager does not.

    @Novak
    Do you know what the differences are?
    EventInstanceManager:
    PHP Code:
        public final void changeMusic(final MapleCharacter chr, final String songName) {
            
    //chr.getClient().getSession().write(CField.musicChange(songName)); whats the difference?
            
    chr.getMap().broadcastMessage(CField.musicChange(songName)); } 
    You mean the difference between
    chr.getClient().getSession().write(CField.musicChange(songName));
    and
    chr.getMap().broadcastMessage(CField.musicChange(songName));
    ?

    Since it's really simple, one grabs the player, finds the connected client that player belongs to, and sends this packet to just that client, meaning the music will only change for that 1 specific player.

    The other will literrally broadcast, it get's the map the character is on, finds all the clients that have a character in that channel/world on that map, and broadcasts the packet to all of them. The result is music changing for all players on said map.

    As for which one to use, that depends on what you want to achieve. Do you want everyone in the map to hear it? Or just one person? Most of the time in a event you'll just use the one that sends it to the entire map, picking out one character cab be a bit more annoying.



Advertisement