Help with a few Mods/Scripts

Nelriana

New Member
Hello All!

I am currently hosting a DayZ.st server and it is working well. There are a few things I would like to add to the server before I finish editing it regularly.

Anti-combat logging. The disco-bot script I found didn't create bots on combat log. It created them whenever someone logged off and it stayed there, and the person could log back in with their gear both on the dead bot and on themselves. (Need a link to a working script if there is one available atm)

AI Patrols: Haven't looked into this much, my hopes are to get something that will have 3 types, soldiers, bandits, and survivors. I have seen a few that do this, do not know much more than that because I have yet to look into it.

**PRIORITY**Looped Global Messages: Mainly want to enable this so that I can help redirect people to the facebook page to help build the community, or report hackers. I looked into the http://sponsored.dayz.st/wiki/index.php?title=Loop_Messages_from_DB, the lines of code I was supposed to change was not what the articles said they should be (original). They looked closer to what they were supposed to be after the fix, but wrong in a few places.

Next post shall contain are the code for each file (Cleanup, and monitor)

Note: monitor has the entire code, cleanup is the problem child as far as I can tell and it has the specific sections of code (as far as I could tell since it was not similar to the tutorial at all)

Any help on how to get the looped global messages to work would be great! I tried editing code in what I assume to be the correct spots but the messages did not show up (added into the database in bliss correctly)
  • Connect to the DB using the control panel
  • 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
 

Attachments

  • server_monitor.sqf
    8.3 KB · Views: 1
Monitor
[]execVM "\z\addons\dayz_server\system\s_fps.sqf"; //server monitor FPS (writes each ~181s diag_fps+181s diag_fpsmin*)

dayz_versionNo = getText(configFile >> "CfgMods" >> "DayZ" >> "version");
dayz_hiveVersionNo = getNumber(configFile >> "CfgMods" >> "DayZ" >> "hiveVersion");
_script = getText(missionConfigFile >> "onPauseScript");

if ((count playableUnits == 0) and !isDedicated) then {
isSinglePlayer = true;
};

waitUntil{initialized}; //means all the functions are now defined

diag_log "HIVE: Starting";

if (_script != "") then
{
diag_log "MISSION: File Updated";
} else {
while {true} do
{
diag_log "MISSION: File Needs Updating";
sleep 1;
};
};

//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!");
};

//Stream in objects
/* STREAM OBJECTS */
//Send the key
_key = format["CHILD:302:%1:",dayZ_instance];
_result = _key call server_hiveReadWrite;

diag_log "HIVE: Request sent";

//Process result
_status = _result select 0;

_myArray = [];
if (_status == "ObjectStreamStart") then {
_val = _result select 1;
//Stream Objects
diag_log ("HIVE: Commence Object Streaming...");
for "_i" from 1 to _val do {
_result = _key call server_hiveReadWrite;

_status = _result select 0;
_myArray set [count _myArray,_result];
//diag_log ("HIVE: Loop ");
};
//diag_log ("HIVE: Streamed " + str(_val) + " objects");
};

_countr = 0;
{

//Parse Array
_countr = _countr + 1;

_idKey = _x select 1;
_type =_x select 2;
_ownerID = _x select 3;
_worldspace = _x select 4;
_intentory=_x select 5;
_hitPoints=_x select 6;
_fuel =_x select 7;
_damage = _x select 8;

_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));
};

if (_damage < 1) then {
diag_log format["OBJ: %1 - %2", _idKey,_type];

//Create it
_object = createVehicle [_type, _pos, [], 0, "CAN_COLLIDE"];
_object setVariable ["lastUpdate",time];
if (_ownerID == "0") then {_object setVariable ["ObjectID", str(_idKey), true];} else {_object setVariable ["ObjectUID", str(_idKey),true];}; //_object setVariable ["ObjectID", _idKey, true];
_object setVariable ["CharacterID", _ownerID, true];

clearWeaponCargoGlobal _object;
clearMagazineCargoGlobal _object;

if (_object isKindOf "TentStorage") then {
_pos set [2,0];
_object setpos _pos;
_object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
};
_object setdir _dir;
_object setDamage _damage;

if (count _intentory > 0) then {
//Add weapons
_objWpnTypes = (_intentory select 0) select 0;
_objWpnQty = (_intentory select 0) select 1;
_countr = 0;
{
if (_x == "Crossbow") then { _x = "Crossbow_DZ" }; // Convert Crossbow to Crossbow_DZ
_isOK = isClass(configFile >> "CfgWeapons" >> _x);
if (_isOK) then {
_block = getNumber(configFile >> "CfgWeapons" >> _x >> "stopThis") == 1;
if (!_block) then {
_object addWeaponCargoGlobal [_x,(_objWpnQty select _countr)];
};
};
_countr = _countr + 1;
} forEach _objWpnTypes;

//Add Magazines
_objWpnTypes = (_intentory select 1) select 0;
_objWpnQty = (_intentory select 1) select 1;
_countr = 0;
{
if (_x == "BoltSteel") then { _x = "WoodenArrow" }; // Convert BoltSteel to WoodenArrow
_isOK = isClass(configFile >> "CfgMagazines" >> _x);
if (_isOK) then {
_block = getNumber(configFile >> "CfgMagazines" >> _x >> "stopThis") == 1;
if (!_block) then {
_object addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
};
};
_countr = _countr + 1;
} forEach _objWpnTypes;

//Add Backpacks
_objWpnTypes = (_intentory select 2) select 0;
_objWpnQty = (_intentory select 2) select 1;
_countr = 0;
{
_isOK = isClass(configFile >> "CfgVehicles" >> _x);
if (_isOK) then {
_block = getNumber(configFile >> "CfgVehicles" >> _x >> "stopThis") == 1;
if (!_block) then {
_object addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];
};
};
_countr = _countr + 1;
} forEach _objWpnTypes;
};

