Advertisement
Guest User

Untitled

a guest
May 28th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 3.33 KB | None | 0 0
  1. USE [lin2world]
  2. GO
  3. /****** Object:  StoredProcedure [dbo].[lin_CreateChar]    Script Date: 05/29/2010 18:26:59 ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. ALTER PROCEDURE [dbo].[lin_CreateChar]
  9. (  
  10. @char_name NVARCHAR(24),  
  11. @account_name NVARCHAR(24),  
  12. @account_id INT,  
  13. @pledge_id INT,  
  14. @builder  TINYINT,  
  15. @gender TINYINT,  
  16. @race  TINYINT,  
  17. @class  TINYINT,  
  18. @world  SMALLINT,  
  19. @xloc  INT,  
  20. @yloc  INT,  
  21. @zloc  INT,  
  22. @HP  FLOAT,  
  23. @MP  FLOAT,  
  24. @SP  INT,  
  25. @Exp  BIGINT,  
  26. @Lev  TINYINT,  
  27. @align  SMALLINT,  
  28. @PK  INT,  
  29. @Duel  INT,  
  30. @PKPardon  INT,  
  31. @FaceIndex   INT = 0,  
  32. @HairShapeIndex  INT = 0,  
  33. @HairColorIndex  INT = 0  
  34. )  
  35. AS  
  36.  
  37. SET NOCOUNT ON  
  38.  
  39. SET @char_name = RTRIM(@char_name)  
  40. DECLARE @char_id int  
  41. SET @char_id = 0  
  42. SET @Lev = 52
  43. SET @Exp = 51262490
  44.  
  45. IF @char_name LIKE N' '  
  46. BEGIN  
  47.  RAISERROR ('Character name has space : name = [%s]', 16, 1, @char_name)  
  48.  RETURN -1  
  49. END  
  50.  
  51. -- check if char name exists
  52. if exists(select char_name from user_data (nolock) where char_name = @char_name)
  53. begin
  54.     RAISERROR ('Character name already exists: name = [%s]', 16, 1, @char_name)
  55.     RETURN -1
  56. end
  57.  
  58. -- check user_prohibit  
  59. if exists(select char_name from user_prohibit (nolock) where char_name = @char_name)  
  60. begin  
  61.  RAISERROR ('Character name is prohibited: name = [%s]', 16, 1, @char_name)  
  62.  RETURN -1  
  63. end  
  64.  
  65. declare @user_prohibit_word nvarchar(20)  
  66. select top 1 @user_prohibit_word = words from user_prohibit_word (nolock) where @char_name like '%' + words + '%'
  67. if @user_prohibit_word is not null  
  68. begin  
  69.  RAISERROR ('Character name has prohibited word: name = [%s], word[%s]', 16, 1, @char_name, @user_prohibit_word)  
  70.  RETURN -1  
  71. end  
  72.  
  73. -- check reserved name  
  74. declare @reserved_name nvarchar(50)  
  75. declare @reserved_account_id int  
  76. select top 1 @reserved_name = char_name, @reserved_account_id = account_id from user_name_reserved (nolock) where used = 0 and char_name = @char_name  
  77. if not @reserved_name is null  
  78. begin  
  79.  if not @reserved_account_id = @account_id  
  80.  begin  
  81.   RAISERROR ('Character name is reserved by other player: name = [%s]', 16, 1, @char_name)  
  82.   RETURN -1  
  83.  end  
  84. end  
  85.  
  86. -- insert user_data  
  87. INSERT INTO user_data  
  88. ( char_name, account_name, account_id, pledge_id, builder, gender, race, class, subjob0_class,
  89. world, xloc, yloc, zloc, HP, MP, max_hp, max_mp, SP, Exp, Lev, align, PK, PKpardon, duel, create_date, face_index, hair_shape_index, hair_color_index )  
  90. VALUES  
  91. (@char_name, @account_name, @account_id, @pledge_id, @builder, @gender, @race, @class, @class,
  92. @world, @xloc, @yloc, @zloc, @HP, @MP, @HP, @MP, @SP, @Exp, @Lev, @align, @PK, @Duel, @PKPardon, GETDATE(), @FaceIndex, @HairShapeIndex, @HairColorIndex)  
  93.  
  94. IF (@@error = 0)  
  95. BEGIN  
  96.  SET @char_id = @@IDENTITY  
  97.  INSERT INTO quest (char_id) VALUES (@char_id)  
  98. END  
  99.  
  100. SELECT @char_id  
  101.  
  102. if @char_id > 0  
  103. begin  
  104.  -- make user_history  
  105.  exec lin_InsertUserHistory @char_name, @char_id, 1, @account_name, NULL  
  106.  if not @reserved_name is null  
  107.   update user_name_reserved set used = 1 where char_name = @reserved_name
  108.  insert user_item(char_id, item_type, amount, enchant, warehouse, eroded, bless, ident, wished, effects, skill, skill_level, bless_new) values(@char_id, 57, 1000000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
  109.  
  110. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement