Stored Procedure: _OnJobLevelUpdate
Parameters:
@CharID INT- Character ID@CharName16 VARCHAR(64)- Character name@JobType TINYINT- Job type@NickName16 VARCHAR(64)- Job nickname@CurrentLevel TINYINT- Character's current job level@NewLevel TINYINT- Character's new job level
Let us send a text notification to the character using _Char_SendTextNotification to make sure that the trigger works correctly.
USE [vPlus]
GO
/****** Object: StoredProcedure [dbo].[_OnJobLevelUpdate] Script Date: 1/16/2024 1:36:15 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[_OnJobLevelUpdate]
@CharID INT,
@CharName16 VARCHAR(64),
@JobType TINYINT,
@NickName16 VARCHAR(64),
@CurrentLevel TINYINT,
@NewLevel TINYINT
AS
BEGIN
SET NOCOUNT ON;
/*
This procedure is executed when the player's job level is updated.
Be aware that the new level might be lower than the current level in case of death.
*/
--------- Your code starts here --------
DECLARE @Message VARCHAR(255)
-- Checking if the character levels up
IF (@NewLevel > @CurrentLevel)
BEGIN
SET @Message = 'Your character job level has been promoted to level ' + CAST(@NewLevel AS NVARCHAR)
EXEC _Char_SendTextNotification @CharID, @Message, 1, 0, 0
END
ELSE
BEGIN
SET @Message = 'Your character job level has been demoted to level ' + CAST(@NewLevel AS NVARCHAR)
EXEC _Char_SendTextNotification @CharID, @Message, 1, 0, 0
END
END