By completing this guide, you should be able to trigger job item sell requests to function and build your own custom systems.
Stored Procedure: _OnCOSCartSellRequest
Parameters:
@NPCID INT - NPC ID
@NPCCodeName128 VARCHAR(129) - NPC CodeName128
@CharID INT - Character ID
@CosID INT - Trade pet ID
@Slot TINYINT - Slot number
@RefItemID INT - Item ID
@RefItemCodeName128 VARCHAR(129) - Item CodeName128
@Quantity SMALLINT - Quantity of items
Let's block selling items to a specific NPC and 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].[_OnCOSCartSellRequest] Script Date: 1/11/2024 3:19:08 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- ALTER date: <ALTER Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[_OnCOSCartSellRequest]
@NPCID INT,
@NPCCodeName128 VARCHAR(129),
@CharID INT,
@CosID INT,
@Slot TINYINT,
@RefItemID INT,
@RefItemCodeName128 VARCHAR(129),
@Quantity SMALLINT
AS
BEGIN
SET NOCOUNT ON;
/*
Return 1 for valid requests, therefore the player
will be able to sell the goods.
Otherwise, the sell request will be canceled.
*/
--------- Your code starts here --------
-- Checking the NPC CodeName128
IF (@NPCCodeName128 = 'NPC_CH_SPECIAL')
BEGIN
EXEC _Char_SendTextNotification @CharID, 'Selling items to this shop is disabled at the moment!', 1, 0, 0;
RETURN 0; -- Block the sell request
END
RETURN 1; -- Allow the sell request
END