[Guide] Set Starting Default Level (SQL Trigger)

Page 1 of 2 12 LastLast
Results 1 to 15 of 29
  1. #1
    Apprentice James2930 is offline
    MemberRank
    Mar 2006 Join Date
    MoonLocation
    10Posts

    [Guide] Set Starting Default Level (SQL Trigger)

    A LOT of people have been asking how to set the default level of a new character to 100 (or any level). So here is a MORE EFFECTIVE way to do it...

    HERE ARE THE STEPS...

    1. Open/Login you SQL Server Management Studio
    2. Expand the Databases Group
    3. Expand the RanGame1 Database
    4. Select New Query from the toolbar
    5. From the New Query window on the right pane, copy and paste this SQL Trigger Code...
    Code:
    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go
    
    -- =============================================
    -- Author:	James29
    -- Create date: 6/15/2006
    -- Description: Sets the default level of a NEW CHARACTER
    -- =============================================
    CREATE TRIGGER [dbo].[NewChar_Level] ON [dbo].[ChaInfo]
    after update
    as
    BEGIN
    
    Update [ChaInfo] set [ChaInfo].ChaLevel=100
    From Inserted
    Where Inserted.ChaLevel = 1 and [ChaInfo].ChaName=inserted.ChaName
    and [ChaInfo].UserNum =inserted.UserNum
    
    END
    6. Execute the SQL Statement.
    7. Verify if the SQL Trigger is created by Expanding dbo.ChaInfo tables, expand triggers. If you don't see NewChar_Level trigger under Triggers group, try refreshing your display.

    This SQL Trigger has been tested by me and works 100%....

    NOTE:
    This should serve as your BASIC Template for SQL Triggering... You can do a lot of things with this... You could set the initial Stats, Stat Points, Money, Character Exp, Character Inventory, Character Skills etc. of a NEWLY CREATED CHARACTER... You would just have to be creative and update the SQL Trigger to suit your needs...


    I hope this helps you...
    Last edited by James2930; 14-06-06 at 09:24 PM.


  2. #2
    Account Upgraded | Title Enabled! livewirecebu is offline
    MemberRank
    Jul 2004 Join Date
    PhilippinesLocation
    851Posts
    can I use this trigger on my MSSQL 2000?

  3. #3
    Apprentice James2930 is offline
    MemberRank
    Mar 2006 Join Date
    MoonLocation
    10Posts
    Quote Originally Posted by livewirecebu
    can I use this trigger on my MSSQL 2000?
    Yeah...

    The steps are almost the same...

    Just copy and paste the code... no edit necessary...

    PS: Did you know that MUServer uses SQL triggers in the database as well...
    Try to check the SQL Trigger for Character table.... (using 1.02 MX version).
    And MU Database still uses SQL Server 2000 only.

  4. #4
    Account Upgraded | Title Enabled! AMD79 is offline
    MemberRank
    Mar 2006 Join Date
    Sabah, MalaysiaLocation
    290Posts
    Can u teach me how to set all the stats point by default example like all stats starts 5000. TQ.

  5. #5
    Hey I already made it...
    But the skill points are set to 0 and stat points are set to 3...
    How to set the stat points to 300 and the skill points to 100??

  6. #6
    Apprentice James2930 is offline
    MemberRank
    Mar 2006 Join Date
    MoonLocation
    10Posts
    Quote Originally Posted by austhistikated
    Hey I already made it...
    But the skill points are set to 0 and stat points are set to 3...
    How to set the stat points to 300 and the skill points to 100??
    That's very simple, all you need to do is play around with the SQL trigger...

    Modify your SQL Trigger to look like this...

    Code:
    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go
    
    -- =============================================
    -- Author:	James29
    -- Create date: 6/15/2006
    -- Description: Sets the default level of a NEW CHARACTER and Adds 300 Stat Points and 100 Skill points... This trigger will modify the exsiting NewChar_Level trigger.
    -- =============================================
    ALTER TRIGGER [dbo].[NewChar_Level] ON [dbo].[ChaInfo]
    after update
    as
    BEGIN
    
    Update [ChaInfo] set [ChaInfo].ChaLevel=100, [ChaInfo].ChaStRemain = 300, [ChaInfo].ChaSkillPoint = 100
    From Inserted
    Where Inserted.ChaLevel = 1 and [ChaInfo].ChaName=inserted.ChaName
    and [ChaInfo].UserNum =inserted.UserNum
    
    END
    As I noted above, you just need to identify the correct field that you need to update and just add that field in the SQL Trigger... Be Creative....
    Last edited by James2930; 15-06-06 at 10:57 AM.

  7. #7
    Yah...
    Lol thanks...
    I already played with it...
    But it's a bit different from you...
    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go

    -- =============================================
    -- Author: James29
    -- Create date: 6/15/2006
    -- Description: Sets the default level of a NEW CHARACTER
    -- =============================================
    CREATE TRIGGER [dbo].[NewChar_Level] ON [dbo].[ChaInfo]
    after update
    as
    BEGIN

    Update [ChaInfo] set [ChaInfo].ChaLevel=100
    From Inserted
    Where Inserted.ChaLevel = 1 and [ChaInfo].ChaName=inserted.ChaName
    and [ChaInfo].UserNum =inserted.UserNum

    Update [ChaInfo] set [ChaInfo].ChaStRemain = 300
    From Inserted
    Where Inserted.ChaStRemain = 3 and [ChaInfo].ChaName=inserted.ChaName
    and [ChaInfo].UserNum =inserted.UserNum

    Update [ChaInfo] set [ChaInfo].ChaSkillPoint = 100
    From Inserted
    Where Inserted.ChaSkillPoint = 0 and [ChaInfo].ChaName=inserted.ChaName
    and [ChaInfo].UserNum =inserted.UserNum

    END

  8. #8
    Apprentice shakarl14 is offline
    MemberRank
    Jun 2006 Join Date
    RPLocation
    19Posts
    i get this error when i execute the query

    Msg 8197, Level 16, State 4, Procedure NewChar_Level, Line 7
    Object 'dbo.ChaInfo' does not exist or is invalid for this operation.
    :wiggle:

  9. #9
    Apprentice James2930 is offline
    MemberRank
    Mar 2006 Join Date
    MoonLocation
    10Posts
    Quote Originally Posted by shakarl14
    i get this error when i execute the query

    Msg 8197, Level 16, State 4, Procedure NewChar_Level, Line 7
    Object 'dbo.ChaInfo' does not exist or is invalid for this operation.
    :wiggle:
    That is because you did not select RANGAME1 database before you executed the SQL Statement...

    The database you're using must still be "master" database... Change it to RANGAME1.

  10. #10
    Apprentice shakarl14 is offline
    MemberRank
    Jun 2006 Join Date
    RPLocation
    19Posts
    nvm i saw the setting but the problem is still ther ill put apicsou can see
    Last edited by shakarl14; 16-06-06 at 02:45 PM.

  11. #11
    Apprentice James2930 is offline
    MemberRank
    Mar 2006 Join Date
    MoonLocation
    10Posts
    Quote Originally Posted by shakarl14
    hi james is that the one in the settings of obdc
    nope... you'll be able to change the database inside SQL Server Management Studio. Try to follow the steps CAREFULLY...

  12. #12
    Apprentice shakarl14 is offline
    MemberRank
    Jun 2006 Join Date
    RPLocation
    19Posts
    here is the pic
    Attached Thumbnails Attached Thumbnails untitled1.bmp  

  13. #13
    Apprentice James2930 is offline
    MemberRank
    Mar 2006 Join Date
    MoonLocation
    10Posts
    Quote Originally Posted by shakarl14
    here is the pic
    That's because you already Executed the SQL Statement before so it has already created an SQL Trigger named NewChar_Level.

    Executing the SQL Statement twice will produce an error since the trigger you want to create already exists.

    Try to remove the trigger first then you can re-execute the SQL Statement...

    or instead of using "Create Trigger" try to change it to "ALTER TRIGGER"

    Good luck

  14. #14
    Apprentice shakarl14 is offline
    MemberRank
    Jun 2006 Join Date
    RPLocation
    19Posts
    Thank u thank u ^^

  15. #15
    Enthusiast dclubs is offline
    MemberRank
    Jun 2006 Join Date
    ThailandLocation
    38Posts
    Thankyou for ANS



Page 1 of 2 12 LastLast

Advertisement