Jump to content

Redis Custom Columns


TheVampire

Recommended Posts

Since Epoch doesn't want server owners to touch the server files, does Epoch plan to add support for custom calls or sections of the redis?

 

In particular what I am wanting is to be able to make VEMF be able to store the mission stats per player in the Redis and recall them for a "stats" display to see who has the most AI kills, etc.

 

I also have other ideas in mind, but before I go crazy I wanted to ask.

 

I would think it would be better to add modifications to the dll earlier than later.

Link to comment
Share on other sites

I was hoping someone would ask this so I will go ahead and document some calls. Our database is schema-less this means that there are no columns or rows just keys and values. The best way to use the Epoch database for your own custom calls is to use your own key namespace. This would be similar to the TAG_*  or EPOCH_ practice Arma script makers use.
 
Save data with expiry in seconds (best way to prevent bloating db)
Index: 
0 = Key Name Prefix
1 = Key Name Unique ID
2 = Expire time in seconds (auto cleanup)
3 = Data can be a string or an array

_player = this; // ref to player
_prefix = "VEMF_DATA";
_uniqueId = getPlayerUID _player;
_expires = "2592000"; // 30 days
_data = ["your", "custom", "data", "goes", "here"]; // this can be an array or string
[_prefix, _uniqueId, _expires, _data] call EPOCH_server_hiveSETEX;

Save data
Index: 
0 = Key Name Prefix
1 = Key Name Unique ID
2 = Data can be a string or an array



_plyr = this; // ref to player
_prefix = "VEMF_DATA";
_uniqueId = getPlayerUID _plyr;
_data = ["your", "custom", "data", "goes", "here"]; // this can be an array or string
[_prefix, _uniqueId, _data] call EPOCH_server_hiveSET;

Save Boolean
Index: 
0 = Key Name Prefix
1 = Key Name Unique ID
2 = Numeric index
3 = Boolean 



_player = this; // ref to player
_prefix = "VEMF_STATS";
_uniqueId = getPlayerUID _player;
_val = 1; // 1 = true, 0 = false 
[_prefix, _uniqueId, 0, 1] call EPOCH_server_hiveSETBIT;

Get data
Index: 
0 = Key Name Prefix
1 = Key Name Unique ID
 
Returns: Array



_player = this; // ref to player
_prefix = "VEMF_DATA";
_uniqueId = getPlayerUID _player;

_response = [_prefix, _uniqueId] call EPOCH_server_hiveGET;
_arr = [];
 
if ((_response select 0) == 1 && typeName(_response select 1) == "ARRAY") then{
    _arr = _response select 1; 
    // do something with data in array here
};

 
Get Boolean
Index: 
0 = Key Name Prefix
1 = Key Name Unique ID

2 = Numeric index
 
Returns: Boolean (true/false)

_player = this; // ref to player
_prefix = "VEMF_STATS";
_uniqueId = getPlayerUID _player;
_response = [_prefix, _uniqueId, 0] call EPOCH_server_hiveGETBIT;

if (_response) then {
   // do something if true 
} else {
   // do something if false
};

Please ask if you have any questions and I will update this for better clarity.

Link to comment
Share on other sites

Hey, where abouts does this save the data to in the Redis DB, in the player stats section?

The examples store the data in the database with there own key namespace. You should not try to save custom data into our key namespaces as it will break the existing data and cause compatibility issues with updates. Also using your own key namespace guarantees your data will not be effected by changes we make.

Link to comment
Share on other sites

The examples store the data in the database with there own key namespace. You should not try to save custom data into our key namespaces as it will break the existing data and cause compatibility issues with updates. Also using your own key namespace guarantees your data will not be effected by changes we make.

Sounds good, will have to mess around a little. Cheers

Link to comment
Share on other sites

Agreed! This is impressive!

 

Hmmm how to use this functionality to keep vehicles locked over a reboot... it must be possible, surely!?

 

You would need to write a serverside script that saves the vehicles information, and locked state. Then after a restart it would need to run a script that would find the correct vehicles again after the server spawns them in and set their locked status over again.

 

I'd rather see Epoch incorporate a timeout into the preexisting code that remembers the lock time past a restart, but still times it out.

Link to comment
Share on other sites

Same, integrated into EPOCH would be best - I think VBAWOL mentioned something coming soon like this.

 

 

You would need to write a serverside script that saves the vehicles information, and locked state. Then after a restart it would need to run a script that would find the correct vehicles again after the server spawns them in and set their locked status over again.

 

I'd rather see Epoch incorporate a timeout into the preexisting code that remembers the lock time past a restart, but still times it out.

