question

hami-m avatar image
hami-m asked

Combination - working with Gold - PlayerPrefs and Virtual Currency?

Hello,

im currently working on a 1v1 Multiplayer Game with Photon and Playfab - i'm at the stage where each player:

- starts with a amout of gold to buy enemies.

- can spawn enemies which try to attack the other player (spawning costs gold)

- when the other player kills the enemy - he earns gold to spawn more enemies.

But i don't know how to get it done for a multiplayer game.

In the start phase of the game i used "PlayerPrefs" - but i don't know if this is a secure way using it in a multiplayer game. So i started looking up information about virtual currency - but i think this isn't a good way either because both players kills alot of enemies which means alot of updates - how are "goldsystem" in mmorpg's working like WoW is it all done with PlayerPrefs or?

also if the game is done the winner get's something like "credits" to buy items from a shop - is it possible to make this done like "player 1 wins and credits are added with API / cloudscripts? Seems like a secure way aswell for me.

I hope my question was clear, thanks to all advance.

Unravel

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image
Seth Du answered

If it is a near-time game, I don’t think Photon is necessary and Cloud Script/Azure function will be enough, but based on your description -- you are using Photon, I assume it is a real-time multiplayer game.

During the game, the most important thing is fairness and anti-cheating. Hence, the whole gaming process will be divided into 2 parts, “Player actions” and “Data processing”. While it is obvious that the client should handle the players’ actions and submit the choices made by players to the Photon hosted servers. Then, in Photon Server, it will verify the actions and perform it if valid.

Normally, neither Virtual Currency (VC) nor PlayerPrefs should be used to decide if the players can purchase to spawn enemies because it is real-time and HTTP responses are slower than socket connections. Thus, the scenario is based on your requirement, if you are using a socket connection, there should be a temporary currency defined only in the hosted servers, and it is used during the match, which will be like a battle resource. Players can “get” the currency, it will be reflected on the client side, but they cannot directly modify it. When the player selects “respawn”, the server will check the command and do the consumption for the player.

After the match is ended, the server should calculate the result scores and update VC for each player, and the client should get the latest data via socket or PlayFab “Get” API calls. Because the connection between clients and servers is via socket, players cannot directly access the server contents, you may simply implement PlayFab SDK and call Server APIs to update players’ data.

4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

hami-m avatar image hami-m commented ·

hey @SethDu thanks for your reply!

Yes im currently working a real-Time Multiplayer game.

Indeed im not just trying to work on a game - i'm trying to even work on important things like "fairness and anti-cheating" even if i'm new to game development - half-done things aren't things for me.

How can i check / handle - Client-Side Actions or submits to the photon-Server - or verify them?

I used some PhotonViews on both Players to interacte with bullets and enemys (not 100% done) - because if player 2 kills a mob from player 1 - the mob disappears for player 2 but not for player 1. Things like that but before i fix those i wan't to start / finish my gold system.

the scenario is based on your requirement, if you are using a socket connection, there should be a temporary currency defined only in the hosted servers, and it is used during the match, which will be like a battle resource. Players can “get” the currency, it will be reflected on the client side, but they cannot directly modify it.

how do you i realise the part above you wrote?

handling temporary currency on the hosted server? - i really like it and would use realise it as you wrote, what would be the best start to do so?

Thanks alot!

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ hami-m commented ·

We can help integrate Photon or any other PlayFab SDK with you, however I am not an expert on Photon or Multiplayer server design. The answer above is only a basic idea, you may find Photon dedicated support from their community.

0 Likes 0 ·
hami-m avatar image hami-m Seth Du ♦ commented ·

Hey thanks again but i'm still kinda lost about this topic, because i don't know how to start. It's not about Photon here.

I just wanna build a ingame "Gold - System" where players can spawn mobs with gold - and gain gold while killing mobs, but on a secure way - not really PlayerPrefs (because i have the feeling that it's kinda vulnerable, saving the Gold as PlayerPref and not as a value on a "server" or something else) - but the idea with saving it on a Server is also illogical because you gain and lose Gold so fast there is no way to save or send this information always to a server to keep the gold value up to date, so there is also no way of hacking or changing the gold value.

Maybe your last message - was a bit to complex for me, to start the first steps.

Is there maybe a tutorial or ideas? - which could help me, i'm literally googlin this topic since weeks - tried a few things on my own, but it sadly doesn't went that well.

0 Likes 0 ·
Show more comments
hami-m avatar image
hami-m answered

Hey @SethDu

by "help you implement SDK and explain the API usage" you mean playfab? - if so i already implemented playfab in my Unity Editor. i use it for login and player information purposes and a bit cloudscirpt + photon Cloud (PUN2) for lobby / room and game / logic handling purposes with PhotonView - as you say i need a temporary variable in my server build how do i realise it? - i'm not working with a dedicated server do i need one and if so does playfab offer one via azure or maybe something else like aws? if so i would need / appreciate help with managing this as my first atempt.

I also read all the disscussions you've send me and i want to go this step, even when it seems hard and alot trying to understand all this like - sending informations to the server which verifies the clients actions and building a data model for the game - it's understandable but as a "newbie" into this topic i can't really imagine how the code behind this would look like... are there documentations or some kind of stuff to read through?

Thanks alot in advance!

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image Seth Du ♦ commented ·

We only provide customized multiplayer server (GSDK) implementation samples on PlayFab/gsdk: Game Server SDK for PlayFab Multiplayer Servers (github.com). We are not familiar with Photon Cloud design. You may find more help on Photon Community.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.