Search Unity

Unity Multiplayer [SyncVar] Protect from Cheat Engine

Discussion in 'Multiplayer' started by wobes, Jun 21, 2016.

  1. wobes

    wobes

    Joined:
    Mar 9, 2013
    Posts:
    763
    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).
     
    wobes likes this.
  3. wobes

    wobes

    Joined:
    Mar 9, 2013
    Posts:
    763
    thank you for your suggestion, I will try.
     
  4. wobes

    wobes

    Joined:
    Mar 9, 2013
    Posts:
    763
    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)
     
    wobes likes this.
  6. wobes

    wobes

    Joined:
    Mar 9, 2013
    Posts:
    763
    Go It! Thank you so much for your help!
     
unityunity