Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • General Discussion /
avatar image
Question by Adrià Entreserra · Jan 10 at 04:41 PM · CloudScriptunity3d

How to use well cloudscript?

Hey I'm doing a game that has waves and every 10 waves there's a boss, every wave that you pass there will be more enemies. Wave 0-20, 1 enemy more for wave, wave 20-40, 3 enemies.... Of course you have virtual currency and all stuff. I know how to make it offline but I have never used cloud script, so I don't know to what extent the code has to be put on the server. I mean, It's necessary that I have to call every time to cloudscript to know how many enemies has spawned to know if I have to spawn more or I can save it in a variable on unity? I don't know how to do it well that the player can't cheat on it.

I have searched it a lot, but I haven't found anything interesting...

For now I have done that every time you killed all enemies it runs the cloud script.

if (enemiesSpawned != enemiesToSpawn)
{
	int spawnPointToSpawn = Random.Range(0, spawnPoints.Count);
	float temp = Random.Range(2, 5);
	Instantiate(Enemie, spawnPoints[spawnPointToSpawn].transform.position, spawnPoints[spawnPointToSpawn].transform.rotation);
	enemiesSpawned++;
	yield return new WaitForSeconds(waitTime);
	StartCoroutine(Spawn(temp));
}
else if(enemiesSpawned == enemiesToSpawn)
{
	DataBaseManager.DBM.NextWave();
	StartWaves();
}

Every time that all enemies has spawned I add 1 to enemiesToSpawn and I set enemiesSpawned to 0. For that I think that the player can manipulate the enemiesSpawned or the enemiesToSpawn and cheat in the game. I don't know How doing it because every time you spawn an enemy, make a cloud script call, it's so much maybe.

If you reach to 0 lives you have start the game again and all stats will be reset. For now I have made this to reset the wave stat:

handlers.ResetWave = function(args, context) 
{   
	var stat = server.GetPlayerStatistics({ PlayFabId: currentPlayerId, StatisticNam	es: "CurrentLevel" });  
 
	var result = parseInt(stat.Statistics[0].Value);
   	var request = {
	   PlayFabId: currentPlayerId,
	    Statistics: [{                 
		"StatisticName": "Wave",                
		"Value": -(result)                    
			}]                
		};   
server.UpdatePlayerStatistics(request);

};

I think that that's not the best way of doing this. I get the statistic and I update the statistic subtracting the same value.

The last thing is the enemy's script. There will be enemies that have different health and different speed. For that, every time I spawn an enemy I have to take the speed and health from the database? If an enemy has 200 HP It can be modified by the player using cheats? And the speed too?

Thanks for all and sorry for my english.

Comment
Adrià Entreserra

People who like this

1 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by SethDu · Jan 11 at 07:03 AM

The advantage of Cloud Script is to have any verification steps you want before the players’ data is updated. Based on different game designs, there are different ways for anti-cheating.

According to your descriptions, each level will have different waves, which also have different quantities of enemy respawning in your game. A simple anti-cheat mechanism is to log players’ activities. For example, the client will send synchronization API calls to log the wave that a player has reached and the timestamp (Cloud Script function with JavaScript getTime()). For Each level, you may need to define a static table, and the data should be tested on your own (stores the least time each level will take). Assume a level has 20 waves, the client will send a sync API call every 5 waves and will quit the level immediately if the verification is failed (Remember that API is returned successfully but with a failed result in the payload).

You may also join some other gaming developer community to discuss anti-cheating methods. What I have mentioned above is a simple method and the important thing is that Cloud Script/Azure Function of PlayFab doesn’t only provide the access of server API through the client, but also can contain additional verification steps to prevent abusive uses before the data is updated.

Comment
Adrià Entreserra

People who like this

1 Show 2 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Adrià Entreserra · Jan 11 at 12:59 PM 0
Share

Sorry I'm new with cloudscript so, how do I send a sync API call? And how does playfab database know that the wave and enemies spawned are correct?

What I understand is that every 5 waves I have to check if the client variables are the same in the database, no? And If it's not the same I quit the level.

avatar image SethDu ♦ Adrià Entreserra · Jan 12 at 09:56 AM 0
Share

What I have mentioned is sending data as parameters of Cloud Script API call. The data is something you code to collect from the client side. The "sync API" simply means ExecuteCloudScript or ExecuteEntityCloudScript to run your customized functions.

The comparison of data doesn't require exact the same value, instead it should be under a tolerant range of the pre-measured data.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    4 People are following this question.

    avatar image avatar image avatar image avatar image

    Related Questions

    Granting items to user with custom data - item instance data 1 Answer

    Get segments with cloud script 1 Answer

    Using single variable increment for every user. unity3d 1 Answer

    Using master player to change values in all other players. 1 Answer

    Catalog's Item Custom Data 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges