0

So I am running into an issue when executing this procedure. It runs properly by deleting the materials and creating a new item "HBlade", but at the very end, it isn't setting the argOutMessage to "Completed successfully. HBlade has been forged." Instead, the outmessage is writing as "Aborted: Need 1 Cblade" which is one of the tests at the beginning of the command.

Any idea on why this may be happening? Am I missing some syntax somewhere? It is perplexing me -- I would like a successful completion to end with the proper OutMessage and not have the command start over upon completion.

Thanks in advance.

WHEN 'HBLADE' THEN
  BEGIN

    SELECT `Amount` INTO prAC FROM `funds` WHERE `CharacterID` = argCharID;

    IF prAC < 20 
    THEN
    BEGIN
      set argOutMessage = 'Aborted: not enough AC.';
      leave main_block;
    END;
      END IF;
SELECT `Contribution` INTO prContribution FROM `character` WHERE `CharacterID` = argCharID;

IF prContribution < 50 
THEN
BEGIN
  set argOutMessage = 'Aborted: not enough contribution.';
  leave main_block;
END;
END IF;
IF ((SELECT COUNT(*) FROM `item` WHERE `CharID` = argCharID AND `Name` = 'CBlade') != 1) THEN
      BEGIN
        SET argOutMessage = "Aborted: need 1 CBlade";
        leave main_block;
      END;
END IF;
IF ((SELECT COUNT(*)
 FROM `item`
 WHERE `CharID` = argCharID AND `Name` IN ('LBlade', 'DExe')
) <> 1)
THEN
SET argOutMessage = 'Aborted: need 1 LBlade or DExe';
leave main_block;
END IF;
UPDATE `funds` 
      SET `Amount` = `Amount` - 20
      WHERE `CharacterID` = argCharID;  

        UPDATE `character` 
        SET `Contribution` = `Contribution` - 50
        WHERE `CharacterID` = argCharID;    

    DELETE FROM `item` WHERE `CharID` = argCharID AND `Name` IN ('CBlade', 'LBlade', 'DExe');

    SET prID1 = FLOOR(-30000+60000*RAND());
    SET prID2 = FLOOR(-30000+60000*RAND());
    SET prID3 = FLOOR(-30000+60000*RAND());

    INSERT INTO `item`(`CharID`, `Name`, `ItemID`, `Count`, `Type`, `ID1`, `ID2`, `ID3`, `Color`, `Effect1`, `Effect2`, `Effect3`, `LifeSpan`, `Attribute`, `Equip`, `X`, `Y`) 
    VALUES (argCharID, 'HBlade', 1419, 1, 2, prID1, prID2, prID3, 9, 0, 0, 0, 15000, 0, 0, 0, 0);

    SET argOutMessage = "Completed successfully. HBlade has been forged.";
    leave main_block;
  END;
AAGM
  • 1
  • 1
  • 1
    After it sets that message it leaves the block, so it never executes the rest of the function. – Barmar Aug 23 '14 at 04:10
  • So assuming all the requirement tests are met e.g., "has enough funds, has enough contribution, has CBlade, has LBlade OR DExe" then I want it to run several cmds to reduce funds by 20, reduc contribution by 50, delete cblade/lblade (or dexe) and insert HBlade and then output the msg of "Completed successfuly. HBlade forged.". How do I get the command to stop at the end and not go through the tests again..it currently seems to be looping after successful completion until the requirements fail at which point it leaves the block. – AAGM Aug 23 '14 at 04:24
  • 1
    I'm not sure what you're talking about, there's no loop in the above code. – Barmar Aug 23 '14 at 04:26
  • It would probably help if you indented the code properly. It's hard to see the structure. – Barmar Aug 23 '14 at 04:26

0 Answers0