Culdych wrote:Yep, as they stand now they are essentially just decoration. There is now way i will ever get them to finish a cycle on the server i play on. I'd preffer it if they worked like farms rather than drying racks, flux is the defacto currency on most servers so making it too easy would be detrimental.
Xarven wrote:Same here. With 3 restarts and maybe 1-2 server crashes there is no way to gather herbs with this. Cause everytime it resets the garden.
CALL `p_grow_herbal_garden`();
BEGIN
DECLARE done INT;
DECLARE herb_garden_container_id INT;
DECLARE curs CURSOR FOR SELECT ID FROM containers where ObjectTypeID = 1353; -- Herbal Garden
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN curs;
SET done = 0;
REPEAT
FETCH curs INTO herb_garden_container_id;
IF (SELECT
EXISTS (SELECT * from items WHERE containerID = herb_garden_container_id
AND ObjectTypeID = 204 AND items.Quantity = 10) -- 10 water
AND
EXISTS (SELECT * from items WHERE containerID = herb_garden_container_id
AND ObjectTypeID = 1032 AND items.Quantity = 1) -- 1 dung
AND
EXISTS (SELECT * from items WHERE containerID = herb_garden_container_id
AND ObjectTypeID >= 684 AND ObjectTypeID <= 750 AND Quantity = 1) -- 1 herb
) = 1
THEN
-- remove water and dung
DELETE FROM items WHERE containerID = herb_garden_container_id
AND (ObjectTypeID = 204 OR ObjectTypeID = 1032);
-- set herb quantity to 45
UPDATE items SET Quantity = 45 WHERE containerID = herb_garden_container_id
AND ObjectTypeID >= 684 AND ObjectTypeID <= 750;
END IF;
UNTIL done END REPEAT;
CLOSE curs;
END
J3ron1mo wrote:Hey folks,
after having the same problem on our server and reading this here, I sat down and wrote a Stored Procedure which will make the herbal garden grow if the correct contents are found inside (10 water, 1 dung, 1 herb). 'Grow' in this case means add another 44 herbs of that type and remove the water and dung.
This then can be called during server restart, which in our case is the daily restart in the morning when normally the plants would grow anyway.
To call it (for example from dump.sql):
- Code: Select all
CALL `p_grow_herbal_garden`();
The stored procedure 'p_grow_herbal_garden':
- Code: Select all
BEGIN
DECLARE done INT;
DECLARE herb_garden_container_id INT;
DECLARE curs CURSOR FOR SELECT ID FROM containers where ObjectTypeID = 1353; -- Herbal Garden
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN curs;
SET done = 0;
REPEAT
FETCH curs INTO herb_garden_container_id;
IF (SELECT
EXISTS (SELECT * from items WHERE containerID = herb_garden_container_id
AND ObjectTypeID = 204 AND items.Quantity = 10) -- 10 water
AND
EXISTS (SELECT * from items WHERE containerID = herb_garden_container_id
AND ObjectTypeID = 1032 AND items.Quantity = 1) -- 1 dung
AND
EXISTS (SELECT * from items WHERE containerID = herb_garden_container_id
AND ObjectTypeID >= 684 AND ObjectTypeID <= 750 AND Quantity = 1) -- 1 herb
) = 1
THEN
-- remove water and dung
DELETE FROM items WHERE containerID = herb_garden_container_id
AND (ObjectTypeID = 204 OR ObjectTypeID = 1032);
-- set herb quantity to 45
UPDATE items SET Quantity = 45 WHERE containerID = herb_garden_container_id
AND ObjectTypeID >= 684 AND ObjectTypeID <= 750;
END IF;
UNTIL done END REPEAT;
CLOSE curs;
END
-- Herb Garden
DROP PROCEDURE IF EXISTS p_grow_herbal_garden;
CREATE PROCEDURE `p_grow_herbal_garden`(
IN `inID` INT UNSIGNED
)
BEGIN
DECLARE done INT;
DECLARE herb_garden_container_id INT;
DECLARE curs CURSOR FOR SELECT ID FROM containers where ObjectTypeID = 1353; -- Herbal Garden
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN curs;
SET done = 0;
REPEAT
FETCH curs INTO herb_garden_container_id;
IF (SELECT
EXISTS (SELECT * from items WHERE containerID = herb_garden_container_id
AND ObjectTypeID = 204 AND items.Quantity = 10) -- 10 water
AND
EXISTS (SELECT * from items WHERE containerID = herb_garden_container_id
AND ObjectTypeID = 1032 AND items.Quantity = 1) -- 1 dung
AND
EXISTS (SELECT * from items WHERE containerID = herb_garden_container_id
AND ObjectTypeID >= 684 AND ObjectTypeID <= 750 AND Quantity = 1) -- 1 herb
) = 1
THEN
-- remove water and dung
DELETE FROM items WHERE containerID = herb_garden_container_id
AND (ObjectTypeID = 204 OR ObjectTypeID = 1032);
-- set herb quantity to 45
UPDATE items SET Quantity = 50 WHERE containerID = herb_garden_container_id
AND ObjectTypeID >= 684 AND ObjectTypeID <= 750;
END IF;
UNTIL done END REPEAT;
CLOSE curs;
END;