-- ----------------------------
-- Procedure structure for [WZ_ACCOUNT_CREATE]
-- ----------------------------
ALTER PROCEDURE [dbo].[WZ_ACCOUNT_CREATE]
@in_IP varchar(64),
@in_HardwareID varchar(14),
@in_Email varchar(128),
@in_Password varchar(64),
@in_ReferralID int,
@in_SerialKey varchar(128),
@in_SerialEmail varchar(128)
AS
BEGIN
SET NOCOUNT ON;
--
-- NOTE: add new ResultCodes to updater CUpdater::CreateAccThreadEntry
--
-- check for serial key
--declare [USER=363813]KEY[/USER]ResultCode int = 99
--declare [USER=363813]KEY[/USER]CustomerID int = 99
--declare [USER=777683]Keyser[/USER]ialType int = 99
--exec [BreezeNet].[dbo].[BN_WarZ_SerialGetInfo]
-- @in_SerialKey,
-- @in_SerialEmail,
-- [USER=363813]KEY[/USER]ResultCode out,
-- [USER=363813]KEY[/USER]CustomerID out,
-- [USER=777683]Keyser[/USER]ialType out
--if [USER=363813]KEY[/USER]ResultCode <> 0 or [USER=363813]KEY[/USER]CustomerID > 0) begin
-- select 3 as ResultCode, 'Serial not valid' as ResultMsg;
-- return
--end
declare [USER=777683]Keyser[/USER]ialType int = 0 -- Legend Package
-- check if that account was created and refunded before (status 999)
declare [USER=18171]ReF[/USER]undCustomerID int = 0
select [USER=18171]ReF[/USER]undCustomerID=CustomerID from Accounts WHERE email=@in_Email and AccountStatus=999
if [USER=18171]ReF[/USER]undCustomerID > 0) begin
-- change email to some unique one so it can be used again.
declare [USER=27358]date[/USER]Time varchar(128)
set [USER=27358]date[/USER]Time = REPLACE(CONVERT(VARCHAR, GETDATE(),111),'/','') + REPLACE(CONVERT(VARCHAR, GETDATE(),108),':','')
declare [USER=18171]ReF[/USER]undedEmail varchar(128) = '(' + [USER=27358]date[/USER]Time + ') ' + @in_Email
update Accounts set email [USER=18171]ReF[/USER]undedEmail where CustomerID [USER=18171]ReF[/USER]undCustomerID
end
-- validate that email is unique
if exists (SELECT CustomerID from Accounts WHERE email=@in_Email) begin
select 2 as ResultCode, 'Email already in use' as ResultMsg;
return;
end
if exists (SELECT CustomerID from HWID_Log WHERE HardwareID=@in_HardwareID) begin
select 2 as ResultCode, 'HWID is already registered' as ResultMsg;
return;
end
-- create user
declare [USER=858930]MD5[/USER]FromPwd varchar(100)
exec FN_CreateMD5Password @in_Password, [USER=858930]MD5[/USER]FromPwd OUTPUT
INSERT INTO Accounts (
email,
MD5Password,
dateregistered,
ReferralID,
lastlogindate,
lastloginIP
) VALUES (
@in_EMail,
[USER=858930]MD5[/USER]FromPwd,
GETDATE(),
@in_ReferralID,
GETDATE(),
@in_IP
)
-- get new CustomerID
declare [USER=25895]Custom[/USER]erID int
SELECT [USER=25895]Custom[/USER]erID=CustomerID from Accounts where email=@in_Email
-- create all needed user tables
INSERT INTO UsersData (
CustomerID,
AccountType,
dateregistered
) VALUES (
[USER=25895]Custom[/USER]erID,
[USER=777683]Keyser[/USER]ialType,
GETDATE()
)
-- guest accounts have 48hrs play time (sync with WZ_ACCOUNT_APPLYKEY also)
if [USER=777683]Keyser[/USER]ialType = 3) begin
declare [USER=27358]date[/USER]ActiveUntil datetime = DATEADD(hour, 48, GETDATE())
update UsersData set DateActiveUntil [USER=27358]date[/USER]ActiveUntil where CustomerID [USER=25895]Custom[/USER]erID
end
-- register CustomerID in BreezeNet
exec [BreezeNet].[dbo].[BN_WarZ_SerialSetCustomerID] @in_SerialKey, [USER=25895]Custom[/USER]erID
-- default items and bonuses for account types
exec FN_AddItemToUser [USER=25895]Custom[/USER]erID, 20174, 2000 -- hero: regular guy
-- CBT TEST HEROES
exec FN_AddItemToUser [USER=25895]Custom[/USER]erID, 20182, 2000
exec FN_AddItemToUser [USER=25895]Custom[/USER]erID, 20184, 2000
-- 10 of each
--declare @i int = 0
--while(@i < 10) begin
-- set @i = @i + 1
-- exec FN_AddItemToUser [USER=25895]Custom[/USER]erID, 101306, 2000 -- Flashlight
-- exec FN_AddItemToUser [USER=25895]Custom[/USER]erID, 101261, 2000 -- Bandages
-- exec FN_AddItemToUser [USER=25895]Custom[/USER]erID, 101296, 2000 -- Can of Soda
-- exec FN_AddItemToUser [USER=25895]Custom[/USER]erID, 101289, 2000 -- Granola Bar
--end
-- BONUSES for packages - do not forget to sync them with [WZ_ACCOUNT_APPLYKEY]
if [USER=777683]Keyser[/USER]ialType = 0) begin
-- legend package, 30$ 1GC=142
update UsersData set GamePoints=(GamePoints+4260) where CustomerID [USER=25895]Custom[/USER]erID
end
if [USER=777683]Keyser[/USER]ialType = 1) begin
-- pioneer package, 15$ 1GC=142
update UsersData set GamePoints=(GamePoints+2139) where CustomerID [USER=25895]Custom[/USER]erID
end
-- success
select 0 as ResultCode
select [USER=25895]Custom[/USER]erID as CustomerID, [USER=777683]Keyser[/USER]ialType as 'AccountType'
return
END