Jump to content

Player Safe Reset Mission


Recommended Posts

Hi folks,

 

I on my server and really liked it.  Here's the sql event I used:

 DROP EVENT IF EXISTS resetVaults; CREATE EVENT resetVaults
   ON SCHEDULE EVERY 1 DAY
   COMMENT 'Sets safe codes to 0000 if not accessed for 14 days'
   DO
UPDATE `object_data` SET `CharacterID` = 0
WHERE
`LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 14 DAY) AND
`Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 14 DAY) AND
`CharacterID` > 0 AND
`Classname` IN ('VaultStorageLocked') AND
`Inventory` <> '[]' AND
`Inventory` IS NOT NULL

I thought it would be nice to add a mission to reveal the location of abandoned safes so players can fight over them :D

 

This script does that, just add abandonedvaults.sqf (code below) to your server pbo (dayz_server/modules).

// Abandoned player safe mission by Cramps (zfclan.org/forum)
// Needs an SQL event set up to turn abandoned vault codes to 0000

private ["_rndvault","_curvaultcode","_curvault","_vaultarray","_numvaults","_allvaults","_spawnChance", "_spawnMarker", "_spawnRadius", "_markerRadius", "_item", "_debug", "_start_time", "_loot", "_loot_amount", "_loot_box", "_wait_time", "_spawnRoll", "_position", "_event_marker"];

// First chack if there is a vault available, no point running if not

diag_log ("Checking vaults...");

_allvaults = (allmissionobjects "VaultStorageLocked");
_numvaults = (count _allvaults);
_vaultarray = [];

for "_i" from 0 to _numvaults do {
	_curvault = _allvaults select _i;
	_curvaultcode = _curvault getVariable "CharacterID";
	if (_curvaultcode == "0000" ) then {
		_vaultarray = _vaultarray + [_curvault];
		};
};

_numvaults = (count _vaultarray);
diag_log ("Total open vaults on server: " + str(_numvaults));

// Exit if no safes
if (_numvaults == 0) exitWith {};

_rndvault = _vaultarray select (floor (random (count _vaultarray)));
_position = getPos _rndvault;
diag_log ("Location of randomly picked 0000 vault = " + str(_position));

// Main epoch mission stuff

_spawnChance =  0.20; // Percentage chance of event happening
_markerRadius = 150; // Radius the loot can spawn and used for the marker
_wait_time = 900; 
_start_time = time;
_debug = false; // Ignores the random chance and runs every time.

if (isNil "EPOCH_EVENT_RUNNING") then {
EPOCH_EVENT_RUNNING = false;
};
 
// Check for another event running
if (EPOCH_EVENT_RUNNING) exitWith {
diag_log("Event already running");
};
 
// Random chance of event happening
_spawnRoll = random 1;
if (_spawnRoll > _spawnChance and !_debug) exitWith {};

// Draw markers & tell players
 
_event_marker = createMarker [ format ["loot_event_marker_%1", _start_time], _position];
_event_marker setMarkerShape "ELLIPSE";
_event_marker setMarkerColor "ColorKhaki";
_event_marker setMarkerSize [(_markerRadius + 100), (_markerRadius + 100)];

_event_marker2 = createMarker [ format ["loot_event_marker_%2", _start_time], _position];
_event_marker2 setMarkerShape "ICON";
_event_marker2 setMarkerType "mil_dot";
_event_marker2 setMarkerColor "ColorBlack";
_event_marker2 setMarkerText "Abandoned Survivor Safe";

if (_debug) then {
_debug_marker = createMarker [ format ["loot_event_debug_marker_%1", _start_time], _position];
_debug_marker setMarkerShape "ICON";
_debug_marker setMarkerType "mil_dot";
_debug_marker setMarkerColor "ColorBlack";
_debug_marker setMarkerAlpha 1;
};

[nil,nil,"per",rTITLETEXT,"It's rumored there is a survivor safe lost with 0000 as it's code. Go find it!","PLAIN DOWN"] call RE;

diag_log(format["Loot event setup, waiting for %1 seconds", _wait_time]);

// Wait
sleep _wait_time;
 
// Clean up
EPOCH_EVENT_RUNNING = false;
deleteMarker _event_marker;
deleteMarker _event_marker2;

Just add it as a mission in the init.sqf the same as you would any other, here's an example:

 

EpochEvents = [["any","any","any","any",30,"abandonedvault"],["any","any","any","any",30,"crash_spawner"],["any","any","any","any",0,"crash_spawner"],["any","any","any","any",15,"supply_drop"],["any","any","any","any",22,"Military"],["any","any","any","any",37,"Treasure"],["any","any","any","any",7,"Supplyitems"],["any","any","any","any",52,"Construction"]];

 

I just added  ["any","any","any","any",30,"abandonedvault"],  to the line, it gets called at half past the hour every hour.

 

The script checks for empty vaults, if there are some and the percent chance test is passed, it will spawn a marker on the map revealing the location.

 

Enjoy!

 

Link to comment
Share on other sites

  • 1 month later...

This works like a charm!

 

