Code:
USE [Kal_db]
GO
/****** Object: StoredProcedure [dbo].[CreatePlayer] Script Date: 10/06/2013 15:46:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[CreatePlayer]
@uid int,
@name varchar(14),
@class tinyint,
@strength tinyint,
@health tinyint,
@intelligence tinyint,
@wisdom tinyint,
@dexterity tinyint,
@curhp smallint,
@curmp smallint,
@map tinyint,
@x int,
@y int,
@z int,
@face tinyint,
@hair tinyint
AS
DECLARE @PID int
DECLARE @GM int
DECLARE @globalgm int
DECLARE @itemid int
DECLARE @startitems int
DECLARE @knightx int
DECLARE @knighty int
DECLARE @knightz int
DECLARE @knightm int
DECLARE @magex int
DECLARE @magey int
DECLARE @magez int
DECLARE @magem int
DECLARE @archerx int
DECLARE @archery int
DECLARE @archerz int
DECLARE @archerm int
DECLARE @theifx int
DECLARE @theify int
DECLARE @theifz int
DECLARE @theifm int
--***************************************
SET @startitems = 1 --set to 0 to disable
--Knight*********************************
SET @knightx = 277091 -- X Coord
SET @knighty = 267423 -- Y Coord
SET @knightz = 39870 -- Z Coord
SET @knightm = 0 -- MAP, 0 for normal world
--Mage***********************************
SET @magex = 277118 -- X Coord
SET @magey = 267406 -- Y Coord
SET @magez = 39870 -- Z Coord
SET @magem = 0 -- MAP, 0 for normal world
--Archer*********************************
SET @archerx = 277138 -- X Coord
SET @archery = 267371 -- Y Coord
SET @archerz = 39870 -- Z Coord
SET @archerm = 0 -- MAP, 0 for normal world
--Theif**********************************
SET @theifx = 277138 -- X Coord
SET @theify = 267371 -- Y Coord
SET @theifz = 39870 -- Z Coord
SET @theifm = 0 -- MAP, 0 for normal world
--***************************************
--Start Koordinates für jedes Klasse extra zuweisen
IF (@Class = 0) --knight
begin
Set @x = @knightx
Set @y = @knighty
Set @z = @knightz
Set @map = @knightm
end
ELSE IF (@Class = 1) --mage
begin
Set @x = @magex
Set @y = @magey
Set @z = @magez
Set @map = @magem
end
ELSE IF (@Class = 2) --archer
begin
Set @x = @archerx
Set @y = @archery
Set @z = @archerz
Set @map = @archerm
end
ELSE IF (@Class = 3) --theif
begin
Set @x = @theifx
Set @y = @theify
Set @z = @theifz
Set @map = @theifm
end
--Global Gamemaster, liest Admin in Login Table
SET @globalgm = (SELECT [Admin] FROM kal_auth.dbo.Login WHERE [UID] = @UID)
IF (@globalgm > 1)
begin
--SET @Name = "[GM]" + @name --Benötigt relog und gibt fehler
SET @GM = @globalgm
end
ELSE
begin
SET @GM = 0
end
--Charakter erstellen
begin
INSERT INTO Player ( [UID], [Admin], [Name], [Class], [Strength], [Health], [Intelligence], [Wisdom], [Dexterity], [CurHP], [CurMP], [Map], [X], [Y], [Z], [Face], [Hair]) VALUES ( @UID, @GM, @Name, @Class, @Strength, @Health, @Intelligence, @Wisdom, @Dexterity, @CurHP, @CurMP, @map, @x, @y, @z, @Face, @Hair)
end
--Jeder Klasse eigene Items geben
IF (@startitems = 1)
begin
SET @PID = (select max([PID]) from Player WHERE [UID] = @UID)
SET @itemid =(select max([IID]) from Item)
--common items
IF (@itemid >= 1000000)
begin
SET @itemid =(select max([IID]) from Item) + 1
end
ELSE
begin
SET @itemid = 1000000
end
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 16, 0, 128, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 18, 0, 128, 200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 20, 0, 128, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
IF (@Class = 0) --knight
begin
--weapon
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
--armor
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
--accessoires und animal
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
end
ELSE IF (@Class = 1) --mage
begin
--weapon
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
--armor
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
--accessoires und animal
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
end
ELSE IF (@Class = 2) --archer
begin
--weapon
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
--armor
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
--accessoires und animal
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
end
ELSE IF (@Class = 3) --theif
begin
--weapon
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
--armor
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
--accessoires und animal
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
SET @itemid = @itemid + 1
INSERT INTO Item ( [PID], [IID], [Index], [Prefix], [Info], [Num], [MaxEnd], [CurEnd], [SetGem], [XAttack], [XMagic], [XDefense], [XHit], [XDodge], [Protect], [UpgrLevel], [UpgrRate]) VALUES ( @PID, @itemid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
end
end