CREATE PROCEDURE [dbo].[UpdatePlayer]
@Level int,
@Specialty int,
@Contribute int,
@Exp int,
@GRole int,
@Strength int,
@Health int,
@Intelligence int,
@Wisdom int,
@Dexterity int,
@CurHP int,
@CurMP int,
@PUPoint int,
@SUPoint int,
@Killed int,
@Map int,
@X int,
@Y int,
@Z int,
@Rage int,
@PID int
AS
DECLARE @CurrentLevel int
DECLARE @iid int
DECLARE @AdminPID int
DECLARE @TimetS int
DECLARE @TimetE int
DECLARE @OldLevel int
DECLARE @Name varchar(14)
SET @TimetS = (SELECT DATEDIFF(s, '19700101', GETDATE()))
SET @TimetE = @TimetS + 172800;
SET @AdminPID = 28980; --admin pid you want to send gifts from
SET @OldLevel = (SELECT TOP 1 [Level] FROM Player WHERE PID = @PID)
SET @Name = (SELECT TOP 1 [Name] FROM Player WHERE PID = @PID)
IF(@OldLevel < 50 AND @Level >= 50) --change this to the level you want reward on, in this example it is level 50
BEGIN
SET @iid = (SELECT TOP 1 IID FROM Item WHERE IID < 1500000000 ORDER BY IID DESC) + 1 --my method of adding IIDs that dont duplicate, add a random item with IID 1500000000 before running the dbserver and mainserver
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [UpgrLevel], [UpgrRate], [Protect])
VALUES ( @AdminPID, @iid, 31, 0, 0, 1000000, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0) --inserting money to admin pid
INSERT INTO Mail ([TimetS], [TimetE], [Priority], [Type], [Status], [SPID], [SName], [RPID], [RName], [IID], [Ver], [Index], [Prefix], [Num], [Pay], [Msg])
VALUES ( @TimetS, @TimetE, 0, 1, 0, @AdminPID, 'New World Kal', @PID, @Name, 0, 0, 31, 0, 1000000, 0, 'test') --inserting mail
UPDATE Player SET [Level] = @Level, [Specialty] = @Specialty, [Contribute] = @Contribute, [Exp] = @Exp, [GRole] = @GRole, [Strength] = @Strength, [Health] = @Health, [Intelligence] = @Intelligence, [Wisdom] = @Wisdom, [Dexterity] = @Dexterity, [CurHP] = @CurHP, [CurMP] = @CurMP, [PUPoint] = @PUPoint, [SUPoint] = @SUPoint, [Killed] = @Killed, [Map] = @Map, [X] = @X, [Y] = @Y, [Z] = @Z, [Rage] = @Rage WHERE [PID] = @PID
END
ELSE
BEGIN
UPDATE Player SET [Level] = @Level, [Specialty] = @Specialty, [Contribute] = @Contribute, [Exp] = @Exp, [GRole] = @GRole, [Strength] = @Strength, [Health] = @Health, [Intelligence] = @Intelligence, [Wisdom] = @Wisdom, [Dexterity] = @Dexterity, [CurHP] = @CurHP, [CurMP] = @CurMP, [PUPoint] = @PUPoint, [SUPoint] = @SUPoint, [Killed] = @Killed, [Map] = @Map, [X] = @X, [Y] = @Y, [Z] = @Z, [Rage] = @Rage WHERE [PID] = @PID
END