Anti-Cheat with 4Players SCILL

Anti-Cheat with 4Players SCILL

The main purpose of 4Players SCILL is to empower game developers to implement gamification features like daily or weekly challenges, battle passes and leaderboards into their games in hours and not weeks.

However, today, we will show how you can leverage 4Players SCILL Events and SCILL Leaderboards to implement anti-cheat-systems into your game with a couple lines of code. The code examples here use Unity with Mirror Networking, but as the concepts are basically the same for all multiplayer games this will also work for you and your game if you don’t use Unity. SCILL also has a SDK for Unreal, so the methods described in this post work basically the same in all game-engines and applications.

Input validation is key

Your server (or host) should validate all input coming from clients to make sure that it has not been hacked.

This is a simple example: We store a float value with the next time that an attack is possible and wait for clients with authority (which own the player object) to press the space key. Then, we call a command on the server to spawn a projectile in the network.

private void Update()
{
  // Make sure this client has authority about this object
  if (!hasAuthority)
    return;

  // Make sure it's time for this client to attack again
  if (Time.time < _nextAttackTime) 
    return;

  if (Input.GetKeyDown(KeyCode.Space))
  {
    // Send a command to the server
    CmdAttack(transform.forward);
    _nextAttackTime = Time.time + 1.0f;
  }
}

[Command]
private void CmdAttack(Vector3 direction)
{
  GameObject go = Instantiate(_projectilePrefab, transform.position, transform.rotation);  
  // Setup projectile....
  // ...
  
  // Spawn the projectile on the server
  NetworkServer.Spawn(go);
}

For cheaters, or cheat programmers, this will be an easy target. They just need to remove the return in line 7. This way, on client side a lot of attack messages per second can be sent to the server and the server will execute it without any further validation.

We need to validate the data. Let's just see the code to do that validation on server side.

[Command]
private void CmdAttack(Vector3 direction)
{
  if (Time.time < _nextAttackTime)
    return;
 
  GameObject go = Instantiate(_projectilePrefab, transform.position, transform.rotation);  
  // Setup projectile....
  // ...
  
  // Spawn the projectile on the server
  NetworkServer.Spawn(go);
  _nextAttackTime = Time.time + 1.0f;
}

Remember that in a networked game, your Unity scripts (or objects) will exist multiple times: On each client and on the server. Every player has a GameObject with an instance of this script, and on the server a GameObject exists with an instance of this script exists for every player.

Therefore, we can use the same code on client and server side for data validation. And this is what we do: The client validates input, then sends data to the server. A "copy" of this script runs on the server, and here we run the same tests again. But this time, it's running on the server - a place where your cheaters will not get their dirty hands on so easily. We don't need to sync values here, as the local time will be different on server and clients, but we only use relative time here, so the absolute values of _nextAttackTime are not important. It's just important that the same amount of time passed since a projectile has been fired - and as time runs with the same speed on client and server this code will work.

Let's finalize our code by refactoring it a bit. If we want to increase fire rate, right now we need to change that in two places, which is not good at all and is prone to for errors.

private bool ValidateAttackInput()
{
    // Make sure it's time for this client to attack again
  if (Time.time < _nextAttackTime) 
    return false;

  _nextAttackTime = Time.time + 1.0f;
  return true;
}

private void Update()
{
  // Make sure this client has authority about this object
  if (!hasAuthority)
    return;

  // Make sure it's time for this client to attack again
  if (!ValidateAttackInput())
    return;

  if (Input.GetKeyDown(KeyCode.Space))
  {
    // Send a command to the server
    CmdAttack(transform.forward);
  }
}

[Command]
private void CmdAttack(Vector3 direction)
{
  // Make sure it's time for this client to attack again
  if (!ValidateAttackInput())
    return;

  GameObject go = Instantiate(_projectilePrefab, transform.position, transform.rotation);  
  // Setup projectile....
  // ...
  
  // Spawn the projectile on the server
  NetworkServer.Spawn(go);
}

That's it. The server validates the input and if attack messages come in faster than they should, they are ignored. Most likely you will have the same pattern implemented (somewhere) in your game.

Anti-cheat with SCILL

Right now, we try to prevent cheats. Cheaters will always start with the easy hacks, like speed hacks shown above. If they are not successful, they will dig deeper, and finally they will find a hole. This is certain. So, how can SCILL help to prevent that?

It's easy. The idea is this: The server side validation should never trigger, because we already do client side validation. But, if the code triggers a lot, this indicates that this specific user is playing around with your client side code or installed a cheat.

Instead of just returning, we can use that data to "mark" this user. Think of it as putting a sticker on the user if this happens. There might be occasions this happens for users without any speed hacks installed like latency or network packet loss among other reasons. So, here and there we'll see users with a couple of stickers applied. But if they look like this, something is definitely not right 😃.

This is exactly what SCILL is all about: Storing abstract atomic events attached to your users and to create value out of that data.

Before you can use this code, you'll need to:

The Unity SCILL SDK exposes the SCILLManager singleton, which you can use on server side to send events for that user. In this simple code example we assume that you use some authenticationData attached to the connection. This can be Steam, Playfab or any other authentication system. SCILL only needs to get a unique (persistent) user id like a SteamID or in simple games it can be the SystemInfo.deviceUniqueIdentifier.

[Command]
private void CmdAttack(Vector3 direction)
{
  // Make sure it's time for this client to attack again
  if (!ValidateAttackInput())
  {
    var userData = (UserData)connectionToClient.authenticationData;
    SCILLManager.Instance?.SendEventForUserIdAsync(userData.userId, "trigger-event", "single", new EventMetaData
    {
      amount = 1,
      event_type = "vf-attack"
    });
  }

  GameObject go = Instantiate(_projectilePrefab, transform.position, transform.rotation);  
  // Setup projectile....
  // ...
  
  // Spawn the projectile on the server
  NetworkServer.Spawn(go);
}

That's it. By adding a couple of lines of code, you now send events to the SCILL cloud. There are many different events you can send for different things. trigger-event is an all-purpose event that makes sense here. SCILL events can have meta data attached. In this case, we add an event_type info that we will use later. As we might have multiple input validation methods, we can use different event types to understand where validation failed. I used a prefix vf (which means validation failed) and then a name of the place in the code.

More info on events, their structure and available types can be found in our documentation.

Now, whenever a validation input error happens, we place a sticker on that user. As the stickers are persistent, cheaters will be already marked in their early stages.

Next, we use a leaderboard to visualize that data.

Identify cheaters with SCILL Leaderboards

With SCILL, you can create leaderboards listening on specific event types and summing up all events coming in. This way, you can easily create leaderboards for your players with most kills or those guys that never die. But, you can also visualize any other event with leaderboards. In this case, we just create a leaderboard listening on trigger-event events and the vf-attack meta data.

We can do that in the 4Players SCILL Admin Panel:

Please note: In the Admin Panel, you can add multiple leaderboards (depending on your tier) for different event types. But you can also sum up multiple events in one leaderboard. So, instead of just adding vf-attack you could also add another meta data value by setting vf-attack vf-move vf-collect-health to build a leaderboard for all validation events.

That's it. Now, you have a real-time leaderboard showing the cheaters in your game! You can use our leaderboard web component to add a fully functional leaderboard in your own backend tools, or just use our Playground application to show the leaderboard for this game.

Do you see the Realtime Updates section at the bottom? SCILL offers real-time notifications that your App can respond to in real-time. So, by listening in on those messages you could show the user a warning to stop cheating or else he'll get banned.

The other way to automate things is to set a Webhook in the SCILL Admin Panel calling a script on your side that you can use to implement business logic for banning users from playing your game, or kicking them from the server. It's up to you how you handle this:

  • Use SCILL Playground as a User Interface to quickly check if there are cheaters in your game
  • Add SCILL Leaderboard Web Component to your web based backend to have the tool right where your community management is
  • Implement Webhooks to automate things on your side by leveraging data collection and processing on SCILL side.

Next steps

Well, you have implemented the SCILL SDK into your game, and you have set up an account. Why not add leaderboards to your game, or daily or weekly challenges with rewards to your game - it's done in less than an hour. Even full fledged, fully functional battle passes can be added to your game in a rather short period of time. SCILL handles all the heavy lifting and we even provide fully functional, ready-to-use prefabs with user interfaces to get you started quickly.

Interested?

Additional documentation

We have extensive documentation on all these topics we touched on this blog.

Why Gamification is a winner!

Why Gamification is a winner!

What is Gamification and you should get involved

Gamification sounds like a new-ish thing, but when you look at it closer, it has always been part of our lifes. It has just been called differently, or we have been using it, without actually being aware of it. As an example, parents always try to sell chores as a fun thing to do and promise small rewards if their offspring gets the jobs done (in time). By doing so, they are selling a task as a game and link a potential reward – they are gamifying!

Nowadays gamification has become far more obvious and the best example outside video games is the gamification of monotonous sports exercises. Companies like Fitbit wouldn’t sell as many of their sport watches, if gamification wouldn’t be a main part of their product DNA. Walking 10.000 steps each day becomes a fun exercise, as you want to stay at the top of the leader board and if you continue doing it, you might even grab the last missing achievement badge in a few days. Sounds familiar? Or looking at video games, achievement hunting became a real thing when Steam, PlayStation and Microsoft added their achievements to all games. It’s not only about enjoying the experience itself, it’s also about beating the extra challenges and unlock all available badges. Why? Because It’s cool to show off rewards and trophies, of course!

Get ready for the next challenge

Now that we understand the general concept of gamification, why are we all obsessed with it? The answer is pretty simple: Humans love to play games! And gamification is exactly this – games, challenges, friendly competition in bitesize portions, usually attached to something else, sometimes completely different.

And since we at 4Players also love challenges and rewards, we developed and launched SCILL, our unique Gamification as a Service platform. With SCILL, challenges can be added to pretty much any application, including but not limited to video games, mobile apps, websites and intranets. The intuitive admin panel allows challenge creation with just a few clicks, also offering the combination of challenges into full-fledged Battle Passes. The latter are a well-known and proven retention and monetization tool in various video games, the most prominent being Epic’s Fortnite for example. In a nutshell, Battle Passes offer a combination of challenges, combined with exclusive rewards spread across levels.

Challenge accepted

SCILL enables developers and publishers to leverage the power of gamification without the need for time-consuming and expensive software development. All it needs is the implementation of the SCILL SDK, definition of game events and the creation of challenges via the SCILL admin panel. Once set up, challenges can be added, tweaked and combined with just a few clicks, helping to increase user retention and offering new ways to monetize them. And all this without sharing any personal data and being 100% GDPR conform!

Our experience shows that gamification with challenges and rewards serves a wide range of different trigger points users show across all services:

A path to follow / Reminder

By offering the right challenge at the right time, we can use them perfectly as a tutorial / guide to understand the core app mechanisms, or offer them throughout the full product, guiding users on every step of their way. In both cases – which are not mutually exclusive – challenges will always act as a clear path to follow, preventing them to get lost, getting frustrated and eventually churn out.

Fun at your own pace

Nothing can be more frustrating than being pushed through a product at a pre-set speed. We all have different skills, more or less time to spend or just a different approach. Utilizing challenges lets users actively decide on their next goal and their own pace. Real-time tracking always keeps challenges updated and a clear picture on their progress.

And for those who want a friendly competition, timed challenges add the little extra to reach the goal ideally ahead of time.

Accomplishments and Rewards

Getting out of your comfort zone can be rewarding and frustrating at the same time. Especially the latter is something to avoid, preventing low retention rates and high churn.

Have you ever played a shooter or racing game, which was fun, but your skill wasn’t good enough to make a frag or finish the lap, leaving you at the bottom of the score board? It can be fun for a couple of matches, but if you don’t see any progress, it soon will be your last match and time to move on to the next game.

By offering accomplishments and rewards at the right time, users will have a much better experience. So in the example above, why not offer a challenge for surviving a certain amount of time, finishing a lap without damage or other achievable goals, giving the user a sense of accomplishments, which they wouldn’t have otherwise? These rewards will usually be enough to retain the user and offer enough time to improve their skills – which will be the base to enjoy the game as initially indented. Plus, it will not mess with any game mechanics or general progress.

Conclusion

Gamification is an extremely powerful – and fun – tool for pretty much any application and any situation. It will add the extra layer of engagement, developers and publishers are looking for, and it can be used as a short-, mid- and long-term motivator to keep retention high and churn rates low. And by combining challenges and rewards in a clever way, they can also be an optional and non-intrusive way to monetize the users.

To sum it up in one sentence: “Gamification is a winner, which can turn the most monotonous task into a fun and rewarding experience.

Add your own gamification layer today with SCILL – for free!

#gamification on 4Players.de – a case study

#gamification on 4Players.de – a case study

Always eager to give their loyal user base more features and incentive to stay on their website 4Players.de, the editorial team doesn’t rely on their high quality content alone, but also #gamification elements. I.e. to enhance interaction, in 2009 the site employed an achievement system inspired by the systems that were used e.g. on the Xbox 360 or a little later on PlayStation 3, PC (Steam) as well as on current consoles.

Depending on their activity on the website the users would get rewards for reading news or reviews, interacting with the editorial team, posting in the forums (with special hand-picked rewards for the best as well as worst forum post) and much more.

Administrative effort was very high. After the initial hardcoded integration and connection to the user database, definition of thresholds and intervals, in which achievements and rewards like special badges (that the users can attach to their profile on the website) will be granted, adding new content was very difficult, time consuming and almost always prone to system errors.

Nonetheless this achievement system was maintained and kept active for years to come enhancing the readers’ experience on the website – although new and especially meaningful achievements were not only harder and harder to find, but also to implement. Eventually the system became dormant around 2016.

Fast-forward five years and the re-introduction of achievements on 4Players.de just went into its public beta stage. Powered by the proprietary system SCILL Gamification as a Service (GaaS) by 4Players with its modular and simple approach, implementation is not only much easier, but also much faster. While the setup, planning and integration took quite a few months back in the days, now it took considerably less time and effort to give the users an experience that is not only easier to maintain but also much easier to enhance with new achievements and more options to interact.

While in 2009 and the following years the development was heavily involved in basically every step of the achievement way’, nowadays only a few lines of code need to be added to the source code initially in order to connect the website to the SCILL backend system. And, naturally, everything is GDPR-compliant. The result: development can focus on their next tasks, while it is up to the editorial team to add new achievement content via the easy-to-use SCILL Admin Panel. Thus, the focus stays on the user experience and the #gamification elements reacting in real-time, surprising the readers as well as rewarding them and enticing them to interact with the content in new or different ways. And that in return means enhanced community engagement plus higher retention and as a side effect more page and thus ad impressions.

Gamify your website with SCILL

Gamify your website with SCILL

Boost interaction, impressions, ad views and registrations

SCILL helps you to increase page and ad impressions, retain visitors longer and convert them into loyal readers. The key to success is called Gamification! 

Humans have an innate need to learn, improve their skills and compete with others. SCILL Gamification helps you to address these needs, increasing motivation, interaction, retention and  monetization of your content and users – in a playful way!

The extra power-layer for your website

SCILL can be integrated seamlessly into your website, without the need of sensitive data.

Backend: Integrate the SCILL SDK, define event triggers to fit your requirements and goals.

Frontend: Decide where and how you want to integrate gamification in your website. SCILL offers easy to integrate web components to get started. Copy & Paste the code and tweak the appearance to fit your brand.

Ready, Stead, Challenge!

Create challenges like “Login every day for 7 days”, use them independently or as a part of task-system like a Battle Pass and reward your users with XP, coins, badges or whatever comes to your mind. Or even create user leaderboards to rank them by XP, to make sure they are incentivized to make purchases, use your content and interact with your app or website. 

Here are some challenge examples:

  • Login in
  • Upload a profile picture
  • Make a purchase
  • Become a premium member
  • Come back 3 times a week
  • Participate in use survey
  • Leave a comment
  • Rate a product
  • Newsletter subscription
  • Find an item / picture
  • Read 10 news

Possibilities are endless and can be as unique as your content. With SCILL you finally can setup user events and engaging content in minutes – no worries if you forgot your company anniversary, Black Friday deals or other occasions you want to celebrate with.

To find out more about website gamification with SCILL, check out our product website.

Start challenge your users and engage with them in a fun way – fast and easy!