Cookies


Vsroplus only uses the cookies it needs to keep you signed in and remember your language. No ads, no tracking.

Got it

Need to learn more? Privacy policy

Our guides are in English for now.

Character Select

Stored Procedure: _OnCharacterSelect

Parameters:

  • @UserJID INT - User JID
  • @CharID INT - Character ID
  • @CharName16 VARCHAR(64) - Character name

Let us send a global game notification using the _Command_Global_SendTextNotification command to make sure that the trigger works correctly.

USE [vPlus]
GO
/****** Object:  StoredProcedure [dbo].[_OnCharacterSelect]    Script Date: 1/9/2024 6:25:17 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:      <Author,,Name>
-- ALTER date:  <ALTER Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[_OnCharacterSelect]
    @UserJID INT,
    @CharID INT,
    @CharName16 VARCHAR(64)
AS
BEGIN
    SET NOCOUNT ON;

    /*DO NOT REMOVE*/
    EXEC _Action_UpdateBuffs @CharID;

    IF (NOT EXISTS(SELECT * FROM _AccountJID WHERE UserJID = @UserJID))
    BEGIN
        INSERT INTO _AccountJID (UserJID) VALUES (@UserJID)

        UPDATE _panel_chart_newaccounts SET Count += 1 WHERE [Day] = CONVERT(DATE, GETDATE());
        IF (@@ROWCOUNT = 0)
            INSERT INTO _panel_chart_newaccounts VALUES (1, GETDATE());
    END

    IF (NOT EXISTS (SELECT * FROM _Char WITH (NOLOCK) WHERE CharID = @CharID))
    BEGIN
        DECLARE @DefaultIconID INT = (SELECT CAST(Value AS INT) FROM _RefSetting WHERE CodeName128 = 'DEFAULT_CHARACTER_ICON_ID' AND ISNUMERIC(Value) = 1)
        IF (@DefaultIconID IS NULL)
            SET @DefaultIconID = 0

        INSERT INTO _Char (CharID, CharMarkID) VALUES (@CharID, @DefaultIconID)

        INSERT INTO vPlus.._CharOptionalTeleport_SavedLocation (CharID, Slot)
        SELECT @CharID, cnt FROM _RefDummySlot WITH(NOLOCK) WHERE cnt < 5

        INSERT INTO _CharDances VALUES (@CharID, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)

        /*Charts Data Begin*/
        UPDATE _panel_chart_newcharacters SET Count += 1 WHERE [Day] = CONVERT(DATE, GETDATE());
        IF (@@ROWCOUNT = 0)
            INSERT INTO _panel_chart_newcharacters VALUES (1, GETDATE());

        DECLARE @OPCount INT = (SELECT COUNT(*) FROM _OnlinePlayers);
        IF (NOT EXISTS (SELECT * FROM _panel_chart_onlineplayers WHERE [Day] = CONVERT(DATE, GETDATE())))
            INSERT INTO _panel_chart_onlineplayers VALUES (@OPCount, GETDATE());
        ELSE
            UPDATE _panel_chart_onlineplayers SET [Count] = @OPCount WHERE [Day] = CONVERT(DATE, GETDATE()) AND [Count] < @OPCount;
        /*Charts Data End*/
    END
    /*DO NOT REMOVE*/

    --------- Your code starts here --------
    -- Declaring our message variable
    DECLARE @Message VARCHAR(255) = @CharName16 + ' has logged in successfully!'

    -- Executing the command
    EXEC _Command_Global_SendTextNotification @Message, 1, 0, 0
END

Last updated: 9 January, 2024

An error has occurred. This application may no longer respond until reloaded. Reload 🗙