ID:166835
 
I know how to make a boot command but i want to set time to it also so that those pesky players do time while they have been booted. Its like i want to boot them and set a time for them to stay booted.
Any help?
try this
var
boot_time = 30
booted

proc
Troll_Kill()
sleep(60)
boot_time -= 1
Troll_Kill()

mob
verb
Boot(mob/M)
set desc = "boot a troll"
src<<input("Input a boottime",boot_time)

mob
Login()
if(src==booted)
if(src.boot_time<0)
src<<"you cannot rejoin until [boot_time]"
..()


Of course you need include your boot verb in there.
In response to TheLunarWolf
It is best not to have functions call themselves to create a looping effect unless you do so in a spawned code block, as that will crash if your boot_time is too large a number.

Don't forget to make your input a number, as it defaults to text if you don't specify.

The way you have booted set up as a global variable, this only allows for a single person to be booted at a time, and it won't work anyway unless you don't delete mobs on logout. Almost every game deletes people on logout. After that, when they rejoin, they have a new mob which isn't the same one as they had before, so this new mob (the src in this instance for Login) will never equal booted. In fact, booted will be null once the player is gone from being booted.

Lastly, you want if(src.boot_time > 0), not <0.

If you want to know how I would do it, I would prefer to keep a list of keys, as is normal for a ban, and add an assossiated timestamp to those which will be allowed back in after a certian period of time.

I like to call it a ban since it seems to more more like a "temp ban." And it's easier to work into an existing ban system anyway.
var/list/banned[0]

proc/ban(client/C, temp_time = 0)
if(ismob(C))
var/mob/M = C
if(M.client) C = M.client
else return 0
banned[C.key] = temp_time

client/New()
if(key in banned)
var/time = banned[key]
if(!time) return
if(world.realtime > time)
banned.Remove(key)
else
src << "You are temporarily restricted from entering. You will be able to join again after [time2text(time)]."
return
.=..()

You would want to pass the timestamp to it of the time the player will be able to rejoin. For example, if you want to ban "test dude" for 10 minutes, that would be ban("test dude", world.realtime+6000)
In response to Loduwijk
Loduwijk wrote:
that would be ban("test dude", world.realtime+6000)

Wouldn't it be better to use world.timeofday? It's more accurate with time.
In response to Android Data
True, but that doesn't work for bans which stretch into a new day. Either because you're playing close to midnight, or because you want to ban someone for 24 hours or more.
In response to Loduwijk
Oh but what you posted is kinda complicated to understand i am really new to this coding and its hard to catch up on things. *sighs* i wish i knew how to
In response to Loduwijk
But you can always make a workaround. world.realtime is a very large number. I'd use a bit of math to determine the time a person is to be unbanned and use that as an associated value to the banned ckey.
In response to CaptFalcon33035
CaptFalcon33035 wrote:
But you can always make a workaround. world.realtime is a very large number.

But not too large for this instance. The inprecision of world.realtime is insignificant for something like this.

I'd use a bit of math to determine the time a person is to be unbanned and use that as an associated value to the banned ckey.

Why go to all the trouble? Is having it precise down to the tenth of a second really that necessary? I don't see how it could be.

Still, I said 24+. What if you wanted someone gone for more than 24 hours? For 25 hours, 2 days, or a week even? You can't do that with timeofday. At least not without silly workarounds that gain you no advantage.

Even if you only wanted it to be 5 minutes though, realtime is still accurate enough. Nobody will care, or even notice for that matter, that it is occasionally off by a second.
In response to PuNkS
PuNkS wrote:
Oh but what you posted is kinda complicated to understand i am really new to this coding and its hard to catch up on things.

Here are some comments.
var/list/banned[0]
//A list to keep track of people who are banned.
/*It is an assossiative list so that you can also know how
long the person is banned for. 0 means permanently.*/


