Thread: Make every npc shout a message on command

Page 1 of 3 123 LastLast
Results 1 to 10 of 23
  1. #1 Make every npc shout a message on command 
    Registered Member
    fabjan's Avatar
    Join Date
    Jul 2007
    Age
    27
    Posts
    552
    Thanks given
    0
    Thanks received
    0
    Rep Power
    101
    purpose: to make every npc shout a message above its head when you type the command (message given in the command ofc)
    difficulty: 1/10
    assumed knowledge: c+p
    tested server: whitescape pulse v2
    classes modified: commandhandler/commands/client wherever your commands are.

    step 1:
    open the .java file that contains your command code.

    step 2:
    find a spot to add your new command

    step 3:
    add the below code to your commands on the spot you have just found:
    if your commands are handled:
    Code:
    			if(command.startsWith("npcshout")) {
    			try {
    			for(int i = 0; i < server.npcHandler.npcs.length; i++) {
    			try {
    			if(server.npcHandler.npcs[i] != null) {
    			server.npcHandler.npcs[i].updateRequired = true;
    			server.npcHandler.npcs[i].textUpdateRequired = true;
    			server.npcHandler.npcs[i].textUpdate = command.substring(9);
    			}
    			} catch (Exception e) {
    			c.sendMessage("npcslot "+i+" invalid for shouting.");
    			}
    			}
    			} catch (Exception e) {
    			c.sendMessage("command ("+command+") was invalid, please check your input.");
    			}
    			}
    if your commands are inside client.java:
    Code:
    			if(command.startsWith("npcshout")) {
    			try {
    			for(int i = 0; i < server.npcHandler.npcs.length; i++) {
    			try {
    			if(server.npcHandler.npcs[i] != null) {
    			server.npcHandler.npcs[i].updateRequired = true;
    			server.npcHandler.npcs[i].textUpdateRequired = true;
    			server.npcHandler.npcs[i].textUpdate = command.substring(9);
    			}
    			} catch (Exception e) {
    			sendMessage("npcslot "+i+" invalid for shouting.");
    			}
    			}
    			} catch (Exception e) {
    			sendMessage("command ("+command+") was invalid, please check your input.");
    			}
    			}
    step 4:
    then save the file you just edited

    step 5:
    compile your server's *.java files

    step 6:
    run your server

    step 7:
    log in to your server

    step 8:
    type ::npcshout "message the npcs must shout here"

    step 9:
    be amazed by the result :woot:

    extra:
    if you want your command admin only or for you only you should know what to do and if you dont:
    Code:
    if (command.startsWith("npcshout") && playerRights >= 2) {
    or
    Code:
    if (command.startsWith("npcshout") && playerName.equals("your character name") {
    enjoy it


    credits: 100% to me (as if this needs to be leeched..)
    Please vote:
    [Only registered and activated users can see links. ]
    btb.servegame.com:
     

  2. #2  
    Vegeta
    Guest
    That's pretty sweet. I will add this. Thanks!
     

  3. #3  
    Banned

    Join Date
    May 2008
    Posts
    2,327
    Thanks given
    55
    Thanks received
    67
    Rep Power
    0
    wont this cause lag... making all the npc's talking at same exact time...

    probably makes some ppl crash whens there say like 50 ppl online and they al say that, when most ur npc's are in a same area....

    just saying other then that, goooood work
     

  4. #4  
    Donator

    tj007razor's Avatar
    Join Date
    Feb 2007
    Posts
    895
    Thanks given
    2
    Thanks received
    9
    Rep Power
    210
    Quote Originally Posted by silabgarza View Post
    wont this cause lag... making all the npc's talking at same exact time...

    probably makes some ppl crash whens there say like 50 ppl online and they al say that, when most ur npc's are in a same area....

    just saying other then that, goooood work
    No.

    Also, thanks tis very lulzy

    [Only registered and activated users can see links. ]

    [Only registered and activated users can see links. ] | [Only registered and activated users can see links. ] | [Only registered and activated users can see links. ]
     

  5. #5  
    Optimist

    Vice's Avatar
    Join Date
    Nov 2007
    Age
    25
    Posts
    3,263
    Thanks given
    3
    Thanks received
    59
    Rep Power
    2536
    Great job fabjan
    Jack
    Scotland
    Undergraduate - BSc Computing Science
     

  6. #6  
    Zelda
    Guest
    Sweeeet.
    Thanks, i'll add this just cause it's worth it .
     

  7. #7  
    Registered Member
    fabjan's Avatar
    Join Date
    Jul 2007
    Age
    27
    Posts
    552
    Thanks given
    0
    Thanks received
    0
    Rep Power
    101
    Quote Originally Posted by silabgarza View Post
    wont this cause lag... making all the npc's talking at same exact time...

    probably makes some ppl crash whens there say like 50 ppl online and they al say that, when most ur npc's are in a same area....

    just saying other then that, goooood work
    no, it doesnt matter how many players there are on at the same time, the npc just displays text above its head and shows for all players, and the text being showed takes a split second, it basically loops through all npc's in your server and tries to make text appear above its head, if it fails it will abort the action also.
    so this wont cause lagg.

    and maybe ur confused about what this does, but the thing is that the npcs only show it once, for the same amount of time as your text stays above your head when you talk. its really handy for announcing things.

    Quote Originally Posted by tj007razor View Post
    No.

    Also, thanks tis very lulzy
    you're welcome

    Quote Originally Posted by Vice View Post
    Great job fabjan
    i know thx

    Quote Originally Posted by Zelda View Post
    Sweeeet.
    Thanks, i'll add this just cause it's worth it .
    I don't know if its worth it, its simple though:woot:
    Please vote:
    [Only registered and activated users can see links. ]
    btb.servegame.com:
     

  8. #8  
    Zelda
    Guest
    Quote Originally Posted by fabjan View Post
    I don't know if its worth it, its simple though:woot:
    It's funny though, which makes it worth it

    Come on guys, tell him how funny it is
    Yeah, it is simple. But you know, i didn't think of it soooo. Yep worth it Lol.
     

  9. #9  
    Registered Member
    fabjan's Avatar
    Join Date
    Jul 2007
    Age
    27
    Posts
    552
    Thanks given
    0
    Thanks received
    0
    Rep Power
    101
    its not just funny
    its also effective, because you can let the whole world know of events or so without yelling, and some players dont really pay attention to the chatbox. but while training combat they will see the npcs shouting.
    Please vote:
    [Only registered and activated users can see links. ]
    btb.servegame.com:
     

  10. #10  
    Vv geget2
    Guest
    i added this is the lulz
     

Page 1 of 3 123 LastLast

Thread Information
Users Browsing this Thread

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


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •