So im having an issue with my triggers on my new server. I am using HeidiSQL to manage the DB hosted with blackbox. So Ive added the following triggers that appear to have correct syntax.
BEFORE INSERT - Does nothing at all on new character load
- Code: Select all
CREATE TRIGGER `skills_before_insert` BEFORE INSERT ON `character` FOR EACH ROW
BEGIN
/* Set Piety to 30 so character can pray without needing to pray for homecoming several times */
IF (New.SkillTypeID = 54 and New.SkillAmount < 300000000) then
set New.SkillAmount = 300000000;
end if;
/* Set Warhorse handling to 60 since it is not implemented yet */
IF (New.SkillTypeID = 26 and New.SkillAmount < 600000000) then
set New.SkillAmount = 600000000;
end if;
/* Set Prospecting to 60 */
IF (New.SkillTypeID = 1 and New.SkillAmount < 600000000) then
set New.SkillAmount = 600000000;
end if;
/* Set Mining to 60 */
IF (New.SkillTypeID = 2 and New.SkillAmount < 600000000) then
set New.SkillAmount = 600000000;
end if;
END
The next part here causes a few different issues, mainly directed at the the add items portion. If i use the character limiter by itself, that works fine.
AFTER INSERT
- Code: Select all
CREATE TRIGGER `character_after_insert` AFTER INSERT ON `character` FOR EACH ROW
BEGIN
SET @characterCount = (SELECT COUNT(*) FROM `character` ch WHERE ch.AccountID = NEW.AccountID);
IF @characterCount > 2 AND NEW.AccountID != 2 AND NEW.AccountID != 3 THEN
SET @msg = "Cannot create more than 2 characters per account";
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = @msg;
END IF;
SET @backpack = NEW.RootContainerID;
SET @temp = f_insertNewItemInventory(@backpack, 1059, 100, 16, 50000, 50000, '',''); /* copper coins */
SET @temp = f_insertNewItemInventory(@backpack, 1060, 100, 8, 50000, 50000, '',''); /* silver coins */
SET @temp = f_insertNewItemInventory(@backpack, 1061, 100, 8, 50000, 50000, '',''); /* gold coins */
SET @temp = f_insertNewItemInventory(@backpack, 48, 100, 1, 50000, 50000, '',''); /* pickaxe */
SET @temp = f_insertNewItemInventory(@backpack, 46, 100, 1, 50000, 50000, '',''); /* hatchet */
SET @temp = f_insertNewItemInventory(@backpack, 974, 50, 25, 50000, 50000, '',''); /* 25x q50 Apple Buns */
SET @temp = f_insertNewItemInventory(@backpack, 299, 50, 1, 15000, 15000, '',''); /* simple clothes */
SET @temp = f_insertNewItemInventory(@backpack, 890, 50, 1, 15000, 15000, '',''); /* novice padded greaves */
SET @temp = f_insertNewItemInventory(@backpack, 38, 50, 1, 15000, 15000, '',''); /* torch */
END;
So what did I do wrong here? For the AFTER INSERT, if I run the query above I get a syntax error at SET @backpack = NEW.RootContainerID;, yet if I add that to the existing character limiter trigger there is no issue. With the SET *** in the trigger I get the 1024 error on new character creation attempt.
Again I reviewed all the current threads on this and have tried them all, not too sure whats going on. And MariaDB is limited to 1 BEFORE and 1 AFTER right now so I cant split them.
Thanks!