SQL script

Results 1 to 3 of 3
  1. #1
    Grand Master cata123 is offline
    Grand MasterRank
    Jul 2006 Join Date
    RomaniaLocation
    529Posts

    SQL script

    Hello .
    I need to make a simple SQL script for a job that adds 5 cashshop points every 15 minutes for example (i don`t know sql scripting) .
    I use 1.00.66 GS with OASIS project database and CSPOINTS column at character for cash points.
    The script i don`t know very well sintaxes and all instructions , but i could be like this :
    check memb_stat = 1 online , check player online (this i don`t know where to find) , add 5 points if online.
    Someone have an idea ?


  2. #2
    Kingdom of Shadows [RCZ]ShadowKing is offline
    Grand MasterRank
    Jul 2007 Join Date
    1,644Posts

    Re: SQL script

    You should make it as simply it can be and to don't waste resources and here we go:
    use it only 1 time for each user.How we do this?Simply,introduce it in a stored procedure(WZ_DISCONNECT_MEMB) or use it as a trigger(ex: onlinehours).

    here is an example of trigger that do a similar thing:
    PHP Code:
    USE [MuOnline]
    GO

    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER TRIGGER 
    [dbo].[MembStat_RecordOnlineHoursON [dbo].[MEMB_STAT]
    AFTER UPDATE
    AS
    declare @
    memb___id varchar(10)
    declare @
    connectstat tinyint
    SELECT 
    @memb___id=memb___id,@connectstat=connectstat FROM INSERTED
    IF (@connectstat 0
    BEGIN
    UPDATE 
    [dbo].[MEMB_STAT]
     
    SET OnlineHours OnlineHours datediff(hourConnectTMgetdate()) 
     
    WHERE memb___id = @memb___id
    END 
    it update the online hours and you can modify it to add the points too,just need to debug it a little.

  3. #3
    Grand Master cata123 is offline
    Grand MasterRank
    Jul 2006 Join Date
    RomaniaLocation
    529Posts

    Re: SQL script

    finished :

    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_NULLS ON
    GO

    ALTER TRIGGER [dbo].[MembStat_RecordOnlineHours] ON [dbo].[MEMB_STAT]
    AFTER UPDATE
    AS
    declare @memb___id varchar(10)
    declare @connectstat tinyint
    declare @OnlineHours int
    SELECT @memb___id=memb___id,@connectstat=connectstat FROM INSERTED
    IF (@connectstat = 0)
    BEGIN
    UPDATE [dbo].[MEMB_STAT]
    SET OnlineHours = OnlineHours + datediff(hour, ConnectTM, getdate()),@OnlineHours=OnlineHours
    WHERE memb___id = @memb___id
    UPDATE [dbo].[MEMB_INFO]
    SET cspoints=cspoints + (@OnlineHours * 10)
    WHERE memb___id = @memb___id
    END
    Last edited by cata123; 02-08-09 at 02:02 PM.



Advertisement