PDA

View Full Version : [share] char_name check modification SQL


smeli
02.04.2007, 14:48
-- place this script to SQL function: "lin_CreateChar"
-- after this code of blank space checking:
IF @char_name LIKE N' '
BEGIN
RAISERROR ('Character name has space : name = [%s]', 16, 1, @char_name)
RETURN -1
END
-- and your server will get less weird names :D



-- check lenght

if Len(@char_name)< 3
BEGIN
RAISERROR ('Character name too short : name = [%s]', 16, 1, @char_name)
RETURN -1
END

-- check for invalid characters
DECLARE @r Int
SET @r = 0
SELECT @r = 1 WHERE @char_name LIKE '%[^a-z]%'
if @r = 1
BEGIN
RAISERROR ('Character have invalid characters : name = [%s]', 16, 1, @char_name)
RETURN -1
END

-- check for repeating x3 letters

/* 3. check for repeats x3 */
DECLARE
@Position Int,
@Counter Int,
@SearchString Varchar(255),
@SearchFor1 Varchar(255),
@SearchFor2 Varchar(255),
@SearchFor3 Varchar(255)

SET @SearchString = @char_name
Set @Position = 3
Set @Counter = 0
SET @SearchFor1 = 'W'
SET @SearchFor2 = SUBSTRING(@SearchString,1,1)
SET @SearchFor3 = SUBSTRING(@SearchString,2,1)

While @Position <= Len(@SearchString)
Begin
SET @SearchFor1=@SearchFor2
SET @SearchFor2=@SearchFor3
SET @SearchFor3=SUBSTRING(@SearchString,@Position,1)

if @SearchFor1 = @SearchFor2
if @SearchFor2 = @SearchFor3
BEGIN
RAISERROR ('Character have 3 repeating letters : name = [%s]', 16, 1, @char_name)
RETURN -1
END

Select @Position = (@Position + 1)
End

FidoW
02.04.2007, 14:58
Umm , intereseting, looks better than my own :P i have a similar store procedure in my server, in my server isnt possible to create names like ... "XXMageXX" etc etc.. about the invalid characteres.. thats a solution to hlapex charname with moded packets, i forget to do that :D

Thats a good one... thanks smeli.

HF
02.04.2007, 15:18
What checking this store procedure? I dont understund

FidoW
02.04.2007, 17:18
What checking this store procedure? I dont understund

With that SP you cant create chars with less than 3 letters.... and you cant use numbers in the name (thats the only part of the SP i dont like)... and cant create chars with names like... "XXXMageXXX" or... "MysticXXX" or any three identical letters together (lllKinglll, etc).. but the invalid characters code... fix the charname injection packet with hlapex too... i dont know if amped fix that, i think doesnt. In the past with Hlapex you can create chars with name not visible with the client, resulting in .. you cant whisp that player... and i not sure but possible crash others clients when trying to target it.

To modify the invalid characters check to allow numbers only make something like this

Search:
SELECT @r = 1 WHERE @char_name LIKE '%[^a-z]%'

Replace with:
SELECT @r = 1 WHERE @char_name LIKE '%[^a-z0-9]%'