ServerData
Class
ServerData
Summary
This game use ServerData to store data,it can be saved as persistent data on server. including user defined item, exp, level, etc...
ServerData is shared across every instance of same map, thus, you can load and save the same ServerData in any instance of same map.
Data Structure
data is stored in dictionary, to be specific: Lua table. value stored in the dictionary can be indexed by data name which is a unique key string, this key should contain player's uuid, for example:
键
值
p#10001
40
p#11002
10
p#20301
34
p#1324
67
Properties
Functions
GetAsync(key)
[yields] get a value by its name.IncreaseAsync(key, delta)
[yields] increase a value. the value should be a number.RemoveAsync(key)
[yields] remove a data by name. this function will return the deleted value.SetAsync(key, value)
[yields] set value by name, this will overwrite exist value or create new a one.TrySetAsync(key, value)
[yields] try set a value by name, if the value was altered by other players , it will fail. when it failed, current value on server will returned.UpdateAsync(key, updateFunction)
[yields] find and update a value by name.
Events
Last updated
Was this helpful?