Jump to content
  • 0

sql queries


Dismal

Question

Hey guys.

 

I am terrible with the SQL database and have had issues with getting my cleanup queries to work.

 

I'm looking for a few cleanup queries to remove ONLY vehicles with no keys on the server and ONLY vehicles that have not been updated in 7 days.

 

Everything i have found so far has been for all objects which removes peoples walls and buildables and what not.

 

If anyone could perhaps give me a few SQL queries that would help me i would appreciate it.

 

 

Link to comment
Share on other sites

15 answers to this question

Recommended Posts

  • 0

If you want to remove ANY vehicle that hasn't been touched in 7 days, just remove the CharacterID = 0 part. It'd look like this:

DELETE FROM object_data WHERE DATE (`Datestamp`) < CURDATE() - INTERVAL 7 DAY;

As for removing vehicles that no longer have a key, you'll have to create an SQL event as described in this thread:

 

http://epochmod.com/forum/index.php?/topic/7065-cleaning-up-owned-vehicles-where-no-keys-exist/?hl=%2Bkeyless+%2Bvehicles#entry46188

Link to comment
Share on other sites

  • 0

I guess the issue i'm having, is i have a hosted server. i have access to the database and can make events, but for some reason everything i can find, is either failing and gives me errors or removes peoples walls and floors and stuff.

 

I cant seem to find an example of a sql event that will leave peoples bases alone, but remove server spawned AND bought vehicles that have not been updated in 7 days, regardless if they are locked or not and regardless if they have inventory.

 

Last time i ran something i it deleted all the walls and floors that had been built prior to the 7 day mark because those don't ever update the time stamp.

Link to comment
Share on other sites

  • 0

This should do the trick. You can test first with the SELECT and then if it looks OK run the second with DELETE.

 

SELECT * FROM
`Object_DATA`
WHERE
`Object_DATA`.`Classname` NOT LIKE 'Tent%'
AND `Object_DATA`.`Classname` NOT LIKE '%Locked'
AND `Object_DATA`.`Classname` NOT LIKE 'Land%'
AND `Object_DATA`.`Classname` NOT LIKE 'Cinder%'
AND `Object_DATA`.`Classname` NOT LIKE 'Wood%'
AND `Object_DATA`.`Classname` NOT LIKE 'Metal%'
AND `Object_DATA`.`Classname` NOT LIKE '%Storage%'
AND `Object_DATA`.`Classname` NOT IN ('OutHouse_DZ', 'GunRack_DZ', 'WorkBench_DZ', 'Sandbag1_DZ', 'FireBarrel_DZ', 'DesertCamoNet_DZ', 'StickFence_DZ', 'LightPole_DZ', 'DeerStand_DZ', 'ForestLargeCamoNet_DZ', 'Plastic_Pole_EP1_DZ', 'Hedgehog_DZ', 'FuelPump_DZ', 'Fort_RazorWire', 'SandNest_DZ', 'ForestCamoNet_DZ', 'Fence_corrugated_DZ', 'CanvasHut_DZ', 'Generator_DZ')
AND `Object_DATA`.`LastUpdated` < NOW() - INTERVAL 7 DAY;

DELETE FROM
`Object_DATA`
WHERE
`Object_DATA`.`Classname` NOT LIKE 'Tent%'
AND `Object_DATA`.`Classname` NOT LIKE '%Locked'
AND `Object_DATA`.`Classname` NOT LIKE 'Land%'
AND `Object_DATA`.`Classname` NOT LIKE 'Cinder%'
AND `Object_DATA`.`Classname` NOT LIKE 'Wood%'
AND `Object_DATA`.`Classname` NOT LIKE 'Metal%'
AND `Object_DATA`.`Classname` NOT LIKE '%Storage%'
AND `Object_DATA`.`Classname` NOT IN ('OutHouse_DZ', 'GunRack_DZ', 'WorkBench_DZ', 'Sandbag1_DZ', 'FireBarrel_DZ', 'DesertCamoNet_DZ', 'StickFence_DZ', 'LightPole_DZ', 'DeerStand_DZ', 'ForestLargeCamoNet_DZ', 'Plastic_Pole_EP1_DZ', 'Hedgehog_DZ', 'FuelPump_DZ', 'Fort_RazorWire', 'SandNest_DZ', 'ForestCamoNet_DZ', 'Fence_corrugated_DZ', 'CanvasHut_DZ', 'Generator_DZ')
AND `Object_DATA`.`LastUpdated` < NOW() - INTERVAL 7 DAY;
Link to comment
Share on other sites

  • 0

Anyone notice a few things like m240nest, parkbench, bagfenceround having charid's of 0?

 

I updated my query:

 

AND `Object_DATA`.`Classname` NOT IN ('M240Nest_DZ', 'ParkBench_DZ', 'BagFenceRound_DZ', 'OutHouse_DZ', 'GunRack_DZ', 'WorkBench_DZ', 'Sandbag1_DZ', 'FireBarrel_DZ', 'DesertCamoNet_DZ', 'StickFence_DZ', 'LightPole_DZ', 'DeerStand_DZ', 'ForestLargeCamoNet_DZ', 'Plastic_Pole_EP1_DZ', 'Hedgehog_DZ', 'FuelPump_DZ', 'Fort_RazorWire', 'SandNest_DZ', 'ForestCamoNet_DZ', 'Fence_corrugated_DZ', 'CanvasHut_DZ', 'Generator_DZ')

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
  • Discord

×
×
  • Create New...