Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.30 KB | None | 0 0
  1. -- ----------------------------
  2. -- Procedure structure for [WZ_CharCreate]
  3. -- ----------------------------
  4.  
  5. ALTER PROCEDURE [dbo].[WZ_CharCreate]
  6. @in_CustomerID int,
  7. @in_Hardcore int,
  8. @in_Gamertag nvarchar(64),
  9. @in_HeroItemID int,
  10. @in_HeadIdx int,
  11. @in_BodyIdx int,
  12. @in_LegsIdx int
  13. AS
  14. BEGIN
  15. SET NOCOUNT ON;
  16.  
  17. if(@in_Gamertag like '%sergey%titov%') begin
  18. select 9 as ResultCode, 'no impersonation' as ResultMsg
  19. return
  20. end
  21.  
  22. if(@in_Gamertag like '%titov%sergey%') begin
  23. select 9 as ResultCode, 'no impersonation' as ResultMsg
  24. return
  25. end
  26.  
  27. if(@in_Gamertag like '%system%') begin
  28. select 9 as ResultCode, 'no System' as ResultMsg
  29. return
  30. end
  31.  
  32. if(@in_Gamertag like '%\[dev\]%' escape '\') begin
  33. select 9 as ResultCode, 'no dev' as ResultMsg
  34. return
  35. end
  36.  
  37. -- check if gamertag is unique
  38. if exists (select CharID from UsersChars where Gamertag=@in_Gamertag)
  39. begin
  40. select 9 as ResultCode, 'Gamertag already exists' as ResultMsg
  41. return
  42. end
  43.  
  44. -- for anticheats we will used this to check heroitemid is vaild.
  45. declare @cat int = 0
  46. select @cat=Category from Items_Gear where ItemID=@in_HeroItemID
  47. if (@cat != 16) BEGIN
  48. select 6 as ResultCode, 'Invaid HeroItemID' as ResultMsg
  49. return
  50. end
  51.  
  52. declare @InventoryIDHero int = 0
  53. select @InventoryIDHero=InventoryID from UsersInventory where ItemID=@in_HeroItemID and CustomerID=@in_CustomerID
  54. if (@InventoryIDHero = 0) BEGIN
  55. select 6 as ResultCode, 'you not have HeroItemID' as ResultMsg
  56. return
  57. end
  58.  
  59. -- anticheats : check this user have Hero.
  60.  
  61. -- we can't have more that 5 survivors
  62. declare @NumChars int = 0
  63. select @NumChars=COUNT(*) from UsersChars where CustomerID=@in_CustomerID
  64. if(@NumChars >= 5) begin
  65. select 6 as ResultCode, 'too many created chars' as ResultMsg
  66. return
  67. end
  68.  
  69. insert into UsersChars (
  70. CustomerID,
  71. Gamertag,
  72. Alive,
  73. Hardcore,
  74. HeroItemID,
  75. HeadIdx,
  76. BodyIdx,
  77. LegsIdx,
  78. CreateDate
  79. ) values (
  80. @in_CustomerID,
  81. @in_Gamertag,
  82. 3,
  83. @in_Hardcore,
  84. @in_HeroItemID,
  85. @in_HeadIdx,
  86. @in_BodyIdx,
  87. @in_LegsIdx,
  88. GETDATE()
  89. )
  90. declare @CharID int = SCOPE_IDENTITY()
  91.  
  92. -- give basic items for first few survivors
  93. declare @CharsCreated int = 0
  94. update UsersData set CharsCreated=(CharsCreated+1) where CustomerID=@in_CustomerID
  95. select @CharsCreated=CharsCreated from UsersData where CustomerID=@in_CustomerID
  96. --if(@CharsCreated <= 5) begin
  97. -- add some default items - BE ULTRA CAREFUL with BackpackSlot number
  98. insert into UsersInventory (CustomerID, CharID, BackpackSlot, ItemID, LeasedUntil, Quantity)
  99. values (@in_CustomerID, @CharID, 1, 101306, '2020-1-1', 1) -- Flashlight
  100. insert into UsersInventory (CustomerID, CharID, BackpackSlot, ItemID, LeasedUntil, Quantity)
  101. values (@in_CustomerID, @CharID, 2, 101261, '2020-1-1', 1) -- Bandages
  102. insert into UsersInventory (CustomerID, CharID, BackpackSlot, ItemID, LeasedUntil, Quantity)
  103. values (@in_CustomerID, @CharID, 3, 101296, '2020-1-1', 1) -- Can of Soda
  104. insert into UsersInventory (CustomerID, CharID, BackpackSlot, ItemID, LeasedUntil, Quantity)
  105. values (@in_CustomerID, @CharID, 4, 101289, '2020-1-1', 1) -- Granola Bar
  106. -- new inventory give out only for char id 1
  107. if(@CharsCreated = 1) begin
  108. insert into UsersInventory (CustomerID, ItemID, LeasedUntil, Quantity)
  109. values (@in_CustomerID, 101088, '2020-1-1', 5) -- M107
  110. insert into UsersInventory (CustomerID, ItemID, LeasedUntil, Quantity)
  111. values (@in_CustomerID, 101247, '2020-1-1', 5) -- Blazer
  112. insert into UsersInventory (CustomerID, ItemID, LeasedUntil, Quantity)
  113. values (@in_CustomerID, 101084, '2020-1-1', 20) -- vss
  114. insert into UsersInventory (CustomerID, ItemID, LeasedUntil, Quantity)
  115. values (@in_CustomerID, 101087, '2020-1-1', 5) -- awm
  116. insert into UsersInventory (CustomerID, ItemID, LeasedUntil, Quantity)
  117. values (@in_CustomerID, 101262, '2020-1-1', 150) -- bandges dx
  118. insert into UsersInventory (CustomerID, ItemID, LeasedUntil, Quantity)
  119. values (@in_CustomerID, 400016, '2020-1-1', 100) -- stanag 30
  120. insert into UsersInventory (CustomerID, ItemID, LeasedUntil, Quantity)
  121. values (@in_CustomerID, 20016, '2020-1-1', 20) -- custom g
  122. insert into UsersInventory (CustomerID, ItemID, LeasedUntil, Quantity)
  123. values (@in_CustomerID, 20067, '2020-1-1', 20) -- K style NVG
  124. insert into UsersInventory (CustomerID, ItemID, LeasedUntil, Quantity)
  125. values (@in_CustomerID, 20180, '2020-1-1', 20) -- Military ruck
  126. insert into UsersInventory (CustomerID, ItemID, LeasedUntil, Quantity)
  127. values (@in_CustomerID, 101173, '2020-1-1', 50) -- IMI TAR 21
  128. insert into UsersInventory (CustomerID, ItemID, LeasedUntil, Quantity)
  129. values (@in_CustomerID, 101172, '2020-1-1', 50) -- sig 556
  130. end
  131.  
  132. -- end
  133.  
  134. -- Krit give 500XP if first char
  135. if(@CharsCreated = 1) begin
  136. UPDATE UsersChars SET XP = 500 WHERE CharID = @CharID
  137. end
  138.  
  139. -- allow to use postbox on newly created survivors
  140. update UsersChars set GameFlags=1 where CharID=@CharID
  141.  
  142. -- Save to CharsCreateLog
  143. --INSERT INTO CharsCreateLog (CustomerID, CharID, GamerTag) VALUES (@in_CustomerID, @CharID, @in_Gamertag)
  144. INSERT INTO CharsLog (CharMessage, CustomerID, CharID, GamerTag, time) VALUES ('Char Create', @in_CustomerID, @CharID, @in_Gamertag, GETDATE())
  145.  
  146. select 0 as ResultCode
  147. select @CharID as 'CharID'
  148. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement