question

Ion avatar image
Ion asked

Need Ideas : How to implement giving lifes in guild chat channel?

Hello!

We are currently working on a game whose social part of the game is used specially to get/give lifes to other clan members.

Which could be the best practice to get a practically synchronous "giving lifes" system?

Are the objects of groups + cloud script a good starting point for this?

Do i need to save the chat history for this?

An example:

I enter to the chat channel, and send " a need lifes message", which other clan members can press a button to give me a life. (the message can be pressed 5 times, so giving me 5 lifes in total)

I back to the main menu (not focus in the chat channel), and suddenly, a user gives me a life, so i get a notification in "lifes section" of the main menu. I go there and i can see the new life to take from the clan member.

Photon chat is cool for exchange messages at the moment, but what about storing such type of messages? Which have a life amount information and expiration date, for example.

Any suggestions/ideas are welcome! :)

Thanks a lot!

CloudScriptphoton
10 |1200

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

1 Answer

·
brendan avatar image
brendan answered

Photon Chat is great for running a chat service between players, but it does not provide server-hosted logic that would drive such a feature. And no, group objects would not be a way to do this, since a group object is just that - data which is general to the group, not specific to either player in your scenario.

What would be best would be to simply have a Cloud Script that you call once the player has chosen how many lives to send. The script would take the number of lives and the target player as input, and the logic would be to check that the player is allowed to grant the lives to the other player (to prevent cheating), then increment the lives on that other player. You could then use Photon Chat to push a message to the other player that the lives were granted.

2 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.

Ion avatar image Ion commented ·

Thanks Brendan, the problem is that a player can only give 1 life for each life request (A life request = 5 lifes). Also, all the life requests are shown in the chat channel, so i need the history of the chat, or the lifes requests as minimum.

I noticed that the chat channel history is cleared when no user is subscribed, or something like that. And i need to store the chat history somewhere, because the life requests must be alive until their expire date or until 5 lifes are given...

I am thinking to implement a similar life request system, without displaying in the chat channel, just another section of the clan, but all the clan members must be able to see the requests.

Is this scenario better to use common data storage in guilds?

Also, i have to explain that is more important the life request system than the chat itself. I can lose the chat history, but not the life requests. I think the life requests should be a common data of the clan, because if the player leave the clan, the life request is also lost.

Thanks!

0 Likes 0 ·
brendan avatar image brendan Ion commented ·

Photon Chat does not currently provide a means to store the chat history. If you want to store it, it's possible to use the Entity File system, where the Entity is the Group (Clan), but you need to make sure the read/write is done only occasionally. So in other words, do not attempt to update it on every chat message - that's guaranteed to not work. So realistically, you would need to have some server-side logic running that monitors for the presence of players and, when they're all gone, reads out the chat text and stores it - which would mean needing a custom game server running. What would be simpler would be to just use Redis to store the chat messages, and then read them back from there when a new chat room is started.

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.