Link to comment
Share on other sites

I was hoping someone would ask this so I will go ahead and document some calls. Our database is schema-less this means that there are no columns or rows just keys and values. The best way to use the Epoch database for your own custom calls is to use your own key namespace. This would be similar to the TAG_*  or EPOCH_ practice Arma script makers use.

 

Save data with expiry in seconds (best way to prevent bloating db)

Index: 

0 = Key Name Prefix

1 = Key Name Unique ID

2 = Expire time in seconds (auto cleanup)

3 = Data can be a string or an array

_player = this; // ref to player
_prefix = "VEMF_DATA";
_uniqueId = getPlayerUID _player;
_expires = "2592000"; // 30 days
_data = ["your", "custom", "data", "goes", "here"]; // this can be an array or string
[_prefix, _uniqueId, _expires, _data] call EPOCH_server_hiveSETEX;

Save data

Index: 

0 = Key Name Prefix

1 = Key Name Unique ID

2 = Data can be a string or an array

_plyr = this; // ref to player
_prefix = "VEMF_DATA";
_uniqueId = getPlayerUID _plyr;
_data = ["your", "custom", "data", "goes", "here"]; // this can be an array or string
[_prefix, _uniqueId, _data] call EPOCH_server_hiveSET;

Save Boolean

Index: 

0 = Key Name Prefix

1 = Key Name Unique ID

2 = Numeric index

3 = Boolean 

_player = this; // ref to player
_prefix = "VEMF_STATS";
_uniqueId = getPlayerUID _player;
_val = 1; // 1 = true, 0 = false 
[_prefix, _uniqueId, 0, 1] call EPOCH_server_hiveSETBIT;

Get data

Index: 

0 = Key Name Prefix

1 = Key Name Unique ID

 

Returns: Array

_player = this; // ref to player
_prefix = "VEMF_DATA";
_uniqueId = getPlayerUID _player;

_response = [_prefix, _uniqueId] call EPOCH_server_hiveGET;
_arr = [];
 
if ((_response select 0) == 1 && typeName(_response select 1) == "ARRAY") then{
    _arr = _response select 1; 
    // do something with data in array here
};

 

Get Boolean

Index: 

0 = Key Name Prefix

1 = Key Name Unique ID

 

Returns: Boolean (true/false)

_player = this; // ref to player
_prefix = "VEMF_STATS";
_uniqueId = getPlayerUID _player;
_response = [_prefix, _uniqueId] call EPOCH_server_hiveGETBIT;

if (_response) then {
   // do something if true 
} else {
   // do something if false
};

Please ask if you have any questions and I will update this for better clarity.

 

I feel good right now!

Link to comment
Share on other sites

soooo if i wanted to make something as simple as when a player connects to the server save his name, and uID to the database... my script would be like this?

_plyr = this;
_prefix = "Player_Info";
_uniqueId = getPlayerUID _plyr;
_pName = name player;
_data = [["_pName"], ["_uniqueId"]]; <--- idk??
[_prefix, _uniqueId, _data] call EPOCH_server_hiveSET;
Link to comment
Share on other sites

  • 3 months later...
  • 4 months later...

Hey, with the addition of epoch_server_core.pbo, does the above still apply or would we use something like fn_server_hiveGET?

Would you use it like this to retrieve the information for a player?

playerInfo = ["Player","<playeridgoeshere>"] call fn_server_hiveGET;

Also, if you have to specify the instance would you do it like this?

vehicleInfo = ["Vehicle:<instancegoeshere>","<vehicleidgoeshere>"] call fn_server_hiveGET;

Thanks

 

Link to comment
Share on other sites

  • 7 months later...
On 1/21/2015 at 5:57 PM, vbawol said:

I was hoping someone would ask this so I will go ahead and document some calls. Our database is schema-less this means that there are no columns or rows just keys and values. The best way to use the Epoch database for your own custom calls is to use your own key namespace. This would be similar to the TAG_*  or EPOCH_ practice Arma script makers use.
 
Save data with expiry in seconds (best way to prevent bloating db)
Index: 
0 = Key Name Prefix
1 = Key Name Unique ID
2 = Expire time in seconds (auto cleanup)
3 = Data can be a string or an array


_player = this; // ref to player
_prefix = "VEMF_DATA";
_uniqueId = getPlayerUID _player;
_expires = "2592000"; // 30 days
_data = ["your", "custom", "data", "goes", "here"]; // this can be an array or string
[_prefix, _uniqueId, _expires, _data] call EPOCH_server_hiveSETEX;

Save data
Index: 
0 = Key Name Prefix
1 = Key Name Unique ID
2 = Data can be a string or an array

 

 

 


_plyr = this; // ref to player
_prefix = "VEMF_DATA";
_uniqueId = getPlayerUID _plyr;
_data = ["your", "custom", "data", "goes", "here"]; // this can be an array or string
[_prefix, _uniqueId, _data] call EPOCH_server_hiveSET;

Save Boolean
Index: 
0 = Key Name Prefix
1 = Key Name Unique ID
2 = Numeric index
3 = Boolean 

 

 

 


_player = this; // ref to player
_prefix = "VEMF_STATS";
_uniqueId = getPlayerUID _player;
_val = 1; // 1 = true, 0 = false 
[_prefix, _uniqueId, 0, 1] call EPOCH_server_hiveSETBIT;

Get data
Index: 
0 = Key Name Prefix
1 = Key Name Unique ID
 
Returns: Array

 

 

 


_player = this; // ref to player
_prefix = "VEMF_DATA";
_uniqueId = getPlayerUID _player;

_response = [_prefix, _uniqueId] call EPOCH_server_hiveGET;
_arr = [];
 
if ((_response select 0) == 1 && typeName(_response select 1) == "ARRAY") then{
    _arr = _response select 1; 
    // do something with data in array here
};

 
Get Boolean
Index: 
0 = Key Name Prefix
1 = Key Name Unique ID

2 = Numeric index
 
Returns: Boolean (true/false)


_player = this; // ref to player
_prefix = "VEMF_STATS";
_uniqueId = getPlayerUID _player;
_response = [_prefix, _uniqueId, 0] call EPOCH_server_hiveGETBIT;

if (_response) then {
   // do something if true 
} else {
   // do something if false
};

Please ask if you have any questions and I will update this for better clarity.

I have been testing this and can't seem to make it work: whatever value I try to SET/SETEX, when I try to GET it, I receive no response (blank array).
These functions being very basic not returning any error codes either.
Are there any other real & very basic examples to test?

Example: store "age" for any PUID and then receive it from the server and write to server log (to test)?

Link to comment
Share on other sites

Store with:

Spoiler

_playeruid = getplayeruid _player;
_storedvalue = 1000;
_return = ["He_Man_Vars", _playeruid, "7776000", [_storedvalue]] call EPOCH_fnc_server_hiveSETEX;

Load with

Spoiler

_playeruid = getplayeruid _player;                
_responce = ["He_Man_Vars", _playeruid] call EPOCH_fnc_server_hiveGETRANGE;
if (count (_responce select 1) > 0) then {
    _storedvalue = _responce select 1 select 0;
};

 

Link to comment
Share on other sites

Just now, He-Man said:

Store with:

  Hide contents

_playeruid = getplayeruid _player;
_storedvalue = 1000;
_return = ["He_Man_Vars", _playeruid, "7776000", [_storedvalue]] call EPOCH_fnc_server_hiveSETEX;

Load with

  Hide contents

_playeruid = getplayeruid _player;                
_responce = ["He_Man_Vars", _playeruid] call EPOCH_fnc_server_hiveGETRANGE;
if (count (_responce select 1) > 0) then {
    _storedvalue = _responce select 1 select 0;
};

 

Thank you for a quick response He-Man, I will try this right away.

 

BTW I was your biggest fan when I was 7!

Link to comment
Share on other sites

25 minutes ago, He-Man said:

Store with:

  Reveal hidden contents

_playeruid = getplayeruid _player;
_storedvalue = 1000;
_return = ["He_Man_Vars", _playeruid, "7776000", [_storedvalue]] call EPOCH_fnc_server_hiveSETEX;

Load with

  Reveal hidden contents

_playeruid = getplayeruid _player;                
_responce = ["He_Man_Vars", _playeruid] call EPOCH_fnc_server_hiveGETRANGE;
if (count (_responce select 1) > 0) then {
    _storedvalue = _responce select 1 select 0;
};

 

Tested this & it is working fine - thanks a lot!

 

There are a couple syntax differences, one of them apparently "broke" my commands. I will play with this some more later, persistent data storage opens a big world to scripters. thanks Obama, vbawol and he-man!

Link to comment
Share on other sites

Glad to see people looking a bit deeper! In case you have not seen it, the github link below is for the Epoch Server Framework and has all of the documentation on calls and functions in one place.

Raw extension calls:
https://github.com/EpochModTeam/EpochServer

Sqf DB helper functions:
https://github.com/EpochModTeam/EpochServer/tree/master/sqf/epoch_server_core

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...