ProfileService Help

Hello, so I am utilizing profile service for my RPG game and one of the mechanics in my game contain “combat logging”, which in short means when you’re in the middle of combat and leave the game it’ll be considered combat logging. With this I want to adjust the players data for example they lose some coins for combat logging but with profile service it automatically saves the data once the players leaves and takes their data out of the server table so it won’t allow me to save any more data regarding that specific player, is there any way I can work around this if you’re familiar with profile service code. Any help is appreciated thank you

1 Like

just remove the coins when they join back again

I’m not super familiar with ProfileService, so there totally might be a way to just write data before the player leaves, but assuming you can’t, one way to do this would be to:

  • Store a “last combat time” variable (e.g. using os.time())
  • Store a “last online time” variable, which you update every second or so
  • When the player joins, check if the “last combat time” is too close to the “last online time”. If it is, the player combat logged last game, so remove their coins (you could also show a UI to them informing them why they lost coins)

Edit: Even easier, you could just store an “in combat” true/false value, and when the player joins again, use it to determine whether they should lose coins.

I’d say Make a Value/Boolean for combat logging, when the player leaves the game when in combat, enable this value , ofcourse, you would need to save this value to the Data Too (You would create this variable on the data template module ) , so it saves, and when the player joins back to the game, Disable the booleand, remove the coins, and that’s all