Jump to content
  • 0

How to unlock vehicles if unused for some number of days


Bob_the_K

Question

Since people come and go on servers, they often leave behind locked vehicles.  We have a script that deletes anything not used for 30 days but we'd like to put in a script that simply unlocks locked vehicles if not used for five days.  This would give others an opportunity to find gear and maybe get a vehicle to use.  I thought I saw a script or SQL procedure to do this but couldn't find it doing searches.

 

Anyone know of such a script or SQL routine?

 

Thanks,

Bob

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Use SQL events for that, they work perfectly fine

 

https://github.com/vbawol/DayZ-Epoch/blob/master/Server%20Files/SQL/add_recommended_mysql_events.sql

 

From there you'll need FindVehicleKeysCount and UnlockNonKeyVehicles

 

Edit: you'll need to modify and add one more event if you want to unlock vehicles with existing keys so just check for last update with 5 day intervals and most people lose their keys anyway

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

basically create an event in sql and change 7DAY to whatever you'd like and it will unlock unused cars

Link to comment
Share on other sites

  • 0

So if they were locked vehicles and the script unlocks them with keys, won't they relock on next reset?   We're looking for them to remain unlocked - essentially becoming keyless vehicles for anyone that comes upon one.

Im not much for sql but it needs to check vehicles timestamp for last update which will be however long you choose. then set the character id to 0 which permanently unlocks the vehicles that havent been used in that period of time.

 

And to unlock vehicles where players have lost the key, you require a function in the database that checks for the key before the event made to unlock non key vehicles works.  Easily found searching google.

Link to comment
Share on other sites

  • 0

So if they were locked vehicles and the script unlocks them with keys, won't they relock on next reset?   We're looking for them to remain unlocked - essentially becoming keyless vehicles for anyone that comes upon one.

 

No, sql event makes them keyless forever as it sets vehicles ID to 0 which means it has no key and is just like any other dynamic vehicle spawned in the server

 

Edit: If you aim to unlock any unused vehicles you need just that little piece of code in my first post if you want to unlock vehicles with lost keys then you'll have to use those from github

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...