I have an in game messaging system, that saves messages players send to each other (which can be destroyed once a player has read) however, I fear an exploiter could use this to cause data caps to be reached.
I put in place a system that prevents too many messages, so you can only have 10 messages in your inbox at once saved, however, their lengths aren’t set. So in theory, somebody could send you a message with a million words ye? Would this then cause data store caps to be reached? and if you so, what would be my best solution?
I thought of setting a word cap, but that could still cause a ton of data requiring saving. For example, let’s say:
100 character cap on message.
You can get 5 messages from each player, and upto 10 seperate players. So that’d max out at
100 * 5 * 10 = 5000
Which I mean, out of a data store cap of 260,000 I’d imagine 5,000 ain’t the end of the world?
But is there a better way?
Small chunket of the code
if #Data.Messages >= 10 then return 'Inbox full!' end -- User has too many messages (from 10 different users)
local FoundUser = false
for i, v in pairs(Data.Messages) do
if i == player.Name then -- Already got a message from that player
print('Already has a message', #v)
-- Check to make sure they don't have a ton of messages from same player
if #v >= 5 then
return 'Inbox full!'
else
-- All good, send the message
table.insert(Data['Messages'][i], FilteredMessage)
FoundUser = true
break
end
end
end
if not FoundUser then
Data.Messages[player.Name] = {FilteredMessage}
end