Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.rs.worldserver;
- import java.sql.*;
- import java.io.*;
- import com.rs.worldserver.util.*;
- import com.rs.worldserver.model.npc.NPC;
- import com.rs.worldserver.model.npc.NPC;
- import com.rs.worldserver.model.npc.NPCAction;
- import com.rs.worldserver.model.npc.NPCDefinition;
- import com.rs.worldserver.model.npc.NPCDrop;
- public class SQL {
- public static Connection connection = null;
- public static Connection myConnection = Server.connection;
- public SQL() {AutoSpawn();}
- public static void AutoSpawn() {
- try {
- String driverName = "com.mysql.jdbc.Driver";
- Class.forName(driverName).newInstance();
- // Create a connection to the database
- String serverName = "127.0.0.1";//your SQL server
- String dbase = "";
- String url = "jdbc:mysql://" + serverName + ":3306/dynamicdb";
- String username = "root";
- String password = "";
- connection = DriverManager.getConnection(url, username, password);
- Statement stmt = connection.createStatement();
- ResultSet rs = stmt.executeQuery("SELECT * FROM autospawn");
- while (rs.next()) {
- int id = rs.getInt("NpcID");
- int slot = rs.getInt("Slot");
- NPCDefinition def = Server.npcManager.npcDefinitions.get(id);
- if (def == null)
- continue;
- //count = rs.getRow();
- NPC npc = new NPC(slot, def, rs.getInt("StartX"), rs.getInt("StartY"), rs.getInt("StartHeight"));
- //NPC npc = new NPC(slot, def, Integer
- //.valueOf(valuesArray[1]), Integer
- //.valueOf(valuesArray[2]), Integer
- //.valueOf(valuesArray[3]));
- //npc.setX1(rs.getInt("RangeX1"));
- //npc.setY1(rs.getInt("RangeY1"));
- //npc.setX2(rs.getInt("RangeX2"));
- //npc.setY2(rs.getInt("RangeY2"));
- //int walkType = rs.getInt("WalkType");
- //if (walkType == 1 || walkType == 2) {
- //npc.setWalking(true);
- //}
- Server.npcManager.npcMap.put(npc.getNpcId(), npc);
- }
- stmt.close();
- } catch (Exception e){
- Misc.println("Error "+e);
- }
- }
- }
Add Comment
Please, Sign In to add comment