Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ----------------------------
- -- Procedure structure for [WZ_CharCreate]
- -- ----------------------------
- ALTER PROCEDURE [dbo].[WZ_CharCreate]
- @in_CustomerID int,
- @in_Hardcore int,
- @in_Gamertag nvarchar(64),
- @in_HeroItemID int,
- @in_HeadIdx int,
- @in_BodyIdx int,
- @in_LegsIdx int
- AS
- BEGIN
- SET NOCOUNT ON;
- if(@in_Gamertag like '%' + char(32) + '%') begin
- select 9 as ResultCode, 'no space in name' as ResultMsg
- return
- end
- if(@in_Gamertag like '%sergey%titov%') begin
- select 9 as ResultCode, 'no impersonation' as ResultMsg
- return
- end
- if(@in_Gamertag like '%titov%sergey%') begin
- select 9 as ResultCode, 'no impersonation' as ResultMsg
- return
- end
- if(@in_Gamertag like '%\[dev\]%' escape '\') begin
- select 9 as ResultCode, 'no dev' as ResultMsg
- return
- end
- -- check if gamertag is unique
- if exists (select CharID from UsersChars where Gamertag=@in_Gamertag)
- begin
- select 9 as ResultCode, 'Gamertag already exists' as ResultMsg
- return
- end
- -- we can't have more that 5 survivors
- declare @NumChars int = 0
- select @NumChars=COUNT(*) from UsersChars where CustomerID=@in_CustomerID
- if(@NumChars >= 5) begin
- select 6 as ResultCode, 'too many created chars' as ResultMsg
- return
- end
- insert into UsersChars (
- CustomerID,
- Gamertag,
- Alive,
- Hardcore,
- HeroItemID,
- HeadIdx,
- BodyIdx,
- LegsIdx,
- BackpackID,
- BackpackSize,
- SkillID0,
- SkillID1,
- SkillID2,
- SkillID3,
- SkillID4,
- SkillID5,
- SkillID6,
- SkillID7,
- SkillID8,
- SkillID9,
- SkillID10,
- SkillID11,
- SkillID12,
- SkillID13,
- SkillID14,
- SkillID15,
- SkillID16,
- SkillID17,
- SkillID18,
- SkillID19,
- SkillID20,
- SkillID21,
- SkillID22,
- SkillID23,
- SkillID24,
- SkillID25,
- SkillID26,
- SkillID27,
- SkillID28,
- SkillID29,
- SkillID30,
- SkillID31,
- SkillID32,
- SkillID33,
- CreateDate
- ) values (
- @in_CustomerID,
- @in_Gamertag,
- 3,
- @in_Hardcore,
- @in_HeroItemID,
- @in_HeadIdx,
- @in_BodyIdx,
- @in_LegsIdx,
- 20175,
- 16,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- 1,
- GETDATE()
- )
- declare @CharID int = SCOPE_IDENTITY()
- -- give basic items for first few survivors
- declare @CharsCreated int = 0
- update UsersData set CharsCreated=(CharsCreated+1) where CustomerID=@in_CustomerID
- select @CharsCreated=CharsCreated from UsersData where CustomerID=@in_CustomerID
- if(@CharsCreated <= 5) begin
- -- add some default items - BE ULTRA CAREFUL with BackpackSlot number
- insert into UsersInventory (CustomerID, CharID, BackpackSlot, ItemID, LeasedUntil, Quantity)
- values (@in_CustomerID, @CharID, 1, 101306, '2020-1-1', 1) -- Flashlight
- insert into UsersInventory (CustomerID, CharID, BackpackSlot, ItemID, LeasedUntil, Quantity)
- values (@in_CustomerID, @CharID, 2, 101261, '2020-1-1', 1) -- Bandages
- insert into UsersInventory (CustomerID, CharID, BackpackSlot, ItemID, LeasedUntil, Quantity)
- values (@in_CustomerID, @CharID, 3, 101304, '2020-1-1', 1) -- Kit Medical
- insert into UsersInventory (CustomerID, CharID, BackpackSlot, ItemID, LeasedUntil, Quantity)
- values (@in_CustomerID, @CharID, 4, 101289, '2020-1-1', 1) -- Granola Bar
- insert into UsersInventory (CustomerID, CharID, BackpackSlot, ItemID, LeasedUntil, Quantity)
- values (@in_CustomerID, @CharID, 5, 101267, '2020-1-1', 1) -- Tac Knife
- -- insert into UsersInventory (CustomerID, CharID, BackpackSlot, ItemID, LeasedUntil, Quantity)
- -- values (@in_CustomerID, @CharID, 6, 20175, '2020-1-1', 1) -- Med Backpack
- end
- -- allow to use postbox on newly created survivors
- update UsersChars set GameFlags=1 where CharID=@CharID
- select 0 as ResultCode
- select @CharID as 'CharID'
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement