Game Development Community

X Y Z Location Saving?

by Don Weatherby · in Torque Game Engine · 10/31/2006 (8:13 pm) · 10 replies

Hi im contomplating on making a MMO-FPS out of TGE (and maybe MMO-KIT) and I was wondering if TGE support xyz saving of players and accounts like if i made an account and password setup then i login as "ryder" then Im spawned in and then i quit im wandering if Im able to make xyz saving so if i decide to relogin as "ryder" ill be in the same stop as when i quit.

hope others have had more success then i have thx in advance!

#1
10/31/2006 (8:51 pm)
Well, you can use object.getposition() and object.setTransform() for moving the object to a given position.

setTransform expects 7 arguements: Xposition, Yposition, Zposition, Xrotation, Yrotation, Zrotation, and Theta (angle).
#2
10/31/2006 (9:38 pm)
Someone recently posted something that does something like this... saves the values into a SQLite database.

www.garagegames.com/blogs/48513/11513
#3
11/01/2006 (8:56 am)
I looked at that but thats for items and Im not using sql right now I was looking more for Player xyz location saving for multiple players MMO style.

thx for the info.
#4
11/01/2006 (10:24 am)
You could have the server save and load from a plain text file if you don't want to use a database.
#5
11/02/2006 (8:37 am)
How would i go about using a plain text file to save/load?

and also im having trouble with getting melee to work from a resource i looked at but i have a seperate thread for that but havvent receivec any responses yet = (
#6
11/02/2006 (9:11 am)
Don -

the poor-man's way to do this would be to just store the info in a torquescript "array".

when the client disconnects:
$gSavedPlayerTransforms[%playerName] = %player.getTransform();

when the client connects:
%trans = $gSavedPlayerTransforms[%playerName];
if (%trans $= "")
   %trans = getTransformFromNormalSpanwPointSystem();
%player.setTransform(%trans);

obviously there's work for you to do here, but that should work for the basics.

caveats:

* if you're having 1000s and 1000s of unique players connecting, the global array will grow kinda big, but frankly i'd cross that bridge when you come to it. for mere hundreds of unique players this should be fine.

* if the server reboots/crashes, the information will be lost.
you can fix that by moving the global array into the "$pref" namespace (ie use $pref::SavedPlayerTransforms), or, better, moving it into a new namespace such as $Sessions and reading and writing the $Sessions namespace from its own file.
#7
11/02/2006 (11:24 am)
@ ORION

Great thanks alot and the poor mans way is just fine (cuz i kinda am one =\ ) and yea some work is needed but ill have a good look at this and see if ui cant make it work. i doubt that atm there will be 1000s but possibly 100s is more like it (If not less!) so this will mostlikey be a great addition to my game sweet!

so to get rid of the server crash/restart problem i could use $prefSave..... instead of $gSave...... im not that good of scripter yet more of level desine and modding but ive had some experiance with script and C++ so this should be somewhat easily implemented.

hey if i have any questions can i contaqct u via forums or ? thx again
#8
11/06/2006 (8:33 am)
How would i go about moving the global array to the $pref namespace? or moving it into a new namspace? with its own file? cuz right now i just use the sever on my own comp so everytime im gonna go in my character spawn point is deleted cuz my server restarts everytime i go in so help would be great thx.
#9
11/06/2006 (8:57 am)
Hiya -

again, starting w/ the poor man's way,
to move it into the prefs namespace, just change the variable to "$pref::savedPlayerTransforms".
that way it will be automatically loaded at startup and saved during a (clean) quit, using the file prefs.cs.

making it be its own namespace/file won't really change the behaviour, but does seem a bit cleaner.
just make up a namespace like "$poorMansDB" (eg $poorMansDB::savedPlayerTransforms).

when you want to save the file (possibly on every disconnect but definitely on exit) do something like:
export("$poorMansDB::*", "./server/poorMansDB.cs", false);

and then at startup, do something like:
exec("./server/poorMansDB.cs");


the prefs namespace does all this in main.cs.

i'm curious to hear how this goes!
#10
11/06/2006 (9:51 am)
Thx im gonna check this out its interesting thx for the info and the fast reply!