Thread: ::addnpc saving? DEV 2.7 HELP!!!

Results 1 to 3 of 3
  1. #1 ::addnpc saving? DEV 2.7 HELP!!! 
    Registered Member Akeid's Avatar
    Join Date
    May 2009
    Posts
    911
    Thanks given
    22
    Thanks received
    15
    Rep Power
    37
    well , i fixed the ::addnpc command, but when i close the server cmd, the npc's go away. I want it to save to the autospawn.cfg file

    here is my method for ::addnpc

    package server.players.Commands;

    import server.*;
    import server.players.*;

    public class addnpc implements Command {
    int npc;
    int d;
    int hp;
    @Override
    public void execute(client client, String command) {
    if (client.playerRights > 2) {
    try {
    String[] args = command.split(" ");
    if (args.length == 3) {
    npc = Integer.parseInt(args[1]);
    d = Integer.parseInt(args[2]);
    int x = client.absX;
    int y = client.absY;
    int h = client.heightLevel;
    boolean respawn = true;
    if (npc > 2000) {
    client.CAM().sendMessage("NPCID cannot exceed the limit of 2000.");
    return;
    }
    if (d > 10) {
    client.CAM().sendMessage("distance cannot exceed the limit of 10.");
    return;
    }
    hp = server.npcHandler.npcs[npc].HP;
    server.npcHandler.newNPC(npc, x, y, h, x+d, y+d, x-d, y-d, 1, server.npcHandler.GetNpcListHP(npc), respawn);
    client.appendToAutoSpawn2(npc, x, y, x+d, y+d, x-d, y-d);
    }
    } catch (Exception e) {
    client.CAM().sendMessage("Incorrect usage, ::addnpc npcid distance");
    }
    } else {
    client.CAM().sendMessage("Only staff members can use this command.");
    }
    }
    }

    I want it to save to \bin\config\autospawn.cfg
    please remember that the auto spawn is

    //------NpcID---CoordX--CoordY--Height--RangeX1-RangeY1-RangeX2-RangeY2-WalkType-HP-Descrption
    Example:
    spawn = 1648 3413 3536 0 3414 3537 3412 3535 2 CRAWLING HAND
    Reply With Quote  
     

  2. #2  
    Registered Member
    Xynth's Avatar
    Join Date
    May 2009
    Posts
    2,222
    Thanks given
    226
    Thanks received
    259
    Rep Power
    1155
    Code:
    		BufferedWriter bw = null;
    
    		try {
    			bw = new BufferedWriter(new FileWriter("config//autospawn.cfg",
    					true));
    			bw.write(data);
    			bw.newLine();
    			bw.flush();
    		} catch (IOException ioe) {
    			ioe.printStackTrace();
    Reply With Quote  
     

  3. #3  
    Previously Hyperion


    Join Date
    Jan 2009
    Posts
    1,254
    Thanks given
    3
    Thanks received
    18
    Rep Power
    138
    just use :pawnnpc...its already in devo
    Reply With Quote  
     


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
  •