@work
- Joined
- Jan 26, 2008
- Messages
- 617
- Reaction score
- 39
Hello guys,
Was taking a look at the Auto Item tool designed by cvr in earlier days,
It seems that tool loops through all the char and look for any new entry and then it logs it in and update it.
Well It may cause some latency in character creation and it may become hectic when there are more characters.
I was passing through the possibilities of SQL Triggers and found out that it will be easier to write a trigger to the insert of a new row to the charac0 table.
Here is a sql trigger which worked for me and I was able to get the stuff and skills and what ever i want to have when a new character is created.
m_body0, m_body1, m_body2, m_body3 are the respective m_body field you want to update.
This is just a more efficient way to get the stuffs on character creation.
I hope it will be helpful !
Was taking a look at the Auto Item tool designed by cvr in earlier days,
It seems that tool loops through all the char and look for any new entry and then it logs it in and update it.
Well It may cause some latency in character creation and it may become hectic when there are more characters.
I was passing through the possibilities of SQL Triggers and found out that it will be easier to write a trigger to the insert of a new row to the charac0 table.
Here is a sql trigger which worked for me and I was able to get the stuff and skills and what ever i want to have when a new character is created.
Code:
CREATE TRIGGER newCharCreated ON [dbo].[charac0]
FOR INSERT
AS
declare @m_body0 varchar(4000);
declare @m_body1 varchar(4000);
declare @m_body2 varchar(4000);
declare @m_body3 varchar(4000);
declare @char_type varchar(255);
declare @charName varchar(255);
select @char_type=i.c_sheaderb from inserted i;
select @charName=i.c_id from inserted i;
set @m_body0='';
set @m_body1='';
set @m_body2='';
set @m_body3='';
if (@char_type='0')
update charac0 set m_body = @m_body0 where c_id = @charName;
if (@char_type='1')
update charac0 set m_body = @m_body1 where c_id = @charName;
if (@char_type='2')
update charac0 set m_body = @m_body2 where c_id = @charName;
if (@char_type='3')
update charac0 set m_body = @m_body3 where c_id = @charName;
PRINT 'New Character Creation fired.'
GO
m_body0, m_body1, m_body2, m_body3 are the respective m_body field you want to update.
This is just a more efficient way to get the stuffs on character creation.
I hope it will be helpful !