Re: Query for time online
PHP Code:
UPDATE a
SET coins = coins + (SELECT COUNT(CID) * 50 AS Expr1 FROM Character WHERE PlayTime >= 500000 AND AID = a.AID AND DeleteFlag = 0)
FROM Account a
Modify the numbers 50 and 500000 in the SQL query. In case your coins column has a different name, modify that as well.
In this example, it will check for each account how many characters have a playtime of 500000 or more, and will multiply that by 50 coins.
So if 1 account has 3 characters with a playtime of 500000 or more, it will add 150 coins to that account.
Re: Query for time online
@Dave
Thank you, Dave.
Some doubts, this query should be run every time I want to make the exchange of playtime coin, right?
If the member has 500,000 playtime and perform the exchange, he received 150 coins, however, I have to reset the playtime member, correct?
I remember a query that did this automatically adding coins while the member is online, is there any way to do this?
Re: Query for time online
Quote:
Originally Posted by
Enough
@
Dave
Thank you, Dave.
Some doubts, this query should be run every time I want to make the exchange of playtime coin, right?
If the member has 500,000 playtime and perform the exchange, he received 150 coins, however, I have to reset the playtime member, correct?
I remember a query that did this automatically adding coins while the member is online, is there any way to do this?
You can edit the "spUpdateCharPlayTime" stored procedure and add what @Dave told you.
Re: Query for time online
You could try adding this at the bottom of spUpdateCharPlayTime:
Code:
DECLARE @Playtime int
SELECT @Playtime=Playtime FROM Character WHERE CID=@CID AND PlayTime >= 500000
IF @Playtime IS NOT NULL
BEGIN
UPDATE Account SET Coins = Coins + 50 WHERE AID = (SELECT AID FROM Character WHERE CID=@CID)
END
I didn't test it so I'm not sure if it's going to work. And of course, you have to modify the values yourself in above snippet.
If you want to reset the PlayTime after the coins have been added, just add UPDATE Character SET PlayTime = 0 WHERE CID=@CID below the coins adding query.
Re: Query for time online
I will try, Dave.
Thanks you, guys!
Re: Query for time online
@Dave
@adz28
It was supposed to work that way?
PHP Code:
USE [MyDB]
GO
/****** Object: StoredProcedure [dbo].[spUpdateCharPlayTime] */
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROC [dbo].[spUpdateCharPlayTime]
@ PlaytimeInc int,
@ Cid int
DECLARE @ Playtime int
SELECT @ Playtime=Playtime FROM Character WHERE CID @ Cid AND PlayTime >= 500000
IF @ Playtime IS NOT NULL
BEGIN
UPDATE Account SET CashCoins = CashCoins + 20 WHERE AID = (SELECT AID FROM Character WHERE CID @ Cid)
END
Re: Query for time online
You're not supposed to delete anything, just add my snippet to the bottom.
Re: Query for time online
@Dave
Like this? \/
PHP Code:
USE [MyDB]
GO
/****** Object: StoredProcedure [dbo].[spUpdateCharPlayTime] Script Date: 03/12/2014 18:05:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/* ??? ??? ?? ???? */
ALTER PROC [dbo].[spUpdateCharPlayTime]
@ PlayTimeInc int,
@ CID int
AS
SET NOCOUNT ON
UPDATE Character
SET PlayTime=PlayTime+(@ PlayTimeInc), LastTime=GETDATE()
WHERE CID= @ CID
DECLARE [MENTION=1333449163]Playtime[/MENTION] int
SELECT @ Playtime=Playtime FROM Character WHERE CID= @ CID AND PlayTime >= 500000
IF @ Playtime IS NOT NULL
BEGIN
UPDATE Account SET Coins = Coins + 50 WHERE AID = (SELECT AID FROM Character WHERE CID= @ CID)
END
Re: Query for time online
Re: Query for time online
Quote:
Originally Posted by
Enough
Just try it out and see if it works.