Jump to content

SQL Cleanups - Someone mind sharing?


Kimzer

Recommended Posts

  Reveal hidden contents

Link to comment
Share on other sites

Here is some more :

/* Unlock vehicles with lost keys */
UPDATE `Object_DATA_1`
SET `Object_DATA_1`.`CharacterID` = 0
WHERE `Object_DATA_1`.`CharacterID` <> 0
AND`Object_DATA_1`.`CharacterID` <= 12500
AND`Object_DATA_1`.`Classname` NOT LIKE 'Tent%'
AND`Object_DATA_1`.`Classname` NOT LIKE '%Locked'
AND`Object_DATA_1`.`Classname` NOT LIKE 'Land%'
AND`Object_DATA_1`.`Classname` NOT LIKE 'Cinder%'
AND`Object_DATA_1`.`Classname` NOT LIKE 'Wood%'
AND`Object_DATA_1`.`Classname` NOT LIKE 'Metal%'
AND`Object_DATA_1`.`Classname` NOT LIKE '%Storage%'
AND`Object_DATA_1`.`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 FindVehicleKeysCount1(Object_DATA_1.CharacterID) = 0
/* Delete all dead characters */
DELETE from Character_data
USING Character_data, Character_data as tempchartable
WHERE (Character_data.PlayerUID = tempchartable.PlayerUID)
AND (NOT Character_data.alive = tempchartable.alive)
AND (Character_data.alive = 0)

/* Delete Inactive Characters */
DELETE FROM Character_DATA
WHERE LastLogin < NOW() - INTERVAL 10 DAY

If using SC :

/* Delete Old Banks */
DELETE FROM banking_data
WHERE LastUpdated < NOW() - INTERVAL 20 DAY

 

Link to comment
Share on other sites

  On 2/4/2015 at 5:54 PM, cen said:

 

  Reveal hidden contents

 

 

I'm assuming this is in a batch file that is directed to run at startup on a dedicated box, yes? How would I incorporate this into a server running on a host? Can I add this to the init.sqf or server_monitor.sqf?

Link to comment
Share on other sites

  On 2/8/2015 at 6:59 PM, JerryAtricks said:

I'm assuming this is in a batch file that is directed to run at startup on a dedicated box, yes? How would I incorporate this into a server running on a host? Can I add this to the init.sqf or server_monitor.sqf?

No, that's a list of SQL query commands. You can use the whole file or parts that interest you.

To run it, it depends on your mysql client - web based one just use SQL tab, but if using HeidiSQL, it's the query tab (blue arrow), paste in code and press run.

Careful tho, try to understand what's going on before you do something silly on a live server as there is no going back. Always do a backup!

 

edit: my bad, didn't even look at it

Edited by raymix
Link to comment
Share on other sites

The List of script that cen posted is not correctly formatted, You cannot run all of it at the same time. Only one by one.

 

Here is the Correct Format for all the scripts plus some extra ones by me:

 

  Reveal hidden contents

Link to comment
Share on other sites

Ok, cool. I used a few of those and did some cleanups on my server. Thanks!

But, what does this code do, exactly?

/* Fix inventory on maintain objects */
UPDATE `object_data`
SET `inventory` = '[]',`LastUpdated` = `LastUpdated`
WHERE `inventory` = '[[[],[]],[[],[]],[[],[]]]'
AND
`Classname` IN (
'BagFenceRound_DZ','CinderWall_DZ','CinderWallDoorLocked_DZ','CinderWallDoorSmall_DZ','CinderWallDoorSmallLocked_DZ',
'CinderWallHalf_DZ','FireBarrel_DZ','GunRack_DZ','LightPole_DZ','MetalFloor_DZ','MetalPanel_DZ','OutHouse_DZ','TentStorage',
'TentStorageDomed','TentStorageDomed2','Sandbag1_DZ','Scaffolding_DZ','StickFence_DZ','StorageShed_DZ','WorkBench_DZ',
'WoodCrate_DZ','WoodFloor_DZ','WoodFloorQuarter_DZ','WoodLargeWall_DZ','WoodLargeWallWin_DZ','WoodShack_DZ','WoodSmallWall_DZ',
'WoodSmallWallThird_DZ','WoodSmallWallWin_DZ','Land_DZE_GarageWoodDoor','WoodFloorHalf_DZ','Fort_RazorWire','Land_DZE_LargeWoodDoorLocked',
'WoodStairsRails_DZ','WoodLadder_DZ','WoodStairsSans_DZ','M240Nest_DZ','Land_DZE_WoodDoor'
);

Does this maintain all built objects? I'm not really sure what the 'inventory' is on maintain objects.

Link to comment
Share on other sites

  On 2/9/2015 at 8:45 AM, JerryAtricks said:

Ok, cool. I used a few of those and did some cleanups on my server. Thanks!

But, what does this code do, exactly?

/* Fix inventory on maintain objects */
UPDATE `object_data`
SET `inventory` = '[]',`LastUpdated` = `LastUpdated`
WHERE `inventory` = '[[[],[]],[[],[]],[[],[]]]'
AND
`Classname` IN (
'BagFenceRound_DZ','CinderWall_DZ','CinderWallDoorLocked_DZ','CinderWallDoorSmall_DZ','CinderWallDoorSmallLocked_DZ',
'CinderWallHalf_DZ','FireBarrel_DZ','GunRack_DZ','LightPole_DZ','MetalFloor_DZ','MetalPanel_DZ','OutHouse_DZ','TentStorage',
'TentStorageDomed','TentStorageDomed2','Sandbag1_DZ','Scaffolding_DZ','StickFence_DZ','StorageShed_DZ','WorkBench_DZ',
'WoodCrate_DZ','WoodFloor_DZ','WoodFloorQuarter_DZ','WoodLargeWall_DZ','WoodLargeWallWin_DZ','WoodShack_DZ','WoodSmallWall_DZ',
'WoodSmallWallThird_DZ','WoodSmallWallWin_DZ','Land_DZE_GarageWoodDoor','WoodFloorHalf_DZ','Fort_RazorWire','Land_DZE_LargeWoodDoorLocked',
'WoodStairsRails_DZ','WoodLadder_DZ','WoodStairsSans_DZ','M240Nest_DZ','Land_DZE_WoodDoor'
);
Does this maintain all built objects? I'm not really sure what the 'inventory' is on maintain objects.

 

 

This is specific to plot for life and eye scan mods as is uses the inventory field to store SteamID and player names.

 

If you don't use those mods you can ignore it but it won't hurt anything either way.

Link to comment
Share on other sites

  On 2/9/2015 at 1:48 PM, cen said:

 

This is specific to plot for life and eye scan mods as is uses the inventory field to store SteamID and player names.

 

If you don't use those mods you can ignore it but it won't hurt anything either way.

 

I dont get it, why are you clearing the inventory, It contains UIDs

Link to comment
Share on other sites

  On 2/9/2015 at 5:31 PM, cen said:

It's not clearing the inventory, it's setting inventories that are [[[],[]],[[],[]],[[],[]]] to []

 

You need to do this so that the hiveext.ini cleanup will pick it up and remove them.

 

Oh nice, Didnt know that, thanks

Link to comment
Share on other sites

Hello, I to to add a few of these as well.  I do want to make sure i'm doing it right before hand.  Don't want to mess anything up.  Here is what i'm adding

 

/* Delete old crap */
DELETE FROM `object_data`
WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 21 DAY);

/* Delete all vehicles not touched in 14 days */
DELETE FROM `object_data`
WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 14 DAY)
AND `Classname`
NOT REGEXP 'barrier|storage|shed|bench|wall|floor|fence|pump|wood|hrescue|stick|pole|generator|panel|house|rack|bag|stand|barrel|canvas|wire|hedgehog|net|trap|ramp|fort|sand|scaffold|nest';

/* Set Safe Combo to 0000 */
UPDATE `object_data`
SET `CharacterID` = 0
WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 30 DAY)
AND `CharacterID` > 0
AND `Classname` = "VaultStorageLocked"
AND `Inventory` <> '[]'
AND `Inventory` IS NOT NULL;

 

I did change some of the interval's.  My server is hosted by vert hosting.  So I have access to phpmyadmin   I have 2 drop down things on the left side, 1 is information schema and 2 My name(which it where the trader data, character data, object data,etc is at.

 

I clicked my name, then clicked the SQL tab on the top.  Which is what raymix said up top, if I read it correctly.  Is that correct, if so is that all I have to do?

 

The deletes all vehicles not touched in 14 days.  Does unlocking them then locking them back again count?  Also is there away to have them have to be moved say 10 meters as well?

 

One more thing the deletes old crap, what exactly is old crap? 

 

Thanks for the help.  I want to make sure its correct before messing with the phpmyadmin.  I already have traders messed up from adding 2 items.  Don't need anything else going wrong lol.

Link to comment
Share on other sites

  • 3 weeks later...
  On 2/4/2015 at 5:54 PM, cen said:

 

  Reveal hidden contents

 

 

CEN!

 

May i kiss your forhead!

 

Thanks for sharing this!

Link to comment
Share on other sites

  • 2 weeks later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Discord

×
×
  • Create New...