if (_object isKindOf "AllVehicles") then {
{
_selection = _x select 0;
_dam = _x select 1;
if (_selection in dayZ_explosiveParts and _dam > 0.8) then {_dam = 0.8};
[_object,_selection,_dam] call object_setFixServer;
} forEach _hitpoints;
_object setvelocity [0,0,1];
_object setFuel _fuel;
_object call fnc_vehicleEventHandler;
};

//Monitor the object
//_object enableSimulation false;
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
};
} forEach _myArray;

// # END OF STREAMING #

// Spawn Buildings
//Send the key
_key = format["CHILD:999:select b.class_name, ib.worldspace from instance_building ib join building b on ib.building_id = b.id where ib.instance_id = ?:[%1]:", dayZ_instance];
_data = "HiveEXT" callExtension _key;
diag_log("SERVER: Fetching buildings...");

//Process result
_result = call compile format ["%1", _data];
_status = _result select 0;

_bldList = [];
_bldCount = 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];

_pos = call compile (_result select 1);
_dir = _pos select 0;
_pos = _pos select 1;

_building = createVehicle [_result select 0, _pos, [], 0, "CAN_COLLIDE"];
_building setDir _dir;
_bldCount = _bldCount + 1;
};
diag_log ("SERVER: Spawned " + str(_bldCount) + " buildings!");
};

//Set the Time
//Send request
_key = "CHILD:307:";
_result = _key call server_hiveReadWrite;
_outcome = _result select 0;
if(_outcome == "PASS") then {
_date = [2013,8,10,(_result select 1) select 3, (_result select 1) select 4];
if(isDedicated) then {
//["dayzSetDate",_date] call broadcastRpcCallAll;
setDate _date;
dayzSetDate = _date;
publicVariable "dayzSetDate";
};

diag_log ("HIVE: Local Time set to " + str(_date));
};

createCenter civilian;
if (isDedicated) then {
endLoadingScreen;
};

if (isDedicated) then {
_id = [] execFSM "\z\addons\dayz_server\system\server_cleanup.fsm";
};

allowConnection = true;

// [_guaranteedLoot, _randomizedLoot, _frequency, _variance, _spawnChance, _spawnMarker, _spawnRadius, _spawnFire, _fadeFire]
nul = [3, 4, (5 * 60), (20 * 60), 1.0, 'center', 4000, true, false] spawn server_spawnCrashSite;
 
Cleanup
First lines to change appear as in my file before editing
{
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;" \n
"_numDead = {local _x} count allDead;" \n
""/*%FSM</STATEINIT""">*/;


In the tutorial it appears as

name = "waiting";
init = /*%FSM<STATEINIT""">*/"//diag_log ""CLEANUP: Waiting for next task"";" \n
"_numDead = {local _x} count allDead;" \n
""/*%FSM</STATEINIT""">*/;


Next section as it appears in my file before editing

name = "prepare";
init = /*%FSM<STATEINIT""">*/"private [""_safety"", ""_crier"", ""_msgList"", ""_lastTimeSync"", ""_lastDeadCheck"", ""_lastItemCheck"", ""_lastObjectUpdateCheck"", ""_timeHackCheck"", ""_deadBodies"", ""_maxBodies""];" \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
"_lastUpdate = time;" \n
"_timeNem = time;" \n
"_deadBodies = [];" \n
"_lastNeedUpdate = time;" \n
"_maxBodies = 15;" \n
""/*%FSM</STATEINIT""">*/;

In tutorial it appears as
init = /*%FSM<STATEINIT""">*/"diag_log (""CLEANUP: INITIALIZING CLEANUP SCRIPT"");" \n
"" \n
"_safety = dayz_serverObjectMonitor;" \n
"" \n
"_lastUpdate = time;" \n
"_timeNem = time;" \n
"_deadBodies = [];" \n
"_lastNeedUpdate = time;" \n
"_maxBodies = 15;" \n
""/*%FSM</STATEINIT""">*/;
 
Back
Top