So for my game I have a party system, I have implemented the basic functions.
Party Module:
local Party = {}
Party.CurrentParties = {}
function Party:Create(player) -- Player Instance: player
local ID = player.UserId
if player and not self.CurrentParties[ID] then
self.CurrentParties[ID] = {}
-- Creates party
-- Fire a remoteEvent to update UI
end
end
function Party:Disband(player) -- Player Instance: player
local ID = player.UserId
if self.CurrentParties[ID] then
self.CurrentParties[ID] = nil
-- Disbands party
-- Fire a remoteEvent to update UI
end
end
function Party:Leave(player) -- Player Instance: player
for Host, Table in pairs(self.CurrentParties) do
if table.find(Table, player) then
table.remove(Table, table.find(Table, player))
-- Player left party
-- Fire a remoteEvent to update UI
end
end
end
function Party:Kick(host, playerToKick) -- Player Instance: host | Instance: playerToKick
local party = self.CurrentParties[host.UserId]
table.remove(party, table.find(party, playerToKick))
-- Kick player for party
-- Fire a remoteEvent to update UI
end
function Party:Invite(host, playerToInvite) -- Player Instance: host | Instance: playerToInvite
if self.CurrentParties[host.UserId][playerToInvite.UserId] then return end
-- Fire event to playerToInvite or remote funcitons?
-- Is it wierd to send it to client just to send it back, since I dont want to invoke the client from server.
table.insert(self.CurrentParties[host.UserId], playerToInvite.UserId) -- If they accept
end
return Party
I have put comments on what I will do, though I have some questions that I need help with.
So most of the functions are pretty basic and I believe they shouldn’t break. As you can see in the Party:Invite()
function I have a comment, now what would be the best way to approach this using a remote event or remote function?
Now I know it isn’t advised to use a remote function from the server to the client, but I think if I add enough checks it could work. So the information I get back from the client should only be a bool val of true or false. If true they accepted the invite. So I would check if the data I got from the client was a bool value and if it was true. Alternatively, I could fire a remote to client and have it sent back to the server. That’s my idea anyway if you have a better Idea let me know?
TL;DR
This is for the invite function:
Should I use RemoteEvent or RemoteFunctions?
Any other solution I could try?
Have I used any bad practice/ anything I should be doing?
I appreciate you took time to read this, hopefully this wasn’t too bad of a post. Just wanted to get other takes on the matter.