Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
Dismiss Notice
Join us now in the Performance Profiling Dev Blitz Day 2023 - Q&A forum where you can connect with our teams behind the Memory and CPU Profilers and the Frame Debugger.

Unity Multiplayer [SyncVar] Protect from Cheat Engine

Discussion in 'Multiplayer' started by Deleted User, Jun 21, 2016.

  1. Deleted User

    Deleted User

    Guest

    Hello everyone,
    Is there any solution to protect [SyncVar] from Cheat Engine?
    for example:
    Code (CSharp):
    1. [SyncVar(hook = "OnMoneyChange")]
    2.     public float money = 500.0F;
    3.  
    4. public void OnMoneyChange(float updateMoney){
    5.         money = updateMoney;
    6.     }
    If I use Cheat Engine, it easy to change it and then buy something for example in my if money < itembuyprice

    Code (CSharp):
    1. if(money < itembuyPrice){
    2.                 inventory.DontAllowBuy();
    3.                 }
    with this you can bypass that if, your SyncVar goin to "-" float, like -500$, but the Cheat Engine shows 100000$ and allow to buy.
    Thank you
     
  2. Severos

    Severos

    Joined:
    Oct 2, 2015
    Posts:
    181
    A cheat engine will change the value of the variable on local machine, however it can't affect the value on server, so if you make the buy operation on server, regardless of what shows local machine the variable will be true one on server.
    SyncVar syncs the variables from server to client (single direction only).
     
    Deleted User likes this.
  3. Deleted User

    Deleted User

    Guest

    thank you for your suggestion, I will try.
     
  4. Deleted User

    Deleted User

    Guest

    have you any ideas how to do buy on Server Side?
     
  5. Severos

    Severos

    Joined:
    Oct 2, 2015
    Posts:
    181
    It really depends on how you're writing your code and your DB backend can affect this process too, there's no standard way to do it so can't really help much.
    All I can say is that you can use command or networkMessage to send the buy request, on server you validate the request then perform it and send RPC/networkMessage with the operation state (success/failed)
     
    Deleted User likes this.
  6. Deleted User

    Deleted User

    Guest

    Go It! Thank you so much for your help!