Code: Select all
function init()
{
// get a reference to the database manager object
// This will let you interact the database configure for this zone
dbase = _server.getDatabaseManager()
trace("VIP_ship extension loaded and running.")
// create a SQL statement
var sql = "SELECT * FROM ships ORDER BY id"
// execute query on DB
// queryRes is a ResultSet object
var queryRes = dbase.executeQuery(sql)
// queryRes is ResultSet object
// Methods available:
//
// size() the number of records contained
// get(n) get the nth record in the RecordSet
//
// Example:
// var record = queryRes.get(0)
//
// Gets the first record in the RecordSet
//
if (queryRes != null)
{
// Cycle through all records in the ResultSet
for (var i = 0; i < queryRes.size(); i++)
{
// Get a record
var tempRow = queryRes.get(i)
// This object will hold the record data that we'll send to the client
var roomObj = {}
// From the record object we can get each field value
roomObj.name = tempRow.getItem("shipname")
roomObj.pwd = ""
roomObj.maxU = 50
roomObj.maxS = 0
roomObj.isGame = false
roomObj.uCount = false
trace(roomObj.name+":"+roomObj.pwd+":"+roomObj.maxU+":"+roomObj.maxS+":"+roomObj.isGame+":"+roomObj.uCount);
_server.createRoom(roomObj, null)
}
}
else
trace("DB Query failed")
}
The weird thing is, if I shut down the server and then start it, it works fine, but if I restart it using the admin tool I get this error:
Code: Select all
2006/02/16 18:51:32.123 - [ WARNING ] [id: 12] (ExtensionHelper.createRoom): Exception while creating room from the server side: java.lang.NullPointerException
Also, sometimes I forget to logout from the admin tool, and so it times out. If I try to log back in, it says the user is already logged in, forcing me to restart the server or wait a really long time. Neither is a lot of fun... Any ideas?