dynamic room generation

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

User avatar
goodguy20k
Posts: 71
Joined: 10 Jan 2006, 23:58
Location: Texas, USA
Contact:

dynamic room generation

Postby goodguy20k » 17 Feb 2006, 00:47

Ok, I'm trying to get SmartFox to create rooms (Decks for my ships) from my database. I have absolutely no problem retrieving the data, but in the room creation. Let me show you the code and explain the problem.

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
Twice.

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?
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 17 Feb 2006, 07:02

Question: I guess you're using of the last betas... which version?

The problem with the admin tool has been solved in the latest beta. (1.4.0beta3)
You will find an extra checkbox that forces the login of the admin even if another admin connection is alive.

If you need to download the latest beta check this page >> http://www.smartfoxserver.com/download/beta/
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
goodguy20k
Posts: 71
Joined: 10 Jan 2006, 23:58
Location: Texas, USA
Contact:

Postby goodguy20k » 17 Feb 2006, 20:30

I was running beta 1, just updated to beta 3. Great fix on the Admin tool. Everything's working great so far with room generation. Now just to battle a room variable error. (I'll make sure it's not something dumb I'm doing before posting it for help.) Thanks Lapo.

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 42 guests