Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

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

Asked by
valchip 789 Moderation Voter
6 years ago
Edited 6 years ago

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.

0
With datastore, you can just have a table of temp bans that store a list: [UserName: string, BanTime: number] ScrewDeath 153 — 6y
0
BanTime being actually the time the ban expires. So you would set it relative to the current time. ScrewDeath 153 — 6y
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. valchip 789 — 6y
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. Azarth 3141 — 6y

1 answer

Log in to vote
1
Answered by
thesit123 509 Moderation Voter
6 years ago
Edited 6 years ago

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.
0
Thanks! Btw I won't use tick() since it is not safe. I will use os.time plus os.date. valchip 789 — 6y
Ad

Answer this question