Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I go about making a script which can modify tables from the server?

This might seem confusing but hopefully you can understand.

Lets say we have a table called bannedplayers.

local bannedplayers = {"bannedplayer1", "bannedplayer2", "someone"}

It could be an empty table or no. Now let say we also have an admin gui which only admins can access. They can ban, kick people for hours, days, week, months, years. Once that code executes it will create a new index in the bannedplayers table. If the player got banned for a week. He will stay inside that list for a week and he will get removed. Or if that is too complicated we can just create new tables with the time of the ban. For example a table called bannedplayers4aweek.

The thing is that this shall be done without shutting down the severs. And I do not think that is possible but with HttpServices it can be. I have seen this before in a game called CB:RO.

I am not asking for script ofc but how could this be done? I just want to get some ideas.

4 comments

0

With datastore, you can just have a table of temp bans that store a list: [UserName: string, BanTime: number]

0

BanTime being actually the time the ban expires. So you would set it relative to the current time.

0

^ how can I save tables in the server and I assume that the server would need to be shutdown so the other servers get affected by this change? It is like gui. If you modify the gui the changes won't be saved unless the player resets.

0

Like you said, httpsservice. You'd probably use something like trello to record the ban in a specified board. You can then refer to that board and return a json table and convert it with JSONDecode. You can then lookup a player in that table and compare timestamps. Trello also has an extensive api, so you probably wouldn't even need to do the json part to find someone.

1 answer

✓ Accepted answer

This is my thinking of a way it should be done, not the absolute way.

First I think you need to know how table dictionary work:

local bannedplayers = {
	["bannedplayer1"] = VALUE,
	["bannedplayer2" = VALUE,
	["someone"] = VALUE
}

What I am thinking is does VALUEs are replaced with UNIX time (using tick() ):

When the ADMIN ban a player for some amount of days, or so, you can calculate how much seconds is in those amount of days (7 Days = 604800).

Then, adds player name to the table, and the key being the amount of seconds in those days plus the time now: bannedplayers[player.Name] = tick() + timeBannedInSeconds, then save that into data storing place.

When a player joins:

  • Get the table from data storing place
  • Check if the player name is in the table
  • If so, then check the time
  • If time has not passed, then kick them; Else, remove them from the table and let them play.

1 comment

0

Thanks! Btw I won't use tick() since it is not safe. I will use os.time plus os.date.

This discussion is preserved as it was. New answers, comments, and votes are closed.