Jump to content
  • 0

unlock vehicles after 5 days of inactivity (mysql event)?


rentiger1112

Question

13 answers to this question

Recommended Posts

  • 0
UPDATE `object_data` SET CharacterID = 0 WHERE LastUpdated < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 DAY) AND CharacterID > 0 AND Classname NOT IN ('VaultStorage','LockboxStorage','VaultStorageLocked','LockboxStorageLocked','WoodShack_DZ','StorageShed_DZ','TentStorageDomed','TentStorageDomed2','TentStorage','Wooden_shed_DZ','GunRack_DZ','WoodCrate_DZ') AND Inventory <> '[]' AND Inventory IS NOT NULL

here is mine sql event... works perfect

Link to comment
Share on other sites

  • 0
UPDATE `object_data` SET CharacterID = 0 WHERE LastUpdated < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 DAY) AND CharacterID > 0 AND Classname NOT IN ('VaultStorage','LockboxStorage','VaultStorageLocked','LockboxStorageLocked','WoodShack_DZ','StorageShed_DZ','TentStorageDomed','TentStorageDomed2','TentStorage','Wooden_shed_DZ','GunRack_DZ','WoodCrate_DZ') AND Inventory <> '[]' AND Inventory IS NOT NULL

here is mine sql event... works perfect

 

thanks

Link to comment
Share on other sites

  • 0
UPDATE `object_data` SET CharacterID = 0 WHERE LastUpdated < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 DAY) AND CharacterID > 0 AND Classname NOT IN ('VaultStorage','LockboxStorage','VaultStorageLocked','LockboxStorageLocked','WoodShack_DZ','StorageShed_DZ','TentStorageDomed','TentStorageDomed2','TentStorage','Wooden_shed_DZ','GunRack_DZ','WoodCrate_DZ') AND Inventory <> '[]' AND Inventory IS NOT NULL

here is mine sql event... works perfect

 

will that always work or do I have to run the event every day ??

shouldn't it be a drop event ?

im asking since I still dont understand sql stuff too well 

I just run that as a query and its there forever ?

Link to comment
Share on other sites

  • 0

will that always work or do I have to run the event every day ??

shouldn't it be a drop event ?

im asking since I still dont understand sql stuff too well 

I just run that as a query and its there forever ?

 

This is the execution code for event. If you run this code now it will just run once. You need to make an event separately for this to keep running.

 

Edit// In other words, this should be the correct code for making it an actual event:

DROP EVENT IF EXISTS unlockUnusedVehicles;
CREATE EVENT unlockUnusedVehicles
    ON SCHEDULE EVERY 4 HOUR
    COMMENT 'Unlocks any vehicle that has not been touched for 5 days'
    DO
      UPDATE `object_data` SET CharacterID = 0 WHERE LastUpdated < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 DAY) AND CharacterID > 0 AND Classname NOT IN ('VaultStorage','LockboxStorage','VaultStorageLocked','LockboxStorageLocked','WoodShack_DZ','StorageShed_DZ','TentStorageDomed','TentStorageDomed2','TentStorage','Wooden_shed_DZ','GunRack_DZ','WoodCrate_DZ') AND Inventory <> '[]' AND Inventory IS NOT NULL;
;

Edited by Rocu
Link to comment
Share on other sites

  • 0

Here's mine:

/* Unlock Purchased Untouched Vehicles */
UPDATE `object_data`
SET `CharacterID` = 0
WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 DAY)
AND `CharacterID` > 0
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';

Link to comment
Share on other sites

  • 0

 

Here's mine:

/* Unlock Purchased Untouched Vehicles */
UPDATE `object_data`
SET `CharacterID` = 0
WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 DAY)
AND `CharacterID` > 0
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';

So you just chuck that in the query and it just continues as a event?

I suck with the database stuff :P

Link to comment
Share on other sites

  • 0

So you just chuck that in the query and it just continues as a event?

I suck with the database stuff :P

 

>.< As I said like 3 posts above, you need to actually make it to an event first. That code he provided is the code that is supposed to execute every X day. It isn't the code that makes the "execute every X day" thing happen. Capiche?

 

If you don't know how to make an event, use this code instead:

DROP EVENT IF EXISTS unlockUnusedVehicles;
CREATE EVENT unlockUnusedVehicles
    ON SCHEDULE EVERY 4 HOUR
    COMMENT 'Unlocks any vehicle that has not been touched for 5 days'
    DO
		UPDATE `object_data`
		SET `CharacterID` = 0
		WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 DAY)
		AND `CharacterID` > 0
		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';
;

Now THIS is the code you can just chuck in the query and it starts looping itself every 5 days. (Haven't tested, but should work)

Edited by Rocu
Link to comment
Share on other sites

  • 0

Why would you only want it to run every 5 days?

 

I run that every time one of my servers start...

 

You're right, my bad. OP wanted 5 days so it kind of got stuck in my mind and wrote 5 days everywhere :D . Edited my scripts above.

Link to comment
Share on other sites

  • 0

 

Here's mine:

/* Unlock Purchased Untouched Vehicles */
UPDATE `object_data`
SET `CharacterID` = 0
WHERE `LastUpdated` < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 DAY)
AND `CharacterID` > 0
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';

What exactly does this one do?? 

Link to comment
Share on other sites

  • 0

What exactly does this one do?? 

 

Well, in technical terms, it sets CharacterID to 0 (clears ownership / removes the need for a key) for any item, that has not been updated within 5 days. Exceptions include barrier, storage, shed, etc etc. The exception is necessary so that it doesn't reset things like safes, lockboxes, locked doors etc. So it applies only on vehicles.

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...