Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 server crashing when logging in again

Author  Topic 

Lifurium
Starting Member

2 Posts

Posted - 2012-08-27 : 09:48:05
Hello everyone! (sorry if my english is a bit bad...)

I only just recently started toying with all of this programming stuff, so I'm not quite sure on how to fix a minor problem i seem to have with the communication between the server and the client.

when i start up the server, players are able to connect and log out when they are done playing without any problems, but only if they log in on a new character.
as soon as people start login on a character that HAVE been in-game before, the server crashes after about 5 minuts, or just when they logout.
as said I'm no expert, but it's almost as if the server/client cant communicate properly with dbo.players table :/
any help would be appriciated! thank you

Again, sorry for the bad english

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-08-27 : 09:58:18
Suspect it's something t odo with the processing you are carrying out.
Creating a new character from scratch is probably ok but sounds like something goes wrong when yoou try to recover an old character.
You need to check the code that is executed - could be that something is not being populated and crashes when it is accessed.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Lifurium
Starting Member

2 Posts

Posted - 2012-08-27 : 10:17:17
just not sure on how to see where the problem is located, since I'm new to all this. After all, I was not the one who made the database.
any chance you could take a look? (or tell me if I'm searching the wrong place :))

USE Goose;

CREATE TABLE players (
player_id INT IDENTITY(1,1) NOT NULL,
player_name VARCHAR(50) NOT NULL,
player_title VARCHAR(50) DEFAULT '' NOT NULL,
player_surname VARCHAR(50) DEFAULT '' NOT NULL,
password_hash CHAR(32) NOT NULL,
password_salt VARCHAR(50) NOT NULL,
access_status SMALLINT DEFAULT 2 NOT NULL,
map_id SMALLINT DEFAULT 1 NOT NULL,
map_x SMALLINT DEFAULT 50 NOT NULL,
map_y SMALLINT DEFAULT 50 NOT NULL,
player_facing SMALLINT DEFAULT 2 NOT NULL,
bound_id SMALLINT DEFAULT 1 NOT NULL,
bound_x SMALLINT DEFAULT 50 NOT NULL,
bound_y SMALLINT DEFAULT 50 NOT NULL,
player_gold BIGINT DEFAULT 5000 NOT NULL,
player_level SMALLINT DEFAULT 1 NOT NULL,
experience BIGINT DEFAULT 0 NOT NULL,
experience_sold BIGINT DEFAULT 0 NOT NULL,
player_hp INT DEFAULT 0 NOT NULL,
player_mp INT DEFAULT 0 NOT NULL,
player_sp INT DEFAULT 0 NOT NULL,
class_id SMALLINT DEFAULT 1 NOT NULL,
guild_id SMALLINT DEFAULT 0 NOT NULL,
stat_ac SMALLINT DEFAULT 0 NOT NULL,
stat_str SMALLINT DEFAULT 0 NOT NULL,
stat_sta SMALLINT DEFAULT 0 NOT NULL,
stat_dex SMALLINT DEFAULT 0 NOT NULL,
stat_int SMALLINT DEFAULT 0 NOT NULL,
res_fire SMALLINT DEFAULT 0 NOT NULL,
res_water SMALLINT DEFAULT 0 NOT NULL,
res_spirit SMALLINT DEFAULT 0 NOT NULL,
res_air SMALLINT DEFAULT 0 NOT NULL,
res_earth SMALLINT DEFAULT 0 NOT NULL,
body_id SMALLINT DEFAULT 1 NOT NULL,
face_id SMALLINT DEFAULT 70 NOT NULL,
hair_id SMALLINT DEFAULT 26 NOT NULL,
hair_r SMALLINT DEFAULT 0 NOT NULL,
hair_g SMALLINT DEFAULT 0 NOT NULL,
hair_b SMALLINT DEFAULT 0 NOT NULL,
hair_a SMALLINT DEFAULT 0 NOT NULL,
aether_threshold DECIMAL(9,4) DEFAULT 0 NOT NULL,
toggle_settings BIGINT DEFAULT 0 NOT NULL,

PRIMARY KEY(player_id)
);

CREATE TABLE inventory (
player_id INT NOT NULL,
item_id INT NOT NULL,
slot SMALLINT NOT NULL,
stack INT NOT NULL,
);

SELECT * FROM players;

SELECT * FROM inventory;

CREATE TABLE equipped (
player_id INT NOT NULL,
item_id INT NOT NULL,
slot SMALLINT NOT NULL
);

SELECT * FROM equipped;

CREATE TABLE combinebag (
player_id INT NOT NULL,
item_id INT NOT NULL,
slot SMALLINT NOT NULL,
stack INT NOT NULL
);

DROP TABLE spellbook
CREATE TABLE spellbook (
player_id INT NOT NULL,
spell_id INT NOT NULL,
slot SMALLINT NOT NULL,
last_casted BIGINT DEFAULT 0 NOT NULL
);

GO
DROP PROCEDURE AddPlayerSpells
GO
CREATE PROCEDURE AddPlayerSpells @PlayerName VARCHAR(32) AS

DECLARE @PlayerID INT
DECLARE @PlayerClass INT
DECLARE @PlayerLevel INT
SELECT @PlayerID=player_id, @PlayerClass=class_id, @PlayerLevel=player_level
FROM players WHERE player_name=@PlayerName

DECLARE @SpellClass INT
DECLARE @SpellLevel INT
DECLARE @SpellID INT

DECLARE @Counter INT = 1

DECLARE ClassSpellCursor CURSOR FOR (SELECT class_id, level, spell_id FROM classes_levelup_spells)
OPEN ClassSpellCursor

FETCH NEXT FROM ClassSpellCursor INTO @SpellClass, @SpellLevel, @SpellID
WHILE @@FETCH_STATUS = 0
BEGIN

IF (@PlayerClass = @SpellClass) AND (@PlayerLevel >= @SpellLevel) BEGIN
INSERT INTO spellbook (player_id, spell_id, slot) VALUES (@PlayerID, @SpellID, @Counter)
SET @Counter = @Counter + 1
END

FETCH NEXT FROM ClassSpellCursor INTO @SpellClass, @SpellLevel, @SpellID
END

CLOSE ClassSpellCursor
DEALLOCATE ClassSpellCursor

GO
SELECT (experience+experience_sold) AS exp,player_name,class_id FROM players WHERE access_status=2 ORDER BY exp;

UPDATE players SET experience=experience+experience_sold,experience_sold=0,player_hp=0,player_mp=0 WHERE player_name='Magus'

UPDATE players SET player_level=25,experience=520000,player_gold=50000,class_id=4 WHERE player_name=''

UPDATE players SET player_name='Solo' WHERE player_name='Conflict'

SELECT player_name,(experience + experience_sold) AS expz FROM players WHERE player_level=50 ORDER BY expz DESC
SELECT * FROM players WHERE player_name='Cipher'

EXEC AddPlayerSpells ''

SELECT * FROM inventory WHERE player_id=4 AND slot=30
UPDATE items SET graphic_tile=120048,graphic_equip=11,graphic_r=0,graphic_g=255,graphic_b=0,graphic_a=200,item_name='Stunnah Shades' WHERE item_id=35967

DELETE FROM spellbook WHERE player_id=112 AND slot IN (1,2,3,4,5)

RESTORE DATABASE Goose FROM Disk='I:\gooseserver\20100505GooseBackup' with recovery
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-08-27 : 10:29:59
Have a look at what is executed for a new character and what is executed for an old one.
Do yoou really mean that the server crashes rather than tha client?
Have a look at the error log and see why it is crashing.

I think there's no need for that cursor - could be a single statement

insert spellbook (player_id, spell_id, slot)
select @PlayerID, SpellID, slot = rownumber() over (order by SpellID)
from classes_levelup_spells
where class_id = @PlayerClass
and @PlayerLevel >= level


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -