Is there a way to generate serial #s for a game?

Get help using Construct 2

Post » Sat May 09, 2015 12:59 pm

And to require those who purchase the game to have one? I've looked through the boards and haven't found anything on this. Thanks, Morgan.
Image
B
20
S
4
Posts: 382
Reputation: 2,964

Post » Sat May 09, 2015 8:02 pm

One possible way to do a serial could be the following:
So say you want the serial to be in the format of
aaaa-bbbb-cccc-dddd
1234-4567-8901-2345

You can then let it be a good serial if
a+2*b+3*c+5*d is in the range of (55000 to 55005) or something.

To generate them you could do something like the following which should give you a few good serials.

repeat 100000 times
--- set a to int(random(10000))
--- set b to int(random(10000))
--- set c to int(random(10000))
--- set d to int(random(10000))
------ a+b*2+c*3+d*5 is in the range (55000 to 55005)
--------- save as valid serial.
B
91
S
31
G
103
Posts: 5,237
Reputation: 67,760

Post » Sun May 10, 2015 12:27 am

Thank you @R0J0hound
Image
B
20
S
4
Posts: 382
Reputation: 2,964

Post » Sat May 30, 2015 3:21 pm

I've tried this technique before, but there's a chance it'll generate the same key/code more than once. Now, you could give the same key/code to more than one player, but in the end that would be the same as having one single license for everyone (and players could give the key to each other and play your game without paying).

You can also do it the way Scirra does it, and give a file (.txt file for instance) on purchase, and the buyer has to put that file into the program's director for the license to activate.

I'm also looking for a nice way to do serial codes and I'm not sure what I'll end up doing yet.
B
11
S
3
G
3
Posts: 206
Reputation: 2,379

Post » Sat May 30, 2015 3:37 pm

You could use a hash:
viewtopic.php?t=62215&start=0
Image ImageImage
B
168
S
50
G
164
Posts: 8,231
Reputation: 105,581

Post » Sat May 30, 2015 5:22 pm

The duplicate serial possibility is solved by keeping your own list of the generated serials along with the buyer info. Then when generating the serials just check if it's in the list first before adding it.

You could also require a name with the serial and use the hash of the name along with the numbers. The txt file works mainly because it contains personal info of the buyer so they wouldn't wish to share it. Likely what c2 does is check the hash of the file to see if it's valid.
B
91
S
31
G
103
Posts: 5,237
Reputation: 67,760


Return to How do I....?

Who is online

Users browsing this forum: bluesun66, plinkie and 10 guests