iCents.net has specific functionalities for selling online games.
Games can be sold as stand-alones (paying each time you play) or on a time-based form. In fact, since games - especially action games - offer an intense experience for the player, these are the only cases where we suggest the duration of less than 1 hour for the paid-links.
Therefore, a game, or a package of games, can be sold for a certain period of time. When the time ends, the User can be removed from the paid area.
In the example below, the "Game of Addition" can be purchased for 10 minutes. When the remaining time is less than five minutes and when the player hovers the mouse over the "OK" button, the player is informed of how much time is left to play. When the time finally runs out, the game closes when the Internet user clicks this button.
The paid-link unlocks "game1.html" using the unlock="game1.html" attribute.
The "OK" button is a noPrice link with this same attribute: unlock="game1.html":
<button id="ok" type="button" althref="blank.html" price="noprice" nopricetext="leave" unlock="game1.html" countdown="5">OK</button>
The paid link then unlocks the "OK" button while it is valid.
The countdown="5" attribute guarantees that only in the final five minutes will the user be warned about the remaining time of the game.
Once the time runs out, the althref="blank.htm" attribute removes the user from the game when the "OK" button is clicked.
In addition, you can define two events for the "OK" button:
document.getElementById('ok').onafterok = ButtonClicked; document.getElementById('ok').onaftercancel = Warn;
The onafterok event is triggered when the "OK" button is clicked while the paid-link is still valid. This event calls the ButtonClicked function, which verifies if the value entered by the User is right or wrong, and updates the counter.
The onaftercancel event is triggered when the "OK" button is clicked after the paid-link expires. This event calls the Warn function, which displays a warning message informing that the game has ended and will be closed.
Note that instead of defining these events, you can do the following:
<button type="button" href="javascript:ButtonClicked()" althref="javascript:Warn()"...
In the example below, we can see another alternative. The Internet user can play while the paid-link is valid. Once the paid-link expires, the game closes automatically.
The iCents.IsLocked(URL) function checks whether the URL is not authorized.
The iCents.IsUnlocked(URL) function checks whether the URL is authorized.
In this example, the paid-link unlocks "game2.html" with the unlock="game2.html" attribute, and the "OK" button is a regular button. It is only responsible for verifying if the value entered by the user is right or wrong and updating the counter.
To end the game at the correct moment, we simply create an interval of time, once every second, and use the iCents.IsLocked("game2.html") function repeatedly to verify if the paid-link is still unlocked.
When the link expires, we close the game, running window.location.replace("blank.html").
As well as controlling the game time, it is also possible to remove authorization when the user loses the game. For this, use the iCents.Lock function, as explained in the "Paid Links with Duration" item. However, removing authorization will not prevent a hacker from replacing authorization in cookies.For this reason, you should also control the user sessions at least until the authorization effectively expires.