The only thing I have a problem with is the issue of a base being around the safe with my indestructible no maintenance server. I have to doors set to destructible now but I guess the doors which were built when I still had the doors set as indestructible are still that way.  I need to have combo locks reset on 30 days as well but I realize there are like what 6 different checks for different doors with combo locks? I could probably figure it out just haven't spent the time yet..

 

Thanks for the great idea and script though!  LOVE IT!

Link to comment
Share on other sites

Hi folks,

 

I on my server and really liked it.  Here's the sql event I used:

 DROP EVENT IF EXISTS resetVaults; CREATE EVENT resetVaults
   ON SCHEDULE EVERY 1 DAY
   COMMENT 'Sets safe codes to 0000 if not accessed for 14 days'
   DO
UPDATE `object_data` SET `CharacterID` = 0
WHERE
`LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 14 DAY) AND
`Datestamp` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 14 DAY) AND
`CharacterID` > 0 AND
`Classname` IN ('VaultStorageLocked') AND
`Inventory` <> '[]' AND
`Inventory` IS NOT NULL

can anybody tell me how to add this to sql events? i'm trying to add via navicat "funcions". is it right?

Link to comment
Share on other sites

Nice mission :)

 

You can also unlock vaults using a MySQL procedure (edit, ive removed datestamp as there can be issues when vaults are packed and re-placed with the dates screwing up, hence I only use lastupdated)

UPDATE `object_data` SET `CharacterID` = 0 WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 14 DAY) AND `CharacterID` > 0 AND `Classname` = ('VaultStorageLocked')  AND `Inventory` <> '[]' AND `Inventory` IS NOT NULL
Link to comment
Share on other sites

struggling to get this running,

 

should it be EpochEvents = [["any","any","any","any",30,"abandonedvault],["any","any","any","any",30,"crash_spawner"],["any","any","any","any",0,"crash_spawner"],["any","any","any","any",15,"supply_drop"],["any","any","any","any",22,"Military"],["any","any","any","any",37,"Treasure"],["any","any","any","any",7,"Supplyitems"],["any","any","any","any",52,"Construction"]];

 

abandonedvault

or

abandonedvaults

 

as the file i created and added to the modules folder was abondedvaults.sqf. 

 

MGT - this is an awesome mission by the way, thank you in advance for your help

 

EDIT

 

Ignore me got it working and its awesome just changed to abondonedvaults (init.sqf) and works flawlessly, awesome mission and thank you MGT

Link to comment
Share on other sites

  • 4 weeks later...

copy and pasted the sql into my databases sql input, hit go and it just underlined many words in red it didn't seem to like, am I being thick or can someone help pls ?

 

didn't get chance to input the abdonedvaults sqf as the above part seemed to have failed

 

regards

Link to comment
Share on other sites

Any updates for 1.0.5.1 ? Getting errors

 

 

3:34:37 Error in expression <_name = name _target;
deleteMarker MH_marker;
deleteMarker MH_shade;
>
 3:34:37   Error position: <MH_marker;
deleteMarker MH_shade;
>
 3:34:37   Error Undefined variable in expression: mh_marker
 3:35:05 "RUNNING EVENT: Abandonedsafe on [2014,6,27,13,35]"
 3:35:05 "Checking vaults..."
 3:35:05 Error in expression <= _allvaults select _i;
_curvaultcode = _curvault getVariable "CharacterID";
if >
 3:35:05   Error position: <_curvault getVariable "CharacterID";
if >
 3:35:05   Error Undefined variable in expression: _curvault
 3:35:05 File z\addons\dayz_server\modules\Abandonedsafe.sqf, line 16
Link to comment
Share on other sites

jeah well thats the 112555 beta patch, im just running my server with parameter -noLogs so errors wont log. because these undefined variable most times dont mean that the script doesnt work ...

Link to comment
Share on other sites

as far as the safe reset stuff goes there must be a possibility to let the server unlock them automatically, you would need to check the vaults when they spawn in and call the unlock action or something, should be possible

Link to comment
Share on other sites

 

Nice mission :)

 

You can also unlock vaults using a MySQL procedure (edit, ive removed datestamp as there can be issues when vaults are packed and re-placed with the dates screwing up, hence I only use lastupdated)

UPDATE `object_data` SET `CharacterID` = 0 WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 14 DAY) AND `CharacterID` > 0 AND `Classname` = ('VaultStorageLocked')  AND `Inventory` <> '[]' AND `Inventory` IS NOT NULL

 

Wish I'd noticed this earlier, was getting some weirdness as described so took it off my server and didn't get the chance to look into why some safes were getting abandoned early.  I'm going to add this version of the SQL and update the code for 1051.  Watch this space!

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...

I got this running - everything works pretty fine.

 

The filename is different then the events name in the first topic. That is why it may does not work for you.

 

Name the file exact as you named the event.

Do you mean the "s" at the end of "abandonedvault.sqf"?

Link to comment
Share on other sites

Two Questions : 

 

1) _spawnChance =  0.99; if I put this too _spawnChance =  1; will it be the highest rate of spawning ? 

 

 

I got this running - everything works pretty fine.

 

The filename is different then the events name in the first topic. That is why it may does not work for you.

 

Name the file exact as you named the event.

 

2) So I name this like this ? 

 

["any","any","any","any",30,"abandonedvaults"] 

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
×
×
  • Create New...