generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: I made a ban module because of that thread earlier

Previous Thread :: Next Thread 
RemasteredBox is not online. RemasteredBox
Joined: 19 Jun 2016
Total Posts: 2140
17 Aug 2016 03:14 AM
I didn't test it though, it's for my game.
I have it stored in ServerScriptService btw so if i use proper validation it wont get exploited anyways.
Is this correct?

local bans = game:GetService('DataStoreService'):GetDataStore('Bans');

game.Players.PlayerAdded:connect(function(player)
local bannedStatus = bans:GetAsync(player.UserId);
if bannedStatus then
local banReason = bannedStatus.reason;
local banTime = bannedStatus.time;
if (banTime == 'infinite') then
player:Kick('You are banned for: '..banReason..", your ban will never expire.");
elseif (banTime >= os.time()) then
player:Kick('You are banned for: '..banReason..", your ban expires in "..(banTime / 60).." minutes.");
end;
end;
end);

return {
setBanStatus = function(player, reason, time)
bans:SetAsync(player.userId, {reason = reason, time = time});
end;
removeBanStatus = function(player)
bans:SetAsync(player.userId, nil);
end;
};


-R.B. Box (Regalius Boxikins Box)
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
17 Aug 2016 03:17 AM
How would it get "exploited" in the first place, it's a server script and one that the client should never have any power to do anything with.

Anyways it looks fine enough, but it'd be way more useful if you had a ban function that takes how many seconds/whatever they'll be banned for, not just the end time
Report Abuse
RemasteredBox is not online. RemasteredBox
Joined: 19 Jun 2016
Total Posts: 2140
17 Aug 2016 03:20 AM
@Flux

I'm saying it wont get exploited, I just put that there so people would know that it wont be (so I don't get hate).
I'm trying to make quality code & improve my knowledge.
I forgot to do that btw, I should have added os.time() to the 'time' variable.


-R.B. Box (Regalius Boxikins Box)
Report Abuse
RemasteredBox is not online. RemasteredBox
Joined: 19 Jun 2016
Total Posts: 2140
17 Aug 2016 03:22 AM
Here's the fixed version guys, I also converted the ban time to days.

local bans = game:GetService('DataStoreService'):GetDataStore('Bans');

game.Players.PlayerAdded:connect(function(player)
local bannedStatus = bans:GetAsync(player.UserId);
if bannedStatus then
local banReason = bannedStatus.reason;
local banTime = bannedStatus.time;
if (banTime == 'infinite') then
player:Kick('You are banned for: '..banReason..", your ban will never expire.");
elseif (banTime >= os.time()) then
player:Kick('You are banned for: '..banReason..", your ban expires in "..(banTime/60/60).." days.");
end;
end;
end);

return {
setBanStatus = function(player, reason, time)
bans:SetAsync(player.userId, {reason = reason, time = (os.time() + time)});
end;
removeBanStatus = function(player)
bans:SetAsync(player.userId, nil);
end;
};


-R.B. Box (Regalius Boxikins Box)
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
17 Aug 2016 03:24 AM
I don't know why you don't use the time along with the amount of days.

"You've been banned for 12 days, 4 hours, 3 minutes, and 2 seconds"
Report Abuse
RemasteredBox is not online. RemasteredBox
Joined: 19 Jun 2016
Total Posts: 2140
17 Aug 2016 03:28 AM
@Flux

Don't know how :(


-R.B. Box (Regalius Boxikins Box)
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
17 Aug 2016 03:30 AM
It's just division and modulus...

local days = math.floor(secsBanned / (60*60*24))
local hours = math.floor(secsBanned / (60*60)) % 24
local minutes = math.floor(secsBanned / 60) % 60
local seconds = secsBanned % 60
Report Abuse
RemasteredBox is not online. RemasteredBox
Joined: 19 Jun 2016
Total Posts: 2140
17 Aug 2016 03:31 AM
What does modulus do?


-R.B. Box (Regalius Boxikins Box)
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
17 Aug 2016 03:33 AM
Gets the remainder from division.
Report Abuse
MiniNob is not online. MiniNob
Joined: 14 May 2013
Total Posts: 822
17 Aug 2016 03:33 AM
It gets the remainder of the division of two numbers
Report Abuse
RemasteredBox is not online. RemasteredBox
Joined: 19 Jun 2016
Total Posts: 2140
17 Aug 2016 03:40 AM
@flux
Okay does this look good?

local bans=game:GetService('DataStoreService'):GetDataStore('Bans');
local ceil = math.ceil;

game.Players.PlayerAdded:connect(function(player)
local bannedStatus=bans:GetAsync(player.UserId);
if bannedStatus then
local banReason=bannedStatus.reason;
local banTime=bannedStatus.time;
if banTime=='infinite' then
player:Kick('You are banned for: '..banReason..', your ban will never expire.');
elseif banTime+bannedStatus.osTime>=os.time() then
player:Kick('You are banned for: '..banReason..'. Your ban expires in '..ceil(banTime/(60*60*24))..' days, '..(ceil(banTime/(60*60))%24)..' hours, '..(ceil(banTime/60)%60)..' minutes, and '..banTime..' seconds.');
end;
end;
end);

return{
setBanStatus=function(player,reason,time)
bans:SetAsync(player.userId,
{
reason=reason;
time=time;
osTime=os.time();
}
);
end;
removeBanStatus=function(player)
bans:SetAsync(player.userId,nil);
end;
};


-R.B. Box (Regalius Boxikins Box)
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
17 Aug 2016 03:44 AM
I said floor, not ceil
Report Abuse
RemasteredBox is not online. RemasteredBox
Joined: 19 Jun 2016
Total Posts: 2140
17 Aug 2016 04:10 AM
@Flux

I know but it's better to round up isn't it, so they wont get disappointed if its off?


-R.B. Box (Regalius Boxikins Box)
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
17 Aug 2016 04:13 AM
no, because it won't be off. Rounding up is the dumbest idea because if they have 1 second left on their ban it will say "1 days 1 hour 1 minute 1 second" and not "0 days 0 hours 0 minutes 1 second"...
Report Abuse
Deafgift100 is not online. Deafgift100
Joined: 09 May 2010
Total Posts: 3958
17 Aug 2016 06:16 AM
why not just round it accurately with

math.ceil(num-.5)

???
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
17 Aug 2016 06:54 AM
I save my bans in a table in one key


63,237
Report Abuse
RemasteredBox is not online. RemasteredBox
Joined: 19 Jun 2016
Total Posts: 2140
17 Aug 2016 06:56 AM
@Happy
That's an incredibly bad idea, IMO.


-R.B. Box (Regalius Boxikins Box)
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
17 Aug 2016 07:44 AM
'why not just round it accurately with
math.ceil(num-.5)'
Because one does not simply round 13 hours to a day. The flooring is to chop off the extra seconds from the whole
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
17 Aug 2016 08:48 AM
it's not a bad idea lol

tell me why

what if you want a banlist?

How do other games do that?

they store it in a table


63,218
Report Abuse
RemasteredBox is not online. RemasteredBox
Joined: 19 Jun 2016
Total Posts: 2140
17 Aug 2016 05:16 PM
@Happy
I thought you meant like 1 giant value, such as a string or something. My bad, I was tired.


-R.B. Box (Regalius Boxikins Box)
Report Abuse
Deafgift100 is not online. Deafgift100
Joined: 09 May 2010
Total Posts: 3958
18 Aug 2016 10:09 AM
ah of course
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image