-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTF2Pug.sql
137 lines (134 loc) · 4.13 KB
/
TF2Pug.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
USE [TF2Pug]
GO
/****** Object: Table [dbo].[Servers] Script Date: 08/21/2011 10:59:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Servers](
[UniqueId] [uniqueidentifier] NOT NULL,
[Address] [nvarchar](255) NOT NULL,
[Port] [int] NULL,
[Password] [nvarchar](50) NOT NULL,
[RconPassword] [nvarchar](50) NOT NULL,
[FriendlyName] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_Servers] PRIMARY KEY CLUSTERED
(
[UniqueId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[PUGs] Script Date: 08/21/2011 10:59:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PUGs](
[UniqueId] [uniqueidentifier] NOT NULL,
[MapId] [uniqueidentifier] NOT NULL,
[BluScore] [tinyint] NOT NULL,
[RedScore] [tinyint] NOT NULL,
[Started] [datetime] NOT NULL,
CONSTRAINT [PK_PUGs] PRIMARY KEY CLUSTERED
(
[UniqueId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[PugPlayers] Script Date: 08/21/2011 10:59:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PugPlayers](
[PugId] [uniqueidentifier] NOT NULL,
[PlayerId] [nvarchar](255) NOT NULL,
[PlayerClass] [tinyint] NOT NULL,
CONSTRAINT [PK_PugPlayers] PRIMARY KEY CLUSTERED
(
[PugId] ASC,
[PlayerId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Players] Script Date: 08/21/2011 10:59:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Players](
[Id] [nvarchar](255) NOT NULL,
[Name] [nvarchar](255) NOT NULL,
CONSTRAINT [PK_Players] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[Maps] Script Date: 08/21/2011 10:59:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Maps](
[UniqueId] [uniqueidentifier] NOT NULL,
[Name] [nvarchar](50) NOT NULL,
[FriendlyName] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_Maps] PRIMARY KEY CLUSTERED
(
[UniqueId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: StoredProcedure [dbo].[sp_ReportScore] Script Date: 08/21/2011 10:59:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[sp_ReportScore]
@PugId uniqueidentifier,
@BluScore tinyint,
@RedScore tinyint
AS
BEGIN
SET NOCOUNT ON;
IF (SELECT COUNT(1) FROM PUGs WHERE UniqueId = @PugId AND BluScore = 0 AND RedScore = 0) > 0
BEGIN
UPDATE PUGs SET BluScore = @BluScore, RedScore = @RedScore WHERE UniqueId = @PugId;
END
END
GO
/****** Object: StoredProcedure [dbo].[sp_AddPlayerToPug] Script Date: 08/21/2011 10:59:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[sp_AddPlayerToPug]
@PugId uniqueidentifier,
@PlayerId nvarchar(255),
@PlayerName nvarchar(255),
@PlayerClass tinyint
AS
BEGIN
SET NOCOUNT ON;
IF (SELECT COUNT(1) FROM Players WHERE [Id] = @PlayerId) = 0
BEGIN
INSERT INTO Players ([Id], Name) VALUES (@PlayerId, @PlayerName);
END
ELSE IF (SELECT COUNT(1) FROM Players WHERE [Id] = @PlayerId AND Name = @PlayerName) = 0
BEGIN
UPDATE Players SET Name = @PlayerName WHERE [Id] = @PlayerId;
END
INSERT INTO PugPlayers (PugId, PlayerId, PlayerClass) VALUES (@PugId, @PlayerId, @PlayerClass);
END
GO