Author Topic: SDK How to save table in serwer.  (Read 2356 times)

SDK How to save table in serwer.
« on: August 22, 2017, 03:40:46 am »
Hello i have question, how to permament save table with variables in SDK server. Maybe is possible to set gvar/lvar with type parameter to send table as variable, but i dont think so. I need it in many critter scripts to change critter parametrs when critter is not logged in. Do you know how to change critter parametr when critter is not loaded to game (player is offline)? I can get critter ID, critter name but i can get critter as 'critter' to change parametrs etc. Maybe you have some idea how for example add offline player to fraction (change his param) or get list of all fraction players (i think saved table with id's is good idea but i dont know how to do this). Thank you in advance for your help.


@edit
Also it can be how to operate on files in serwer folder, operation like file.open() in scripts is dedicated for files in client folder. If I find out how to do this it will manipulate read/write files to achieve what I needs.
« Last Edit: August 22, 2017, 03:53:22 am by dawidsonki »

Re: SDK How to save table in serwer.
« Reply #1 on: August 28, 2017, 08:16:39 pm »
What you do is create a critter and store your variables onto the critter params via Critter.ParamBase[index] , you get 1000 variables here! Move the critter to worldmap or a safe map and just simply store the critterhandle into a dictionary with the playerId as key. Then you can attach a initCritter script on this datastorage critter to automatically insert itself into the dictionary to maintain the dictionary data permanence between server sessions.

You can also following similiar logic as the critterStorageDeviceâ„¢ with maps. Create a location and then get the map(s). Using the handy map::setData(index, int); You get to store 100 variables here references by Map.Id!

or you could create an boring anydata.

@edit
To access server files with file.open() just use pre-pend to the filepath "../server/" !
« Last Edit: August 28, 2017, 08:20:51 pm by devis »