Make rooms, Independent & Persistent
Posted: 25 Feb 2013, 20:46
-- Problem #1
Well, i need create rooms from the client. Easily i can use the method provided in the documentation, and add the variable from any room map file, but no! Because the openspace do the decoration changes in that file, and if a do a change in my room map, the map of another room is the same, so the changes i do happens in the 2 rooms with the same map!
So? What's what i need? I need create a method to write a specific map file, when i create the room...
Well, in the documentation includes this server object function called .writeFile() this creates a file in the Server folder (I Have Modified the OpenSpace Extension to use the maps from this folder) perfect! i'm gonna use this code :
the map instance contains the Houses#default.map text content, so if we create a file with the same content of the default maps, it looks like the same, but this is independent...
NOTE : THIS DON'T WORKS - THE writeFile() Doesn't work! Why? I DON'T KNOW!
So i need a method to create a file...
-- Problem #2 : Create a Persistent Room,
When a use the method mentioned, the server creates a dynamic room...What it means? THE ROOM IS DELETED WHEN THE USER IS OUT!!...
So? How i can create a persistent(static) room from the client?
_________________________________________________________________
Thanks! Please Reply....
Well, i need create rooms from the client. Easily i can use the method provided in the documentation, and add the variable from any room map file, but no! Because the openspace do the decoration changes in that file, and if a do a change in my room map, the map of another room is the same, so the changes i do happens in the 2 rooms with the same map!
So? What's what i need? I need create a method to write a specific map file, when i create the room...
Well, in the documentation includes this server object function called .writeFile() this creates a file in the Server folder (I Have Modified the OpenSpace Extension to use the maps from this folder) perfect! i'm gonna use this code :
Code: Select all
private function onCreateClick(e:MouseEvent):void
{
logTrace("Creating Room...")
// --- Room Data --------------------------------
var roomObj = {}
roomObj.name = ti_room.text
roomObj.maxU = 25
roomObj.isGame = false
var room = ti_room.text
// --- Vars --------------------------------
var roomVars = [
{name:"_os_mapId", type:"s", val:"Houses#"+ room +"", priv:false, persistent:true},
]
// --- Room Data Export --------------------------------
var newRoom = smartFox.createRoom(roomObj, roomVars)
var map = map.text
var ok = smartFox.writeFile("Houses#"+ room +".map", map)
if (ok)
trace("File saved!")
else
trace("File write failed!")
// --- Room Data Export - Process Status --------------------------------
if (newRoom != null)
trace("Room Created...")
else
trace("An Error Ocurred : onCreateRoom Function...#18!")
}
the map instance contains the Houses#default.map text content, so if we create a file with the same content of the default maps, it looks like the same, but this is independent...
NOTE : THIS DON'T WORKS - THE writeFile() Doesn't work! Why? I DON'T KNOW!
So i need a method to create a file...
-- Problem #2 : Create a Persistent Room,
When a use the method mentioned, the server creates a dynamic room...What it means? THE ROOM IS DELETED WHEN THE USER IS OUT!!...
So? How i can create a persistent(static) room from the client?
_________________________________________________________________
Thanks! Please Reply....