By completing this guide, you should be able to trigger achievement unlocks to function and build your own custom systems.
Stored Procedure: _OnAchievementUnlock
Parameters:
@CharID INT - Character ID
@CharName VARCHAR(64) - Character name
@AchievementID INT - Achievement ID
@AchievementCodeName VARCHAR(129) - Achievement CodeName
Let's send a text notification to the character using _Char_SendTextNotification to ensure that the trigger works fine for us.
USE [vPlus]
GO
/****** Object: StoredProcedure [dbo].[_OnAchievementUnlock] Script Date: 2/19/2024 1:55:23 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- ALTER date: <ALTER Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[_OnAchievementUnlock]
@CharID INT,
@CharName VARCHAR(64),
@AchievementID INT,
@AchievementCodeName VARCHAR(129)
AS
BEGIN
SET NOCOUNT ON;
/*
This procedure is executed once an achievement gets unlocked.
*/
--------- Your code starts here --------
-- Checking if the player unlocked the Gold Spender achievement Lvl 2
IF (@AchievementCodeName = 'GOLD_SPENDER_02')
BEGIN
EXEC _Char_SendTextNotification @CharID, 'Congratulations! Gold Spender Achievement Lvl 2 is now unlocked', 1, 0, 0;
END
END