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

0 favourites
  • 6 posts
From the Asset Store
20 high quality click sounds, ready to improve your game's UI instantly
  • 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.

  • 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.

  • Thank you R0J0hound

  • 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.

  • You could use a hash:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)