-
Notifications
You must be signed in to change notification settings - Fork 0
/
ragerp.sql
690 lines (629 loc) · 21.1 KB
/
ragerp.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
USE [RageRP]
GO
/****** Object: Table [dbo].[Characters] Script Date: 21/04/2019 02:56:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Characters](
[id] [bigint] IDENTITY(1,1) NOT NULL,
[CharacterName] [varchar](255) NOT NULL,
[Gender] [int] NOT NULL,
[CurrentPed] [varchar](255) NOT NULL,
[Cash] [int] NOT NULL,
[Bank] [int] NOT NULL,
[PedString] [varchar](max) NOT NULL,
[isNewCharacter] [bit] NOT NULL,
[isPolice] [bit] NOT NULL,
[PoliceLevel] [int] NOT NULL,
[isEMS] [bit] NOT NULL,
[EMSLevel] [int] NOT NULL,
CONSTRAINT [PK_Characters] 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] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object: Table [dbo].[CharacterVehicles] Script Date: 21/04/2019 02:56:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CharacterVehicles](
[id] [bigint] IDENTITY(1,1) NOT NULL,
[CharacterID] [bigint] NOT NULL,
[VehicleID] [bigint] NOT NULL,
CONSTRAINT [PK_CharacterVehicles] 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].[DefaultSpawnLocations] Script Date: 21/04/2019 02:56:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DefaultSpawnLocations](
[id] [bigint] IDENTITY(1,1) NOT NULL,
[LocationName] [varchar](max) NOT NULL,
[posX] [decimal](10, 4) NOT NULL,
[posY] [decimal](10, 4) NOT NULL,
[posZ] [decimal](10, 4) NOT NULL,
[lookX] [decimal](10, 4) NOT NULL,
[lookY] [decimal](10, 4) NOT NULL,
[lookZ] [decimal](10, 4) NOT NULL,
[spawnX] [decimal](10, 4) NULL,
[spawnY] [decimal](10, 4) NULL,
[spawnZ] [decimal](10, 4) NULL,
[heading] [decimal](10, 4) NULL,
CONSTRAINT [PK_DefaultSpawnLocations] 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] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object: Table [dbo].[FactionSpawnLocations] Script Date: 21/04/2019 02:56:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[FactionSpawnLocations](
[id] [bigint] IDENTITY(1,1) NOT NULL,
[LocationName] [varchar](max) NOT NULL,
[isPolice] [bit] NOT NULL,
[isEMS] [bit] NOT NULL,
[posX] [decimal](10, 4) NOT NULL,
[posY] [decimal](10, 4) NOT NULL,
[posZ] [decimal](10, 4) NOT NULL,
[lookX] [decimal](10, 4) NOT NULL,
[lookY] [decimal](10, 4) NOT NULL,
[lookZ] [decimal](10, 4) NOT NULL,
[spawnX] [decimal](10, 4) NULL,
[spawnY] [decimal](10, 4) NULL,
[spawnZ] [decimal](10, 4) NULL,
[heading] [decimal](10, 4) NULL,
CONSTRAINT [PK_FactionSpawnLocations] 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] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object: Table [dbo].[PlayerCharacters] Script Date: 21/04/2019 02:56:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PlayerCharacters](
[id] [bigint] IDENTITY(1,1) NOT NULL,
[PlayerID] [bigint] NOT NULL,
[CharacterID] [bigint] NOT NULL,
[isDeleted] [bit] NOT NULL,
CONSTRAINT [PK_PlayerCharacters] 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].[Players] Script Date: 21/04/2019 02:56:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Players](
[id] [bigint] IDENTITY(1,1) NOT NULL,
[PlayerName] [varchar](255) NOT NULL,
[License] [varchar](9) NOT NULL,
[DateCreated] [datetime] NOT NULL,
[isAdmin] [bit] NOT NULL,
[AdminLevel] [int] NOT NULL,
[Password] [varchar](255) 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].[PlayerWhitelist] Script Date: 21/04/2019 02:56:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PlayerWhitelist](
[id] [bigint] IDENTITY(1,1) NOT NULL,
[PlayerID] [bigint] NOT NULL,
[License] [varchar](255) NOT NULL,
[isWhitelisted] [bit] NOT NULL,
CONSTRAINT [PK_PlayerWhitelist] 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].[Vehicles] Script Date: 21/04/2019 02:56:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Vehicles](
[id] [bigint] IDENTITY(1,1) NOT NULL,
[carModel] [varchar](255) NOT NULL,
[colour] [varchar](255) NOT NULL,
[plate] [varchar](255) NOT NULL,
[mods] [varchar](max) NOT NULL,
[inGarage] [bit] NOT NULL,
[trunk] [varchar](max) NOT NULL,
CONSTRAINT [PK_Vehicles] 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] TEXTIMAGE_ON [PRIMARY]
GO
SET IDENTITY_INSERT [dbo].[Characters] OFF
GO
SET IDENTITY_INSERT [dbo].[Characters] OFF
GO
SET IDENTITY_INSERT [dbo].[DefaultSpawnLocations] ON
GO
INSERT [dbo].[DefaultSpawnLocations] ([id], [LocationName], [posX], [posY], [posZ], [lookX], [lookY], [lookZ], [spawnX], [spawnY], [spawnZ], [heading]) VALUES (1, N'Los Santos International', CAST(-1028.1298 AS Decimal(10, 4)), CAST(-2642.2287 AS Decimal(10, 4)), CAST(49.5994 AS Decimal(10, 4)), CAST(-1037.0593 AS Decimal(10, 4)), CAST(-2725.8332 AS Decimal(10, 4)), CAST(26.5260 AS Decimal(10, 4)), CAST(-1038.2340 AS Decimal(10, 4)), CAST(-2738.7620 AS Decimal(10, 4)), CAST(20.1692 AS Decimal(10, 4)), CAST(327.4659 AS Decimal(10, 4)))
GO
INSERT [dbo].[DefaultSpawnLocations] ([id], [LocationName], [posX], [posY], [posZ], [lookX], [lookY], [lookZ], [spawnX], [spawnY], [spawnZ], [heading]) VALUES (2, N'Portola Drive Station', CAST(-891.8143 AS Decimal(10, 4)), CAST(-84.5571 AS Decimal(10, 4)), CAST(64.9400 AS Decimal(10, 4)), CAST(-890.5471 AS Decimal(10, 4)), CAST(-85.1643 AS Decimal(10, 4)), CAST(64.4115 AS Decimal(10, 4)), CAST(-832.6562 AS Decimal(10, 4)), CAST(-101.1316 AS Decimal(10, 4)), CAST(28.1854 AS Decimal(10, 4)), CAST(234.7200 AS Decimal(10, 4)))
GO
SET IDENTITY_INSERT [dbo].[DefaultSpawnLocations] OFF
GO
SET IDENTITY_INSERT [dbo].[FactionSpawnLocations] ON
GO
INSERT [dbo].[FactionSpawnLocations] ([id], [LocationName], [isPolice], [isEMS], [posX], [posY], [posZ], [lookX], [lookY], [lookZ], [spawnX], [spawnY], [spawnZ], [heading]) VALUES (1, N'Davis Fire Station', 0, 1, CAST(212.6069 AS Decimal(10, 4)), CAST(-1612.6430 AS Decimal(10, 4)), CAST(44.9114 AS Decimal(10, 4)), CAST(208.4230 AS Decimal(10, 4)), CAST(-1639.9932 AS Decimal(10, 4)), CAST(35.3026 AS Decimal(10, 4)), CAST(663.1050 AS Decimal(10, 4)), CAST(-71.8925 AS Decimal(10, 4)), CAST(38.5825 AS Decimal(10, 4)), CAST(26.8565 AS Decimal(10, 4)))
GO
INSERT [dbo].[FactionSpawnLocations] ([id], [LocationName], [isPolice], [isEMS], [posX], [posY], [posZ], [lookX], [lookY], [lookZ], [spawnX], [spawnY], [spawnZ], [heading]) VALUES (2, N'Rockford Hills Fire Station', 0, 1, CAST(-685.7616 AS Decimal(10, 4)), CAST(-50.6085 AS Decimal(10, 4)), CAST(78.8487 AS Decimal(10, 4)), CAST(-651.2114 AS Decimal(10, 4)), CAST(-87.3439 AS Decimal(10, 4)), CAST(47.4825 AS Decimal(10, 4)), CAST(199.7348 AS Decimal(10, 4)), CAST(-1646.9070 AS Decimal(10, 4)), CAST(29.8032 AS Decimal(10, 4)), CAST(241.0663 AS Decimal(10, 4)))
GO
INSERT [dbo].[FactionSpawnLocations] ([id], [LocationName], [isPolice], [isEMS], [posX], [posY], [posZ], [lookX], [lookY], [lookZ], [spawnX], [spawnY], [spawnZ], [heading]) VALUES (3, N'El Burro Heights Fire Station', 0, 1, CAST(1169.0413 AS Decimal(10, 4)), CAST(-1415.9796 AS Decimal(10, 4)), CAST(63.0675 AS Decimal(10, 4)), CAST(1192.2167 AS Decimal(10, 4)), CAST(-1471.5539 AS Decimal(10, 4)), CAST(39.7405 AS Decimal(10, 4)), CAST(1194.2050 AS Decimal(10, 4)), CAST(-1473.9360 AS Decimal(10, 4)), CAST(34.8595 AS Decimal(10, 4)), CAST(275.6947 AS Decimal(10, 4)))
GO
INSERT [dbo].[FactionSpawnLocations] ([id], [LocationName], [isPolice], [isEMS], [posX], [posY], [posZ], [lookX], [lookY], [lookZ], [spawnX], [spawnY], [spawnZ], [heading]) VALUES (4, N'Davis Sheriff''s Station', 1, 0, CAST(428.8711 AS Decimal(10, 4)), CAST(-1604.3663 AS Decimal(10, 4)), CAST(47.2069 AS Decimal(10, 4)), CAST(384.4632 AS Decimal(10, 4)), CAST(-1609.8959 AS Decimal(10, 4)), CAST(29.1691 AS Decimal(10, 4)), CAST(369.8974 AS Decimal(10, 4)), CAST(-1608.5320 AS Decimal(10, 4)), CAST(29.2919 AS Decimal(10, 4)), CAST(238.2178 AS Decimal(10, 4)))
GO
INSERT [dbo].[FactionSpawnLocations] ([id], [LocationName], [isPolice], [isEMS], [posX], [posY], [posZ], [lookX], [lookY], [lookZ], [spawnX], [spawnY], [spawnZ], [heading]) VALUES (5, N'Mission Row Police Station', 1, 0, CAST(401.6901 AS Decimal(10, 4)), CAST(-949.1757 AS Decimal(10, 4)), CAST(54.2695 AS Decimal(10, 4)), CAST(433.5852 AS Decimal(10, 4)), CAST(-984.1002 AS Decimal(10, 4)), CAST(34.6233 AS Decimal(10, 4)), CAST(458.6651 AS Decimal(10, 4)), CAST(-993.3438 AS Decimal(10, 4)), CAST(30.6896 AS Decimal(10, 4)), CAST(41.7385 AS Decimal(10, 4)))
GO
INSERT [dbo].[FactionSpawnLocations] ([id], [LocationName], [isPolice], [isEMS], [posX], [posY], [posZ], [lookX], [lookY], [lookZ], [spawnX], [spawnY], [spawnZ], [heading]) VALUES (6, N'Vespucci Police Station', 1, 0, CAST(-1102.7290 AS Decimal(10, 4)), CAST(-755.0809 AS Decimal(10, 4)), CAST(47.4706 AS Decimal(10, 4)), CAST(-1092.8710 AS Decimal(10, 4)), CAST(-812.6923 AS Decimal(10, 4)), CAST(30.2643 AS Decimal(10, 4)), CAST(-1118.5350 AS Decimal(10, 4)), CAST(-845.7151 AS Decimal(10, 4)), CAST(13.3825 AS Decimal(10, 4)), CAST(123.0584 AS Decimal(10, 4)))
GO
INSERT [dbo].[FactionSpawnLocations] ([id], [LocationName], [isPolice], [isEMS], [posX], [posY], [posZ], [lookX], [lookY], [lookZ], [spawnX], [spawnY], [spawnZ], [heading]) VALUES (7, N'Vinewood Police Station', 1, 0, CAST(693.2681 AS Decimal(10, 4)), CAST(-5.4895 AS Decimal(10, 4)), CAST(106.6995 AS Decimal(10, 4)), CAST(636.3175 AS Decimal(10, 4)), CAST(-4.8682 AS Decimal(10, 4)), CAST(85.2924 AS Decimal(10, 4)), CAST(639.7669 AS Decimal(10, 4)), CAST(0.4571 AS Decimal(10, 4)), CAST(82.7864 AS Decimal(10, 4)), CAST(238.6315 AS Decimal(10, 4)))
GO
SET IDENTITY_INSERT [dbo].[FactionSpawnLocations] OFF
GO
SET IDENTITY_INSERT [dbo].[PlayerCharacters] ON
GO
INSERT [dbo].[PlayerCharacters] ([id], [PlayerID], [CharacterID], [isDeleted]) VALUES (1, 1, 1, 0)
GO
INSERT [dbo].[PlayerCharacters] ([id], [PlayerID], [CharacterID], [isDeleted]) VALUES (2, 1, 2, 0)
GO
SET IDENTITY_INSERT [dbo].[PlayerCharacters] OFF
GO
SET IDENTITY_INSERT [dbo].[Players] OFF
GO
SET IDENTITY_INSERT [dbo].[Players] OFF
GO
SET IDENTITY_INSERT [dbo].[PlayerWhitelist] OFF
GO
SET IDENTITY_INSERT [dbo].[PlayerWhitelist] OFF
GO
ALTER TABLE [dbo].[Characters] ADD CONSTRAINT [DF_Characters_isPolice] DEFAULT ((0)) FOR [isPolice]
GO
ALTER TABLE [dbo].[Characters] ADD CONSTRAINT [DF_Characters_PoliceLevel] DEFAULT ((0)) FOR [PoliceLevel]
GO
ALTER TABLE [dbo].[Characters] ADD CONSTRAINT [DF_Characters_isEMS] DEFAULT ((0)) FOR [isEMS]
GO
ALTER TABLE [dbo].[Characters] ADD CONSTRAINT [DF_Characters_EMSLevel] DEFAULT ((0)) FOR [EMSLevel]
GO
ALTER TABLE [dbo].[FactionSpawnLocations] ADD CONSTRAINT [DF_FactionSpawnLocations_isPolice] DEFAULT ((0)) FOR [isPolice]
GO
ALTER TABLE [dbo].[FactionSpawnLocations] ADD CONSTRAINT [DF_FactionSpawnLocations_isEMS] DEFAULT ((0)) FOR [isEMS]
GO
ALTER TABLE [dbo].[Vehicles] ADD CONSTRAINT [DF_Vehicles_mods] DEFAULT ('{}') FOR [mods]
GO
ALTER TABLE [dbo].[Vehicles] ADD CONSTRAINT [DF_Vehicles_Trunk] DEFAULT ('{}') FOR [trunk]
GO
/****** Object: StoredProcedure [dbo].[spu_CheckIfWhitelisted] Script Date: 21/04/2019 02:56:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
* Last Edited: Kieran - 26/03/2019 13:04
* ChangeLog:
*
* 26/03/2019 13:04 - Kieran
* Created Procedure
*/
CREATE PROCEDURE [dbo].[spu_CheckIfWhitelisted]
@License varchar(255)
AS
BEGIN
SELECT * FROM PlayerWhitelist WHERE License = @License
END
GO
/****** Object: StoredProcedure [dbo].[spu_DeleteCharacter] Script Date: 21/04/2019 02:56:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
* Last Edited: Kieran - 07/04/2019 01:24
* ChangeLog:
*
* 07/04/2019 01:24 - Kieran
* Created Procedure
*/
CREATE PROCEDURE [dbo].[spu_DeleteCharacter]
@PlayerID bigint,
@CharacterID bigint
AS
BEGIN
UPDATE PlayerCharacters
SET isDeleted = 1
WHERE id = @CharacterID AND PlayerID = @PlayerID
END
GO
/****** Object: StoredProcedure [dbo].[spu_GetCharacter] Script Date: 21/04/2019 02:56:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
* Last Edited: Kieran - 27/03/2019 20:20
* ChangeLog:
*
* 27/03/2019 20:20 - Kieran
* Created Procedure
*/
CREATE PROCEDURE [dbo].[spu_GetCharacter]
@CharacterID bigint,
@PlayerID bigint
AS
BEGIN
SELECT c.* FROM Players p
INNER JOIN PlayerCharacters pc on pc.PlayerID = p.id
INNER JOIN Characters c on c.id = pc.CharacterID
WHERE p.id = @PlayerID AND c.id = @CharacterID
END
GO
/****** Object: StoredProcedure [dbo].[spu_GetCharacterVehicles] Script Date: 21/04/2019 02:56:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
* Last Edited: Kieran - 31/03/2019 00:08
* ChangeLog:
*
* 31/03/2019 00:08 - Kieran
* Created Procedure
*/
CREATE PROCEDURE [dbo].[spu_GetCharacterVehicles]
@CharacterID bigint,
@PlayerID bigint
AS
BEGIN
SELECT v.* FROM Players p
INNER JOIN PlayerCharacters pc on pc.PlayerID = p.id
INNER JOIN Characters c on c.id = pc.CharacterID
INNER JOIN CharacterVehicles cv on cv.CharacterID = c.id
INNER JOIN Vehicles v on v.id = cv.VehicleID
WHERE p.id = @PlayerID AND c.id = @CharacterID
END
GO
/****** Object: StoredProcedure [dbo].[spu_GetPlayerBySocialClubName] Script Date: 21/04/2019 02:56:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
* Last Edited: Kieran - 26/03/2019 21:45
* ChangeLog:
*
* 26/03/2019 21:45 - Kieran
* Created Procedure
*/
CREATE PROCEDURE [dbo].[spu_GetPlayerBySocialClubName]
@PlayerName varchar(255)
AS
BEGIN
SELECT * FROM Players WHERE PlayerName = @PlayerName
END
GO
/****** Object: StoredProcedure [dbo].[spu_GetPlayerCharacters] Script Date: 21/04/2019 02:56:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
* Last Edited: Kieran - 07/04/2019 16:18
* ChangeLog:
*
* 07/04/2019 06:18 - Kieran
* Added isDeleted where clause
*
* 26/03/2019 21:46 - Kieran
* Created Procedure
*/
CREATE PROCEDURE [dbo].[spu_GetPlayerCharacters]
@PlayerID bigint
AS
BEGIN
SELECT c.* FROM Players p
INNER JOIN PlayerCharacters pc on pc.PlayerID = p.id
INNER JOIN Characters c on c.id = pc.CharacterID
WHERE p.id = @PlayerID AND pc.isDeleted = 0
END
GO
/****** Object: StoredProcedure [dbo].[spu_GetSpawnLocations] Script Date: 21/04/2019 02:56:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
* Last Edited: Kieran - 21/04/2019 02:50
* ChangeLog:
*
* 21/04/2019 02:50 - Kieran
* Added Logic to get faction Spawn Locations from CharacterID
*
* 20/04/2019 17:16 - Kieran
* Created Procedure
*/
CREATE PROCEDURE [dbo].[spu_GetSpawnLocations]
@CharacterID bigint
AS
BEGIN
DECLARE @isPolice bit
DECLARE @isEMS bit
SELECT @isPolice = isPolice, @isEMS = isEMS FROM Characters WHERE id = @CharacterID;
with #Default (id, LocationName, posX, posY, posZ, lookX, lookY, lookZ, spawnX, spawnY, spawnZ, heading)
AS
(
SELECT CAST('1' + CAST(id AS varchar) AS bigint) AS id, LocationName, posX, posY, posZ, lookX, lookY, lookZ, spawnX, spawnY, spawnZ, heading FROM DefaultSpawnLocations
),
#Faction (id, LocationName, posX, posY, posZ, lookX, lookY, lookZ, spawnX, spawnY, spawnZ, heading)
AS
(
SELECT CAST('2' + CAST(id AS varchar) AS bigint) AS id, LocationName, posX, posY, posZ, lookX, lookY, lookZ, spawnX, spawnY, spawnZ, heading FROM FactionSpawnLocations
WHERE isPolice = @isPolice OR isEMS = @isEMS
),
#Result (id, LocationName, posX, posY, posZ, lookX, lookY, lookZ, spawnX, spawnY, spawnZ, heading)
AS
(
SELECT * FROM #Default
UNION
SELECT * FROM #Faction
)
SELECT * FROM #Result
END
GO
/****** Object: StoredProcedure [dbo].[spu_GetVehicle] Script Date: 21/04/2019 02:56:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
* Last Edited: Kieran - 31/03/2019 00:14
* ChangeLog:
*
* 31/03/2019 00:14 - Kieran
* Created Procedure
*/
CREATE PROCEDURE [dbo].[spu_GetVehicle]
@VehicleID bigint
AS
BEGIN
SELECT * FROM Vehicles WHERE id = @VehicleID
END
GO
/****** Object: StoredProcedure [dbo].[spu_InsertCharacter] Script Date: 21/04/2019 02:56:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
* Last Edited: Kieran - 26/03/2019 13:04
* ChangeLog:
*
* 07/04/2019 21:01 - Kieran
* Changed ClothingString to PedString
*
* 07/04/2019 18:33 - Kieran
* Added isNewCharacter column to Insert Statement
*
* 07/04/2019 01:30 - Kieran
* Added isDeleted column to Insert Statement
*
* 26/03/2019 13:04 - Kieran
* Created Procedure
*/
CREATE PROCEDURE [dbo].[spu_InsertCharacter]
@PlayerID bigint,
@CharacterName varchar(255),
@Gender int,
@CurrentPed varchar(255),
@Cash int,
@Bank int,
@PedString varchar(MAX),
@CharacterID bigint output
AS
BEGIN
INSERT INTO Characters
(CharacterName
,Gender
,CurrentPed
,Cash
,Bank
,PedString
,isNewCharacter)
VALUES
(@CharacterName
,@Gender
,@CurrentPed
,@Cash
,@Bank
,@PedString
,1)
SET @CharacterID = (SELECT SCOPE_IDENTITY())
INSERT INTO PlayerCharacters
(PlayerID, CharacterID, isDeleted)
VALUES
(@PlayerID, @CharacterID, 0)
END
GO
/****** Object: StoredProcedure [dbo].[spu_InsertCharacterVehicle] Script Date: 21/04/2019 02:56:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
* Last Edited: Kieran - 31/03/2019 00:13
* ChangeLog:
*
* 31/03/2019 00:13 - Kieran
* Created Procedure
*/
CREATE PROCEDURE [dbo].[spu_InsertCharacterVehicle]
@CharacterID bigint,
@carModel varchar(255),
@colour varchar(255),
@plate varchar(255),
@VehicleID bigint output
AS
BEGIN
INSERT INTO Vehicles
(carModel
,colour
,plate
,inGarage)
VALUES
(@carModel
,@colour
,@plate
,0)
SET @VehicleID = (SELECT SCOPE_IDENTITY())
INSERT INTO CharacterVehicles
(VehicleID, CharacterID)
VALUES
(@VehicleID, @CharacterID)
END
GO
/****** Object: StoredProcedure [dbo].[spu_InsertPlayer] Script Date: 21/04/2019 02:56:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
* Last Edited: Kieran - 26/03/2019 21:54
* ChangeLog:
*
* 06/03/2019 01:53 - Kieran
* @License is now a random 9 digit number
*
* 31/03/2019 14:34 - Kieran
* Added insert into PlayerWhitelist
*
* 26/03/2019 21:54 - Kieran
* Added isAdmin & AdminLevel
*
* 26/03/2019 21:30 - Kieran
* Added @RefID output
*
* 26/03/2019 13:55 - Kieran
* Added DateCreated
*
* 25/03/2019 22:40 - Kieran
* Created Procedure
*/
CREATE PROCEDURE [dbo].[spu_InsertPlayer]
@PlayerName varchar(255),
@RefID bigint output
AS
BEGIN
DECLARE @License varchar(9) = CAST(convert(numeric(9,0),rand() * 899999999) + 100000000 AS varchar(9))
INSERT INTO Players
(PlayerName, License, DateCreated, isAdmin, AdminLevel)
VALUES
(@PlayerName, @License, getdate(), 0, 0)
SET @RefID = (SELECT SCOPE_IDENTITY())
INSERT INTO PlayerWhitelist
(PlayerID, License, isWhitelisted)
VALUES
(@RefID, @License, 0)
END
GO
/****** Object: StoredProcedure [dbo].[spu_UpdateCharacter] Script Date: 21/04/2019 02:56:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
* Last Edited: Kieran - 20/04/2019 18:27
* ChangeLog:
*
* 20/04/2019 18:27 - Kieran
* Added logic to update the isNewCharacter flag automatically when a character is updated
*
* 20/04/2019 16:48 - Kieran
* Updated Procedure to use the PedString now
*
* 31/03/2019 00:19 - Kieran
* Created Procedure
*/
CREATE PROCEDURE [dbo].[spu_UpdateCharacter]
@CharacterID bigint,
@Gender int,
@CurrentPed varchar(255),
@Cash int,
@Bank int,
@PedString varchar(max)
AS
BEGIN
UPDATE Characters
SET Gender = @Gender
,CurrentPed = @CurrentPed
,Cash = @Cash
,Bank = @Bank
,PedString = @PedString
WHERE id = @CharacterID
DECLARE @isNewCharacter bit = (SELECT isNewCharacter FROM Characters WHERE id = @CharacterID)
IF(@isNewCharacter = 1)
BEGIN
UPDATE Characters
SET isNewCharacter = 0
WHERE id = @CharacterID
END
END
GO
/****** Object: StoredProcedure [dbo].[spu_UpdateVehicle] Script Date: 21/04/2019 02:56:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
* Last Edited: Kieran - 31/03/2019 00:16
* ChangeLog:
*
* 31/03/2019 00:16 - Kieran
* Created Procedure
*/
CREATE PROCEDURE [dbo].[spu_UpdateVehicle]
@VehicleID bigint,
@carModel varchar(255),
@colour varchar(255),
@plate varchar(255),
@mods varchar(MAX),
@inGarage bit,
@trunk varchar(MAX)
AS
BEGIN
UPDATE Vehicles
SET carModel = @carModel
,colour = @colour
,plate = @plate
,mods = @mods
,inGarage = @inGarage
,trunk = @trunk
WHERE id = @VehicleID
END
GO