What file is the 1st part of the code added in?
|
|
Well, I got tired of simply adding npcs into the npcspawn.cfg manually and since I use one of these
for my MySql based server. I figured I'd make one for the standard .cfg file which most of these 508
server's use. Hope it helps someone. Mission is to save developers time.
First add this:
Then go add thisCode:/** * Handles spawning a new npc in-game and * also add's it to your npcspawn.cfg * @author BamBam <[email protected]> * @version %1% * @param NpcID the NpcId of the npc that is added. */ public void addNpc(int NpcID) { BufferedWriter bw = null; try { bw = new BufferedWriter(new FileWriter("./data/npcs/npcspawn.cfg", true)); bw.write("spawn = " +NpcID+ "\t" +absX+ "\t" +absY +"\t0\t0\t0\t0\t0\tNpc "+NpcID+" was added in-game by BamBam. Runekeep.com"); frames.sendMessage(this, "NPC was added to npcspawn.cfg."); bw.newLine(); bw.flush(); } catch (Exception e) { e.printStackTrace(); } }
Code:/** * Command for spawning a new npc in-game and * adding it to your npcspawn.cfg * @author BamBam <[email protected]> * @version %1% */ if (cmd[0].equals("addnpc")) { try { int NpcID = Integer.parseInt(cmd[1]); Server.engine.newNPC(Integer.parseInt(cmd[1]), p.absX, p.absY, p.heightLevel, p.absX, p.absY, p.absX, p.absY, false, 0); p.addNpc(NpcID); } catch (Exception e) { p.frames.sendMessage(p, "Usage: addnpc NpcID"); } }
To use, you must type ::addnpc npcid in-game.
(e.g ::addnpc 14 would add a druid in-game and save it into the npcspawn.cfg.)
If its useful to you, a simple Thank You is all I'm looking for. =)
Enjoy.
BamBam - RK
What file is the 1st part of the code added in?
Oh, I didn't know one of these were released. but, Thank you. Nice sig by the way, pretty funny. =)

Nice but i suggest checking conventions.
No need for new lines and spaces in lines
Also. remove your site from the code.Code:/** * Handles spawning a new npc in-game and * also add's it to your npcspawn.cfg * @author BamBam <[email protected]> * @version %1% * @param NpcID the NpcId of the npc that is added. */ public void addNpc(int NpcID) { BufferedWriter bw = null; try { bw = new BufferedWriter(new FileWriter("./data/npcs/npcspawn.cfg", true)); bw.write("spawn = " +NpcID+ "\t" +absX+ "\t" +absY +"\t0\t0\t0\t0\t0\tNpc "+NpcID+" was added in-game by BamBam. "); frames.sendMessage(this, "NPC was added to npcspawn.cfg."); bw.newLine(); bw.flush(); } catch (Exception e) { e.printStackTrace(); } }
I use a MySQL version something like this, adding the npc i want, also adding the player coord offset for the size of the npc if you want it, then editable later in the mysql.
Way cleaner than CFG file loading
Well, I do know conventions. However, everyone has there own way of doing things, I find it easier to read using my style. but, thank you for your opinion. It's much appreciated.
Also. I am the author. The web address is the source distributor. Removing it, is like stealing the code itself. I would like it to stay in there as to people know the original group that created it. You wouldn't go to sourceforge.net and copy their code and remove everything that is related to their author or work group, would you? This is what open source is all about. Groups, Communities, Dedication. Work as a team. Win as a individual. =)
Nice, Thank you.
| « 562 [rs2hd] Godwars Spawn! | [508/525] Make a autospawning NPC w/o going into the source files [508/525] » |
| Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |