Taviana 2.0 Looping Database Messages Tutorial

Will695

Member
So here's another think that I found not to be working on my Taviana server, Database loop messaging. I had a play around and found that this works, now as I've been writing (just come back to the top to say) this I've just noticed that it's on dayz.st after skimming it, it's mostly the same but I thought I'd write one anyway from my files as I got the info from a different source (forgot where just comparing old files with the new ones)

Anyway here's how I did it. You'll just need to edit three files server_cleanup, server_monitor in the server.pbo and the init in the mission

We'll start with Init.

You need to comment out the enable radio false line in the init so find
Code:
enableRadio false;

and change it to

Code:
//enableRadio false;

and that's it for the init.sqf

next is the server_cleanup

Find this part
Code:
    /*%FSM</STATE>*/
    /*%FSM<STATE "waiting">*/
    class waiting
    {
      name = "waiting";
      init = /*%FSM<STATEINIT""">*/"//diag_log ""CLEANUP: Waiting for next task"";" \n
      ""/*%FSM</STATEINIT""">*/;


Where now going to stick some code in the middle of it so

right after this line

Code:
init = /*%FSM<STATEINIT""">*/"//diag_log ""CLEANUP: Waiting for next task"";" \n

put this code

Code:
      "private [""_payload"", ""_interval"",""_delay""];" \n
      "{" \n
      "    _payload = _x select 0;" \n
      "    _interval = _x select 1;" \n
      "    _delay = _x select 2;" \n
      "    if (time - _delay > _interval && _interval != -1) then {" \n
      "        [nil, nil, rSPAWN, [_crier, _payload], { (_this select 0) globalChat (_this select 1) }] call RE;" \n
      "        if (_interval == 0) then {" \n
      "            _msgList set [_forEachIndex, [_payload, -1, time]];" \n
      "        } else {" \n
      "            _msgList set [_forEachIndex, [_payload, _interval, time]];" \n
      "        };" \n
      "    };" \n
now right after that we need to change this line
Code:
""/*%FSM</STATEINIT""">*/;
to this
Code:
"} forEach _msgList;"/*%FSM</STATEINIT""">*/;

so if right the whole thing should look like this

Code:
    /*%FSM</STATE>*/
    /*%FSM<STATE "waiting">*/
    class waiting
    {
      name = "waiting";
      init = /*%FSM<STATEINIT""">*/"//diag_log ""CLEANUP: Waiting for next task"";" \n
      "private [""_payload"", ""_interval"",""_delay""];" \n
      "{" \n
      "    _payload = _x select 0;" \n
      "    _interval = _x select 1;" \n
      "    _delay = _x select 2;" \n
      "    if (time - _delay > _interval && _interval != -1) then {" \n
      "        [nil, nil, rSPAWN, [_crier, _payload], { (_this select 0) globalChat (_this select 1) }] call RE;" \n
      "        if (_interval == 0) then {" \n
      "            _msgList set [_forEachIndex, [_payload, -1, time]];" \n
      "        } else {" \n
      "            _msgList set [_forEachIndex, [_payload, _interval, time]];" \n
      "        };" \n
      "    };" \n
      "} forEach _msgList;"/*%FSM</STATEINIT""">*/;

ok now that's done we need to go down near the bottom of the file and find this bit of code

Code:
    /*%FSM</STATE>*/
    /*%FSM<STATE "prepare">*/
    class prepare
    {
      name = "prepare";
      init = /*%FSM<STATEINIT""">*/"private [""_safety"", ""_lastSyncTime"", ""_lastCleanDead"", ""_lastCleanObjs"", ""_lastUpdateVeh""];" \n
      "diag_log (""CLEANUP: INITIALIZING CLEANUP SCRIPT"");" \n
      "" \n
      "_safety = dayz_serverObjectMonitor;" \n
      "" \n
      "_lastSyncTime = time;" \n
      "_lastCleanDead = time;" \n
      "_lastCleanObjs = time;" \n
      "_lastUpdateVeh = time;"/*%FSM</STATEINIT""">*/;

And as before we're going to put some code in the midde so

right after this line

Code:
"_safety = dayz_serverObjectMonitor;" \n

put this

Code:
      "_msgList = msgList;" \n
      "_crierGrp = createGroup sideLogic;" \n
      "_crier = _crierGrp createUnit [""Survivor2_DZ"", [-2500, 0, 0], [], 0, ""NONE""];" \n

so if we've done it right it should look like this

Code:
    /*%FSM</STATE>*/
    /*%FSM<STATE "prepare">*/
    class prepare
    {
      name = "prepare";
      init = /*%FSM<STATEINIT""">*/"private [""_safety"", ""_msgList"", ""_crier"", ""_lastSyncTime"", ""_lastCleanDead"", ""_lastCleanObjs"", ""_lastUpdateVeh""];" \n
      "diag_log (""CLEANUP: INITIALIZING CLEANUP SCRIPT"");" \n
      "" \n
      "_safety = dayz_serverObjectMonitor;" \n
      "_msgList = msgList;" \n
      "_crierGrp = createGroup sideLogic;" \n
      "_crier = _crierGrp createUnit [""Survivor2_DZ"", [-2500, 0, 0], [], 0, ""NONE""];" \n
      "" \n
      "_lastSyncTime = time;" \n
      "_lastCleanDead = time;" \n
      "_lastCleanObjs = time;" \n
      "_lastUpdateVeh = time;"/*%FSM</STATEINIT""">*/;

Ok that's that for the server_cleanup

Now for the server_monitor.sqf

find this bit of code

Code:
waitUntil{initialized};
 
_key = format["CHILD:302:%1:", dayZ_instance];
_data = "HiveEXT" callExtension _key;

Once again putting some code in the middle

So after this line
Code:
waitUntil{initialized};

put this
Code:
_key = format["CHILD:999:select payload, loop_interval, start_delay from message where instance_id = ?:[%1]:", dayZ_instance];
_data = "HiveEXT" callExtension _key;
 
diag_log("SERVER: Fetching messages...");
 
//Process result
_result = call compile format ["%1", _data];
_status = _result select 0;
 
msgList = [];
_msgCount = 0;
if (_status == "CustomStreamStart") then {
    _val = _result select 1;
    for "_i" from 1 to _val do {
        _data = "HiveEXT" callExtension _key;
        _result = call compile format ["%1",_data];
 
        _status = _result select 0;
        msgList set [count msgList, _result];
        _msgCount = _msgCount + 1;
    };
    diag_log ("SERVER: Added " + str(_msgCount) + " messages!");
};

The whole thing should look like this, note that I've got some "\\Send the key" comments in but probably don't need it as they're only comments

Code:
waitUntil{initialized};
 
//Send the key
_key = format["CHILD:999:select payload, loop_interval, start_delay from message where instance_id = ?:[%1]:", dayZ_instance];
_data = "HiveEXT" callExtension _key;
 
diag_log("SERVER: Fetching messages...");
 
//Process result
_result = call compile format ["%1", _data];
_status = _result select 0;
 
msgList = [];
_msgCount = 0;
if (_status == "CustomStreamStart") then {
    _val = _result select 1;
    for "_i" from 1 to _val do {
        _data = "HiveEXT" callExtension _key;
        _result = call compile format ["%1",_data];
 
        _status = _result select 0;
        msgList set [count msgList, _result];
        _msgCount = _msgCount + 1;
    };
    diag_log ("SERVER: Added " + str(_msgCount) + " messages!");
};
 
//Send the key
_key = format["CHILD:302:%1:", dayZ_instance];
_data = "HiveEXT" callExtension _key;

And that's it! Put the files back in the server.pbo and upload

To make a message in the database

Open the MESSAGES table
Click INSERT tab at top
ID - This is sequential, start with the number 1
PAYLOAD - the actual message you want displayed
LOOP_INTERVAL - how many SECONDS before this message displays again
START_DELAY - how many SECONDS before this message starts the first display
INSTANCE_ID - select your instance ID, do NOT leave it null

Again don't take credit for this as I got it somewhere else that I can't remember.
 
Awesome and thank you! Ill check it out as soon as I get home! Will this make the php messages work or are we entering the messages directly in? I can't see the code atm.
 
Help and Discussion for Taviana 2.0 looped database messages start here...

Awesome and thank you! Ill check it out as soon as I get home! Will this make the php messages work or are we entering the messages directly in? I can't see the code atm.

This is for the php messaging, though the messaging table in the database. No need to code it in the pbo's :D
 
Ok, all of my servercleanup was already exactly the same as what you posted. My server_monitor was missing the code tho. Now it looks like this:
Code:
_key = format["CHILD:302:%1:", dayZ_instance];
_data = "HiveEXT" callExtension _key;
_key = format["CHILD:999:select payload, loop_interval, start_delay from message where instance_id = ?:[%1]:", dayZ_instance];
_data = "HiveEXT" callExtension _key;
 
diag_log("SERVER: Fetching messages...");
 
//Process result
_result = call compile format ["%1", _data];
_status = _result select 0;
 
msgList = [];
_msgCount = 0;
if (_status == "CustomStreamStart") then {
    _val = _result select 1;
    for "_i" from 1 to _val do {
        _data = "HiveEXT" callExtension _key;
        _result = call compile format ["%1",_data];
 
        _status = _result select 0;
        msgList set [count msgList, _result];
        _msgCount = _msgCount + 1;
    };
    diag_log ("SERVER: Added " + str(_msgCount) + " messages!");
};
 
diag_log("SERVER: Fetching objects...");
 
//Process result
_result = call compile format ["%1", _data];
_status = _result select 0;

My only concern is that with base building 2.0 I do recall having to delete some of this code. Im not 100% sure and havnt tested yet(bout to now) but ill let ya know.
 
ok I may have a solution for you in the server monitor your only adding the msglist bit the bit before it maybe different for you as ive just skimmed the base building bit anf u need to change the _key=format stuff at the top. you should try to merge it and not delete anything or overwrite. at work at the min I'll have a look when I get home
 
Let me know if you need more than this. Thanks!

Code:
[]execVM "\z\addons\dayz_server\system\s_fps.sqf";
 
dayz_versionNo = getText(configFile >> "CfgMods" >> "DayZ" >> "version");
dayz_hiveVersionNo = getNumber(configFile >> "CfgMods" >> "DayZ" >> "hiveVersion");
diag_log("SERVER VERSION: Bliss v4.2");
 
if ((count playableUnits == 0) and !isDedicated) then {
    isSinglePlayer = true;
};
 
waitUntil{initialized};
 
//Send the key
_key = format["CHILD:302:%1:", dayZ_instance];
_data = "HiveEXT" callExtension _key;
_key = format["CHILD:999:select payload, loop_interval, start_delay from message where instance_id = ?:[%1]:", dayZ_instance];
_data = "HiveEXT" callExtension _key;
 
diag_log("SERVER: Fetching messages...");
 
//Process result
_result = call compile format ["%1", _data];
_status = _result select 0;
 
msgList = [];
_msgCount = 0;
if (_status == "CustomStreamStart") then {
    _val = _result select 1;
    for "_i" from 1 to _val do {
        _data = "HiveEXT" callExtension _key;
        _result = call compile format ["%1",_data];
 
        _status = _result select 0;
        msgList set [count msgList, _result];
        _msgCount = _msgCount + 1;
    };
    diag_log ("SERVER: Added " + str(_msgCount) + " messages!");
};
 
diag_log("SERVER: Fetching objects...");
 
//Process result
_result = call compile format ["%1", _data];
_status = _result select 0;
 
_objList = [];
_objCount = 0;
if (_status == "ObjectStreamStart") then {
    _val = _result select 1;
    for "_i" from 1 to _val do {
        _data = "HiveEXT" callExtension _key;
        _result = call compile format ["%1",_data];
 
        _status = _result select 0;
        _objList set [count _objList, _result];
        _objCount = _objCount + 1;
    };
    diag_log ("SERVER: Fetched " + str(_objCount) + " objects!");
};
 
//Spawn objects
_countr = 0;
{
    //Parse individual vehicle row
    _countr = _countr + 1;
 
    _idKey =    _x select 1;
    _type =        _x select 2;
    _ownerID =    _x select 3;
 
    _worldspace = _x select 4;
    _dir = 0;
    _pos = [0,0,0];
    _wsDone = false;
    if (count _worldspace >= 2) then
    {
        _dir = _worldspace select 0;
        if (count (_worldspace select 1) == 3) then {
            _pos = _worldspace select 1;
            _wsDone = true;
        }
    };

this is the one I modified as you instructed. Next ill post the working one.
 
Working one:

Code:
[]execVM "\z\addons\dayz_server\system\s_fps.sqf";
 
dayz_versionNo = getText(configFile >> "CfgMods" >> "DayZ" >> "version");
dayz_hiveVersionNo = getNumber(configFile >> "CfgMods" >> "DayZ" >> "hiveVersion");
diag_log("SERVER VERSION: Bliss v4.2");
 
if ((count playableUnits == 0) and !isDedicated) then {
    isSinglePlayer = true;
};
 
waitUntil{initialized};
 
//Send the key
_key = format["CHILD:302:%1:", dayZ_instance];
_data = "HiveEXT" callExtension _key;
 
diag_log("SERVER: Fetching objects...");
 
//Process result
_result = call compile format ["%1", _data];
_status = _result select 0;
 
_objList = [];
_objCount = 0;
if (_status == "ObjectStreamStart") then {
    _val = _result select 1;
    for "_i" from 1 to _val do {
        _data = "HiveEXT" callExtension _key;
        _result = call compile format ["%1",_data];
 
        _status = _result select 0;
        _objList set [count _objList, _result];
        _objCount = _objCount + 1;
    };
    diag_log ("SERVER: Fetched " + str(_objCount) + " objects!");
};
 
//Spawn objects
_countr = 0;
{
    //Parse individual vehicle row
    _countr = _countr + 1;
 
    _idKey =    _x select 1;
    _type =        _x select 2;
    _ownerID =    _x select 3;
 
    _worldspace = _x select 4;
    _dir = 0;
    _pos = [0,0,0];
    _wsDone = false;
    if (count _worldspace >= 2) then
    {
        _dir = _worldspace select 0;
        if (count (_worldspace select 1) == 3) then {
            _pos = _worldspace select 1;
            _wsDone = true;
        }
    };         
    if (!_wsDone) then {
        if (count _worldspace >= 1) then { _dir = _worldspace select 0; };
        _pos = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
        if (count _pos < 3) then { _pos = [_pos select 0,_pos select 1,0]; };
        diag_log ("MOVED OBJ: " + str(_idKey) + " of class " + _type + " to pos: " + str(_pos));
    };

Obviously neither is the full code. Its not allowing me to attach the file and only allows 1000 characters so Ive only posted up the first half of each.
 
ok think i found you're issue you doubled some stuff try this,

Code:
[]execVM "\z\addons\dayz_server\system\s_fps.sqf";
 
dayz_versionNo = getText(configFile >> "CfgMods" >> "DayZ" >> "version");
dayz_hiveVersionNo = getNumber(configFile >> "CfgMods" >> "DayZ" >> "hiveVersion");
diag_log("SERVER VERSION: Bliss v4.2");
 
if ((count playableUnits == 0) and !isDedicated) then {
    isSinglePlayer = true;
};
 
waitUntil{initialized};
 
//Send the key
_key = format["CHILD:999:select payload, loop_interval, start_delay from message where instance_id = ?:[%1]:", dayZ_instance];
_data = "HiveEXT" callExtension _key;
 
diag_log("SERVER: Fetching messages...");
 
//Process result
_result = call compile format ["%1", _data];
_status = _result select 0;
 
msgList = [];
_msgCount = 0;
if (_status == "CustomStreamStart") then {
    _val = _result select 1;
    for "_i" from 1 to _val do {
        _data = "HiveEXT" callExtension _key;
        _result = call compile format ["%1",_data];
 
        _status = _result select 0;
        msgList set [count msgList, _result];
        _msgCount = _msgCount + 1;
    };
    diag_log ("SERVER: Added " + str(_msgCount) + " messages!");
};
 
//Send the key
_key = format["CHILD:302:%1:", dayZ_instance];
_data = "HiveEXT" callExtension _key;
 
diag_log("SERVER: Fetching objects...");
 
//Process result
_result = call compile format ["%1", _data];
_status = _result select 0;
 
_objList = [];
_objCount = 0;
if (_status == "ObjectStreamStart") then {
    _val = _result select 1;
    for "_i" from 1 to _val do {
        _data = "HiveEXT" callExtension _key;
        _result = call compile format ["%1",_data];
 
        _status = _result select 0;
        _objList set [count _objList, _result];
        _objCount = _objCount + 1;
    };
    diag_log ("SERVER: Fetched " + str(_objCount) + " objects!");
};
 
//Spawn objects
_countr = 0;
{
    //Parse individual vehicle row
    _countr = _countr + 1;
 
    _idKey =    _x select 1;
    _type =        _x select 2;
    _ownerID =    _x select 3;
 
    _worldspace = _x select 4;
    _dir = 0;
    _pos = [0,0,0];
    _wsDone = false;
    if (count _worldspace >= 2) then
    {
        _dir = _worldspace select 0;
        if (count (_worldspace select 1) == 3) then {
            _pos = _worldspace select 1;
            _wsDone = true;
        }
    };       
    if (!_wsDone) then {
        if (count _worldspace >= 1) then { _dir = _worldspace select 0; };
        _pos = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
        if (count _pos < 3) then { _pos = [_pos select 0,_pos select 1,0]; };
        diag_log ("MOVED OBJ: " + str(_idKey) + " of class " + _type + " to pos: " + str(_pos));
    };

i've just taken your working one above and added what's needed, should work if not then it's the basebuilding that's at fault as you said.
 
you had
Code:
_key = format["CHILD:302:%1:", dayZ_instance];
_data = "HiveEXT" callExtension _key;
_key = format["CHILD:999:select payload, loop_interval, start_delay from message where instance_id = ?:[%1]:", dayZ_instance];
_data = "HiveEXT" callExtension _key;

which wasn't supposed to be there anyway i hope the above works.
 
I inboxed you about it. I have this fix in my server now and BB seems to work fine but I havnt yet seen any messages. I have them set for 15min cycles so they may have just not come up yet. Thanks for all your help and ill update ya soonest
 
hi. ive followed the instructions above to the letter and I have no errors. everything in the database is as it should be but im not getting any messages show up in my server. Is there anything else that I need to do?

Open the MESSAGES table - DONE.
Click INSERT tab at top - DONE.
ID - This is sequential, start with the number 1 - DONE.
PAYLOAD - the actual message you want displayed - DONE.
LOOP_INTERVAL - how many SECONDS before this message displays again - DONE.
START_DELAY - how many SECONDS before this message starts the first display - DID THIS BUT ON ANOTHER SITE IT STATES THAT IT IS MINUTES NOT SECONDS.
INSTANCE_ID - select your instance ID, do NOT leave it null - DONE.

Im running a dayz.st server with Taviana.

many thx

termy
 
hi. ive followed the instructions above to the letter and I have no errors. everything in the database is as it should be but im not getting any messages show up in my server. Is there anything else that I need to do?

Open the MESSAGES table - DONE.
Click INSERT tab at top - DONE.
ID - This is sequential, start with the number 1 - DONE.
PAYLOAD - the actual message you want displayed - DONE.
LOOP_INTERVAL - how many SECONDS before this message displays again - DONE.
START_DELAY - how many SECONDS before this message starts the first display - DID THIS BUT ON ANOTHER SITE IT STATES THAT IT IS MINUTES NOT SECONDS.
INSTANCE_ID - select your instance ID, do NOT leave it null - DONE.

Im running a dayz.st server with Taviana.

many thx

termy


Yeah there was one thing, make sure you have commented out enable radio

so it looks like
//enableRadio false;

in your init.sqf file in the mission

(I've edited the main tutorial to state that)
 
But the last is in seconds if I recall correctly. Im running dayz.st Tavi 2.0 and they scroll as set to do.
 
Yeah there was one thing, make sure you have commented out enable radio

so it looks like
//enableRadio false;

in your init.sqf file in the mission

(I've edited the main tutorial to state that)

Ok many thx for that. i think i did it but ill double check.

EDIT:
I have looked and i had already done that. still not working.
 
Back
Top