created room and roomvars backup
-
Portuguese
- Posts: 12
- Joined: 07 Apr 2006, 23:43
created room and roomvars backup
I would like a created room and roomvars backup so they won't erase when the servers resets, please i need it
sorry for posting in an other "topic" i pressed the wrong button...
but is it possible what i asked?
sorry for posting in an other "topic" i pressed the wrong button...
but is it possible what i asked?
-
DavidPesta
- Posts: 27
- Joined: 13 Apr 2006, 19:22
-
DavidPesta
- Posts: 27
- Joined: 13 Apr 2006, 19:22
I noticed this was Lapo's answer as well:
http://forums.smartfoxserver.com/viewtopic.php?t=424
http://forums.smartfoxserver.com/viewtopic.php?t=424
-
Portuguese
- Posts: 12
- Joined: 07 Apr 2006, 23:43
-
DavidPesta
- Posts: 27
- Joined: 13 Apr 2006, 19:22
A solution to this that occurred to me recently is to format all of your variables in an XML structure and store that structure in a single mediumtext field. 'TEXT' (65K) is smaller than 'MEDIUMTEXT' (16M) in MySQL, which may be too small, so use 'MEDIUM' instead of 'TEXT' if you have a lot going on in that room. Use 'LONGTEXT' only if you are saving especially massive rooms.
Of course, this may not be so good for keeping a persistent/continual copy of room variables, only for a single backup before the server comes down, which requires prior knowledge of the server coming down beforehand. You could take minutely snapshots--but with massive rooms that would really slow down your server.
So it looks like your best bet for especially massive rooms would be to keep all room data in their own variable fields afterall. Keep player data in their own database table and report the room that the player exists in inside of the player database table.
Okay, these are a few strategies that I would begin to think about. Your goal is to evaluate the way your application functions and structure your tables for data accordingly.
David
Of course, this may not be so good for keeping a persistent/continual copy of room variables, only for a single backup before the server comes down, which requires prior knowledge of the server coming down beforehand. You could take minutely snapshots--but with massive rooms that would really slow down your server.
So it looks like your best bet for especially massive rooms would be to keep all room data in their own variable fields afterall. Keep player data in their own database table and report the room that the player exists in inside of the player database table.
Okay, these are a few strategies that I would begin to think about. Your goal is to evaluate the way your application functions and structure your tables for data accordingly.
David
-
DavidPesta
- Posts: 27
- Joined: 13 Apr 2006, 19:22
Read through this as well.
http://forums.smartfoxserver.com/viewtopic.php?t=554
http://forums.smartfoxserver.com/viewtopic.php?t=554
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
@DavidPesta.
Using a database is not a must here eigther. You can use _server.writeFile() method to write to a file and then read them with something like
Using a database is not a must here eigther. You can use _server.writeFile() method to write to a file and then read them with something like
Code: Select all
var roomVarsString = _server.readFile("../room1vars.bkp")function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
-
Portuguese
- Posts: 12
- Joined: 07 Apr 2006, 23:43
ooh thanks that will be great!
ooh thanks that will be great! but where can i find like a toturial or where in the DOCs could i fin it to read more... and how should i save the variable text? because if i write variable per variable it would take me lot memory and time.... or if there is another way to save the variables in the text files with saving them one per one..?
-
Portuguese
- Posts: 12
- Joined: 07 Apr 2006, 23:43
could it be by arrays?
if i do it by arrays, how can i load the array from the mySQL because if i do it.. in the clientside.. if i do vars[2] it will tell me 'undefined' so how can i do it?
Example of saving and reading an array as a string.
Only thing to note is that now you have strings as elements of your myArray and not numbers anymore.
Code: Select all
var myArr = [1,343,3,53,23,64];
var str = myArr.join(",");
var ok = _server.writeFile("testarray.txt", str);
if (ok)
trace("File saved!")
else
trace("File write failed!")
/// ------------ let's assume the file was saved.
// - you can read them like
var str = _server.readFile("testarray.txt");
myArray = str.split(",");
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
-
Portuguese
- Posts: 12
- Joined: 07 Apr 2006, 23:43
ooh tanks!! but...
thanks but... when i reset the server and the server starts again... all the inits(); in the extension will be invoked? or what can i do that when the server resets and starts again... do something?
Yes, when the server restarts, as long as the extensions is a zone level extension and is attached from the config.xml, the init method will be called.
If your rooms where static, they also are in the xml with some extension attached. When server starts the rooms will be created.
If you created the rooms dinamically then you will also need to constantly save data about the rooms from the zone extension so that you will be able to recreate the rooms when the zone level extension's init method's is called.
If your rooms where static, they also are in the xml with some extension attached. When server starts the rooms will be created.
If you created the rooms dinamically then you will also need to constantly save data about the rooms from the zone extension so that you will be able to recreate the rooms when the zone level extension's init method's is called.
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}