Version 3.1.0 How t...
 
Notifications
Clear all

Version 3.1.0 How to create a weekly event system?

10 Posts
2 Users
2 Reactions
949 Views
(@danilletov)
Posts: 13
Eminent Member
Topic starter
 

Hello! I have Version 3.1.0

I want to implement a weekly event system, how can I do that? Examples would be very helpful.
Can someone already created it, would be grateful for the help.

You wrote that the opportunity was:
"-Added a new sample script in /extra folder which deletes the Session Tokens older than 7 days (configurable in a variable), you can use this in a scheduled job on your server OS to be executed once per week for example"

This topic was modified 6 years ago 2 times by DanilLetov
 
Posted : 08/10/2018 2:15 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

What do you mean by "weekly event system"? What are exactly your needs?

The quote that you highlighted is just only an example of how you can write a PHP script that deletes the session tokens to keep the table SessionToken clean.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 08/10/2018 6:32 pm
(@danilletov)
Posts: 13
Eminent Member
Topic starter
 

Every week I want to create a new event for the players. I would like to store its parameters in the database queue of these events. and every Monday to load from the queue a new event to load for all clients.
I was hoping that there was already some standard solution for this.

 
Posted : 10/10/2018 7:39 am
(@danilletov)
Posts: 13
Eminent Member
Topic starter
 

If there was a place for global settings of the game, available to each client, then I could use it. I would put a queue of events in it. And made the synchronization with server time.
Is there no allocated space for global game settings available in the admin panel?

 
Posted : 10/10/2018 7:43 am
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

May be you could make use of Server Settings in admin, those are global settings for all registered apps in Combu:

  • create a new setting with a specific name (i.e.: MyAppEvents)
  • use a JSON creator tool to generate a JSON string to represent an array of objects with your event's data (i.e. on  https://jsoneditoronline.org in the right panel click NEW, set the type of the root object as Array by clicking the icon at left of the first node and add all your events and data as Object nodes with String properties, when you've finished to create the array just click the button with a right-to-left icon in the middle of screen and make sure to have selected the second icon at top-left corner of the left panel [the icon that usually means "align to left" in document editors] so that the output JSON text is compressed in a single line string)
  • assign the JSON representation string as value of the new setting
  • in Unity you can access the server settings after initialization through CombuManager.instance.serverInfo.settings

If you follow these steps you could decode the JSON of this Setting as an ArrayList of Hashtable:

ArrayList eventsData = CombuManager.instance.serverInfo.settings["MyAppEvents"].ToString().arrayListFromJson();
foreach (Hashtable eventData in eventsData)
{
    // string myProp1 = eventData["myProp1"].ToString();
}

If you need more micro-management or need to store more data (for example if you don't want to use User's appCustomData to store user account values associated to events) then you'll better have to create a custom add-on (I'm also available for small jobs like the creation of custom add-ons for Combu).

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 10/10/2018 12:30 pm
DanilLetov reacted
(@danilletov)
Posts: 13
Eminent Member
Topic starter
 

Thank you very much for your help I will try to use your advice. In a couple of days I will try to implement what you have proposed.

 
Posted : 10/10/2018 2:37 pm
(@danilletov)
Posts: 13
Eminent Member
Topic starter
 

Hello, I'm trying to implement what you have proposed. But I can not get the values created on the server settings.

 
Posted : 18/10/2018 6:10 pm
(@danilletov)
Posts: 13
Eminent Member
Topic starter
 

screen from admin

 
Posted : 18/10/2018 6:13 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

As far as I see in your first screenshot it seems that you have the issue that I fixed in my local environment regarding what's returned by the server info webservice, may be I fixed it after 3.1.0 (I'm going to send 3.1.1 very soon, hopefully by this Sunday).

To port the fix to your server (until I'll release 3.1.1) check if the method GetCurrentSettings in /vendor/skaredcreations/combu/combu/ServerSettings.php is like this:

public static function GetCurrentSettings(&$serverClientKeys) {
    $serverClientKeys = array();
    $settings = array();
    $recs = self::Load();
    foreach ($recs as $rec) {
        $settings[$rec->DataKey] = $rec->DataValue;
        if ($rec->Visible) {
            $serverClientKeys[$rec->DataKey] = $rec->DataValue;
        }
    }
    return $settings;
}

and the function wsInfo in /server.php is like this:

function wsInfo() {
    global $ServerClientSettings, $WS_VERSION;
    $version = array(
        "version" => COMBU_VERSION,
        "requireUpdate" => isHigherVersion($WS_VERSION, defined("MIN_CLIENT_VERSION") ? MIN_CLIENT_VERSION : ""),
        "time" => date("Y-m-d H:i:s"),
        "settings" => json_encode($ServerClientSettings),
        "responseEncrypted" => Utils::ServerResponseRequired()
    );
    Utils::EchoJson($version, TRUE);
}

I've tested the following code in Unity in my local dev server:

var test1 = CombuManager.instance.serverInfo.settings["Test1"];
Debug.Log("test1: " + test1.GetType().Name + " > " + test1);

var test2 = CombuManager.instance.serverInfo.settings["Test2"].ToString().arrayListFromJson();
string str2 = "";
foreach (var s in test2)
{
    str2 += (str2 == "" ? "" : ", ") + s;
}
Debug.Log("test2: " + str2);

var test3 = CombuManager.instance.serverInfo.settings["Test3"].ToString().hashtableFromJson();
string str3 = "";
var data3 = (ArrayList)test3["zz"];
foreach (var s in data3)
{
    str3 += (str3 == "" ? "" : ", ") + s;
}
Debug.Log("test3: " + str3);

and the log in Console was:

test1: String > 123
test2: 1, 2
test3: 1, 2

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 18/10/2018 7:42 pm
DanilLetov reacted
(@danilletov)
Posts: 13
Eminent Member
Topic starter
 

Very good, it's working.
Thanks for help! 

 
Posted : 19/10/2018 2:42 pm
Share: