Thread: Command that applies to all NPCs? (718)

Results 1 to 6 of 6
  1. #1 Command that applies to all NPCs? (718) 
    Registered Member
    Join Date
    Oct 2013
    Posts
    14
    Thanks given
    2
    Thanks received
    6
    Rep Power
    11
    I have this command which makes all players do animgfx, but I'm wondering if there is a way to make it apply to all NPC's too?

    case "animgfx":
    int animId = Integer.parseInt(cmd[1]);
    int gfxId = Integer.parseInt(cmd[2]);
    int height = cmd.length > 3 ? Integer.parseInt(cmd[3]) : 0;
    for (Player p : World.getPlayers()) {
    p.setNextAnimation(new Animation(animId));
    p.setNextGraphics(new Graphics(gfxId, 0, height));
    }
    return true;
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Registered Member
    arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,628
    Thanks given
    165
    Thanks received
    270
    Rep Power
    497
    There is a way. Just loop all npcs instead of players and have it send it instead.


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     

  4. Thankful user:


  5. #3  
    Registered Member
    Join Date
    Oct 2013
    Posts
    14
    Thanks given
    2
    Thanks received
    6
    Rep Power
    11
    Quote Originally Posted by arch337 View Post
    There is a way. Just loop all npcs instead of players and have it send it instead.
    Got it to work with this

    case "animgfx":
    int animId = Integer.parseInt(cmd[1]);
    int gfxId = Integer.parseInt(cmd[2]);
    int height = cmd.length > 3 ? Integer.parseInt(cmd[3]) : 0;
    for (NPC n : World.getNPCs()) {
    n.setNextAnimation(new Animation(animId));
    n.setNextGraphics(new Graphics(gfxId, 0, height));
    }
    return true;

    Would there however be a way to make it work for BOTH Npcs and players?
    Reply With Quote  
     

  6. Thankful user:


  7. #4  
    ya


    Join Date
    Jul 2014
    Posts
    478
    Thanks given
    106
    Thanks received
    82
    Rep Power
    419
    Quote Originally Posted by guthixfaithz View Post
    Got it to work with this

    case "animgfx":
    int animId = Integer.parseInt(cmd[1]);
    int gfxId = Integer.parseInt(cmd[2]);
    int height = cmd.length > 3 ? Integer.parseInt(cmd[3]) : 0;
    for (NPC n : World.getNPCs()) {
    n.setNextAnimation(new Animation(animId));
    n.setNextGraphics(new Graphics(gfxId, 0, height));
    }
    return true;

    Would there however be a way to make it work for BOTH Npcs and players?
    yh, think fella.

    Code:
     		if (command[0].equalsIgnoreCase("dunno")) {
    			int gfx = Integer.parseInt(command[1]);
    			int anim = Integer.parseInt(command[2]);
    
    			World.getNpcs().forEach(npc -> {
    				npc.performGraphic(new Graphic(gfx));
    				npc.performAnimation(new Animation(anim));
    			});
    
    			World.getPlayers().forEach(p -> {
    				p.performGraphic(new Graphic(gfx));
    				p.performAnimation(new Animation(anim));
    			});
    		}
    - Mostlikely possible to do it with just 1 iteration aswell.
    Reply With Quote  
     

  8. Thankful user:


  9. #5  
    Yob
    Yob is offline
    Registered Member Yob's Avatar
    Join Date
    May 2019
    Posts
    52
    Thanks given
    36
    Thanks received
    7
    Rep Power
    0
    Try this:
    Code:
    case "animgfx":
    				int animId = Integer.parseInt(cmd[1]);
    				int gfxId = Integer.parseInt(cmd[2]);
    				int height = cmd.length > 3 ? Integer.parseInt(cmd[3]) : 0;
                                    for (NPC n : World.getNPCs()) {
    				n.setNextAnimation(new Animation(animId));
    				n.setNextGraphics(new Graphics(gfxId, 0, height));
                                    }
                                    int animId = Integer.parseInt(cmd[1]);
    				int gfxId = Integer.parseInt(cmd[2]);
    				int height = cmd.length > 3 ? Integer.parseInt(cmd[3]) : 0;
                                    for (Player p : World.getPlayers()) {
    				n.setNextAnimation(new Animation(animId));
    				n.setNextGraphics(new Graphics(gfxId, 0, height));
                                    }
    				return true;
    or this:
    Code:
    case “animgfx”:
                                    int animId = Integer.parseInt(cmd[1]);
    				int gfxId = Integer.parseInt(cmd[2]);
    				int height = cmd.length > 3 ? Integer.parseInt(cmd[3]) : 0;
                                    for (NPC n : World.getNPCs && World.getPlayers()) {
    				n.setNextAnimation(new Animation(animId));
    				n.setNextGraphics(new Graphics(gfxId, 0, height));
                                    }
    Note sure if that’ll work or not.
    Kinda sloppy too, I’m not home on my PC atm.

    Let me know if it works or not, if not I’ll help furthermore.
    Achieve what your mind desires.
    Reply With Quote  
     

  10. Thankful users:


  11. #6  
    Registered Member
    Join Date
    Oct 2013
    Posts
    14
    Thanks given
    2
    Thanks received
    6
    Rep Power
    11
    Quote Originally Posted by Yob Taf View Post
    Try this:
    Code:
    case "animgfx":
    				int animId = Integer.parseInt(cmd[1]);
    				int gfxId = Integer.parseInt(cmd[2]);
    				int height = cmd.length > 3 ? Integer.parseInt(cmd[3]) : 0;
                                    for (NPC n : World.getNPCs()) {
    				n.setNextAnimation(new Animation(animId));
    				n.setNextGraphics(new Graphics(gfxId, 0, height));
                                    }
                                    int animId = Integer.parseInt(cmd[1]);
    				int gfxId = Integer.parseInt(cmd[2]);
    				int height = cmd.length > 3 ? Integer.parseInt(cmd[3]) : 0;
                                    for (Player p : World.getPlayers()) {
    				n.setNextAnimation(new Animation(animId));
    				n.setNextGraphics(new Graphics(gfxId, 0, height));
                                    }
    				return true;
    or this:
    Code:
    case “animgfx”:
                                    int animId = Integer.parseInt(cmd[1]);
    				int gfxId = Integer.parseInt(cmd[2]);
    				int height = cmd.length > 3 ? Integer.parseInt(cmd[3]) : 0;
                                    for (NPC n : World.getNPCs && World.getPlayers()) {
    				n.setNextAnimation(new Animation(animId));
    				n.setNextGraphics(new Graphics(gfxId, 0, height));
                                    }
    Note sure if that’ll work or not.
    Kinda sloppy too, I’m not home on my PC atm.

    Let me know if it works or not, if not I’ll help furthermore.
    Already got it to work with

    case "animgfx":
    int animId = Integer.parseInt(cmd[1]);
    int gfxId = Integer.parseInt(cmd[2]);
    int height = cmd.length > 3 ? Integer.parseInt(cmd[3]) : 0;
    for (NPC n : World.getNPCs()) {
    n.setNextAnimation(new Animation(animId));
    n.setNextGraphics(new Graphics(gfxId, 0, height));
    }
    for (Player p : World.getPlayers()) {
    p.setNextAnimation(new Animation(animId));
    p.setNextGraphics(new Graphics(gfxId, 0, height));
    }
    return true;

    I still appreciate the help though
    Reply With Quote  
     

  12. Thankful user:



Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Boolean Apply To All Players
    By Wobblum in forum Help
    Replies: 5
    Last Post: 12-05-2012, 12:32 AM
  2. [PI]Command that teleports to Slayer Task NPC
    By o paws in forum Snippets
    Replies: 10
    Last Post: 03-07-2012, 05:25 AM
  3. Replies: 1
    Last Post: 01-02-2011, 05:34 AM
  4. ::players command that you see all player names
    By pkownage135 in forum Requests
    Replies: 3
    Last Post: 02-14-2009, 07:47 PM
  5. How to adds a scoring system applied to all players
    By Bulby Strife in forum Tutorials
    Replies: 12
    Last Post: 02-03-2008, 11:33 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •