Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1.  
  2. -- ----------------------------
  3. -- Procedure structure for [WZ_CharCreate]
  4. -- ----------------------------
  5.  
  6. ALTER PROCEDURE [dbo].[WZ_CharCreate]
  7. @in_CustomerID int,
  8. @in_Hardcore int,
  9. @in_Gamertag nvarchar(64),
  10. @in_HeroItemID int,
  11. @in_HeadIdx int,
  12. @in_BodyIdx int,
  13. @in_LegsIdx int
  14. AS
  15. BEGIN
  16. SET NOCOUNT ON;
  17.  
  18. if(@in_Gamertag like '%' + char(32) + '%') begin
  19. select 9 as ResultCode, 'no space in name' as ResultMsg
  20. return
  21. end
  22.  
  23. if(@in_Gamertag like '%sergey%titov%') begin
  24. select 9 as ResultCode, 'no impersonation' as ResultMsg
  25. return
  26. end
  27.  
  28. if(@in_Gamertag like '%titov%sergey%') begin
  29. select 9 as ResultCode, 'no impersonation' as ResultMsg
  30. return
  31. end
  32.  
  33. if(@in_Gamertag like '%\[dev\]%' escape '\') begin
  34. select 9 as ResultCode, 'no dev' as ResultMsg
  35. return
  36. end
  37.  
  38. -- check if gamertag is unique
  39. if exists (select CharID from UsersChars where Gamertag=@in_Gamertag)
  40. begin
  41. select 9 as ResultCode, 'Gamertag already exists' as ResultMsg
  42. return
  43. end
  44.  
  45. -- we can't have more that 5 survivors
  46. declare @NumChars int = 0
  47. select @NumChars=COUNT(*) from UsersChars where CustomerID=@in_CustomerID
  48. if(@NumChars >= 5) begin
  49. select 6 as ResultCode, 'too many created chars' as ResultMsg
  50. return
  51. end
  52.  
  53. insert into UsersChars (
  54. CustomerID,
  55. Gamertag,
  56. Alive,
  57. Hardcore,
  58. HeroItemID,
  59. HeadIdx,
  60. BodyIdx,
  61. LegsIdx,
  62. BackpackID,
  63. BackpackSize,
  64. SkillID0,
  65. SkillID1,
  66. SkillID2,
  67. SkillID3,
  68. SkillID4,
  69. SkillID5,
  70. SkillID6,
  71. SkillID7,
  72. SkillID8,
  73. SkillID9,
  74. SkillID10,
  75. SkillID11,
  76. SkillID12,
  77. SkillID13,
  78. SkillID14,
  79. SkillID15,
  80. SkillID16,
  81. SkillID17,
  82. SkillID18,
  83. SkillID19,
  84. SkillID20,
  85. SkillID21,
  86. SkillID22,
  87. SkillID23,
  88. SkillID24,
  89. SkillID25,
  90. SkillID26,
  91. SkillID27,
  92. SkillID28,
  93. SkillID29,
  94. SkillID30,
  95. SkillID31,
  96. SkillID32,
  97. SkillID33,
  98. CreateDate
  99. ) values (
  100. @in_CustomerID,
  101. @in_Gamertag,
  102. 3,
  103. @in_Hardcore,
  104. @in_HeroItemID,
  105. @in_HeadIdx,
  106. @in_BodyIdx,
  107. @in_LegsIdx,
  108. 20175,
  109. 16,
  110. 1,
  111. 1,
  112. 1,
  113. 1,
  114. 1,
  115. 1,
  116. 1,
  117. 1,
  118. 1,
  119. 1,
  120. 1,
  121. 1,
  122. 1,
  123. 1,
  124. 1,
  125. 1,
  126. 1,
  127. 1,
  128. 1,
  129. 1,
  130. 1,
  131. 1,
  132. 1,
  133. 1,
  134. 1,
  135. 1,
  136. 1,
  137. 1,
  138. 1,
  139. 1,
  140. 1,
  141. 1,
  142. 1,
  143. 1,
  144. GETDATE()
  145. )
  146. declare @CharID int = SCOPE_IDENTITY()
  147.  
  148. -- give basic items for first few survivors
  149. declare @CharsCreated int = 0
  150. update UsersData set CharsCreated=(CharsCreated+1) where CustomerID=@in_CustomerID
  151. select @CharsCreated=CharsCreated from UsersData where CustomerID=@in_CustomerID
  152. if(@CharsCreated <= 5) begin
  153. -- add some default items - BE ULTRA CAREFUL with BackpackSlot number
  154. insert into UsersInventory (CustomerID, CharID, BackpackSlot, ItemID, LeasedUntil, Quantity)
  155. values (@in_CustomerID, @CharID, 1, 101306, '2020-1-1', 1) -- Flashlight
  156. insert into UsersInventory (CustomerID, CharID, BackpackSlot, ItemID, LeasedUntil, Quantity)
  157. values (@in_CustomerID, @CharID, 2, 101261, '2020-1-1', 1) -- Bandages
  158. insert into UsersInventory (CustomerID, CharID, BackpackSlot, ItemID, LeasedUntil, Quantity)
  159. values (@in_CustomerID, @CharID, 3, 101304, '2020-1-1', 1) -- Kit Medical
  160. insert into UsersInventory (CustomerID, CharID, BackpackSlot, ItemID, LeasedUntil, Quantity)
  161. values (@in_CustomerID, @CharID, 4, 101289, '2020-1-1', 1) -- Granola Bar
  162. insert into UsersInventory (CustomerID, CharID, BackpackSlot, ItemID, LeasedUntil, Quantity)
  163. values (@in_CustomerID, @CharID, 5, 101267, '2020-1-1', 1) -- Tac Knife
  164. -- insert into UsersInventory (CustomerID, CharID, BackpackSlot, ItemID, LeasedUntil, Quantity)
  165. -- values (@in_CustomerID, @CharID, 6, 20175, '2020-1-1', 1) -- Med Backpack
  166. end
  167.  
  168. -- allow to use postbox on newly created survivors
  169. update UsersChars set GameFlags=1 where CharID=@CharID
  170.  
  171. select 0 as ResultCode
  172. select @CharID as 'CharID'
  173. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement