Page 1 of 1

How to quite a game after 5 years?

PostPosted: Fri Mar 31, 2006 4:32 pm
by Sam
Hello!

Need help!

I want that the user only use my game in a period of 5 years. After 5 years the game would be quite (not available more).

The code that I have tried is:

Code: Select all
Quitedate = 2009-01-01
Nowdate = date
If Nowdate = Quitedate then Action.GoToFrame "quite"


But it does not working

Regards, Sam
:roll:

PostPosted: Sat Apr 01, 2006 2:12 am
by ShadowHunter
Hi,

1. Open your project
2. In the "Project Menu" click "VBS Procedures (advanced)"
3. Copy/Paste this code into the window

Code: Select all
Sub ExpiredCheck

Dim ExpireDate, CurrentDate

ExpireDate = CDate(01/01/2009)
CurrentDate = FormatDateTime(Date,2)

If ExpireDate <= CurrentDate Then   
   CreateTimedEvent 0.1, "Action.GoToFrame ""ExpiredFrame"""
End If

End Sub


4. Click "OK"
5. Right click on the initial frame (first frame when the game starts)
6. Select "Properties"
7. Select the "Advanced" tab
8. Tick the "Execute VBScript code immediately after the frame has appeared" checkbox
9. Copy/Paste this into the window

Code: Select all
ExpiredCheck


That should work regardsless of regional settings too :D

Better of course would be to look at the date the game was first ran or installed and add 5 years to it and provide a system time set back check.

You can learn this by downloading my "Trial and Registration script" from my website http://www.shadowhunter.co.uk, look under the VBScripts section.

Hope this get you started !

Kind regards,

ShAdOwHuNtEr

PostPosted: Sat Apr 01, 2006 9:22 pm
by Sam
Hi ShAdOwHuNtEr!

Thanks a lot, but the code does not working. I think the value of the CurrentDate and the ExpireDat is not the same format.
If I check the CurrentDate :
Code: Select all
Text(1)= FormatDateTime(Date,2)
gives 4/1/2006
If I check the ExpireDat:
Code: Select all
Text(1)= CDate(01/01/2009)
gives 00:00:43

Best regards, Sam

PostPosted: Sat Apr 01, 2006 10:24 pm
by Candle
I find it hard to believe a game would be on a computer that long.
Most computers have a reinstall of the OS long before that so it will be a new install of the game or left off and on to something new.
Think back five years and look on your computer , you won't find anything on there from that long ago.

PostPosted: Sun Apr 02, 2006 11:37 am
by ShadowHunter
Hi,

The whole idea of the DateTimeFormat function is to get an universal date formating, 2 for being mm/dd/yyyy. You could try to remove the CDate function...

I would have used the Format(Now, "mm/dd/yyyy") function but AM seems not to accept this. Maybe GM has an explanation for this.

Though it works fine on my computer because, it might be regional settings related.

What settings do you use in Windows ?

We will find a solution because there are more ways to store a date :wink:

Unfortunally I agree with Candle... 5 years is an eternity in computer terms. I wouldn't worry to much about it.

Kind regards,

ShAdOwHuNtEr

PostPosted: Sun Apr 02, 2006 10:16 pm
by Sam
Hi!

When I reform your code as below, it works on my computer perfectly, but I want that the code should work on all type of settings that the Windows use.
I don?t know how to check a computer setting to know what settings do I use in my Windows ?

Code: Select all
Sub ExpiredCheck
Dim ExpireDate, CurrentDate
ExpireDate = CDate("4/2/09")
CurrentDate = CDate(FormatDateTime(Date,2))
If ExpireDate <= CurrentDate Then
CreateTimedEvent 0.1, "Action.GoToFrame ""ExpiredFrame"""
End If
End Sub


Best Regards, Sam

PostPosted: Mon Apr 03, 2006 4:23 pm
by ShadowHunter
Hi Sam,

I don't think the code works since you use the wrong variable... You have created "EDate" but are using "ExpireDate" to make a comparison...

Anyway, try to store the date as a long variable then you have a number instead of a formated date. That should be the same regardless of the regional settings.

Kind regards,

ShAdOwHuNtEr

PostPosted: Mon Apr 03, 2006 9:53 pm
by Sam
Hi!

I don't know, it works on my PC, I will try it on onther PC too.
I remove the variable EDate. I t still working as well as before.

Code: Select all
Sub ExpiredCheck
Dim ExpireDate, CurrentDate
ExpireDate = CDate("4/2/09")
CurrentDate = CDate(FormatDateTime(Date,2))
If ExpireDate <= CurrentDate Then
CreateTimedEvent 0.1, "Action.GoToFrame ""ExpiredFrame"""
End If
End Sub

Best Regards,
sam