proc/ban(client/C, temp_time = 0)
//a function that accepts two arguments: a client and a timestamp
if(ismob(C))
//This if statement part just lets you pass a mob instead of a client.
//If a mob was passed, set C to the mob's client if it has one. If not (if it's an NPC), abort.
var/mob/M = C
if(M.client) C = M.client
else return 0
banned[C.key] = temp_time
//Add the client's key to the list and assossiate it with the timestamp that represents when it can rejoin.

client/New()
if(key in banned) //if the player is in the banned list...
var/time = banned[key] //let's grab the time it's allowed back in
if(!time) return //if it's a permanent ban, abort (the client will not be allowed in the game if you abort here)
if(world.realtime > time)
//If it is passed the time that the player is allowed back in...
banned.Remove(key)
//...then remove the player from the banned list.
else
//If it's not past the time, tell the player and then abort.
src << "You are temporarily restricted from entering. You will be able to join again after [time2text(time)]."
return
//If it gets to here then it hasn't aborted yet. That means the player is allowed in.
//.=..() does the default action of client/New and returns what the default returns (which is the player's mob)
.=..()
In response to TheLunarWolf
That would effect all the people that had been booted, thus, if someone was booted and in fifteen minutes another person was booted, the first bootee would suffer the time till unboot back up to 30.
In response to Loduwijk
WOW nice explanation. But even though im gonna use this i wanted a boot one also can i use the same procedure and get the boot one done?
In response to PuNkS
You just call the ban function however you want.
mob/admin/verb
boot(mob/M)
M.Logout()
permanent_ban(mob/M)
ban(M)
boot_for_a_while(mob/M, n as num) //n is in seconds
ban(M, n*10)
In response to Loduwijk
Oh ok then i think i understand what you mean.
In response to PuNkS
I understand all of that but im getting errors. Where do i put like the var and procs
In response to PuNkS
Exactly where I showed them.
In response to Loduwijk
1.0 System\1.2 Administration\H_Admin Loading and Saving.dm:67:error:banned:undefined var
1.0 System\1.2 Administration\H_Admin Loading and Saving.dm:68:error:banned:undefined var
1.0 System\1.2 Administration\H_Admin Loading and Saving.dm:71:error:banned.Remove:undefined var
1.0 System\1.2 Administration\H_Admin Loading and Saving.dm:67:if :warning: if statement has no effect
1.0 System\1.2 Administration\H_Admin Loading and Saving.dm:74:error::missing expression

Those are the errors im getting

In response to PuNkS
Banned was the first thing in there.
var/list/banned[0]

Check back up at my first post in this thread again.
In response to Loduwijk
ok i got that fixed b4 i read this ne way.
Should there be some part in the code where it says like if the person boot logs in then scr blah blah then else return .=..?
In response to PuNkS
That is already there in client/New.

client/New is called when the client first connects and is the first thing that happens. Its default nature is to create a mob for the client with the appropriate key, gender and name, then return that mob. It is supposed to return null to disallow a connection, but that doesn't work. However, if you don't do its default action and you don't give it a mob, then it will not let the player connect.

In the parts where it detects that the player should not be allowed in, it returns, aborting the function. It aborts before the client gets a mob, so it doesn't let the client in. Then, as you can see, the last line of client/New there is .=..() which does the default action and returns it.
In response to Loduwijk
        Boot_Player(mob/PC/M in world)
set category = "Admin"
if(GMLockCheck ())
usr<<" font color =red> YOur Admin Powers are locked!"
return
else
var/Reason=input("Input a reason.")as null|text
var/Time=input({"For how long? (in seconds)
(Max of 900 seconds (15 Minutes))
(Input the amount of time for boot.
Any time past 15 minutes will be lowered
to 15 minutes)"}
) as num
if(Time>=900)
Time=900
if(Time>=1)
Time*=10
if(Reason)
if(Time)
world << "<b>[M] has been <font color=red>Booted</font> by [src] ([Reason])([Time/10] Seconds)"
M.booted=1
AdminLog("Boot","[Reason]","Time: [Time/10] Seconds",M)
del(M)//**********//

Thats wat i came up with but i got one error.M.booted=1 is undefined how can i fix this