ID:263973
 
Code:
mob/host
verb
Check_For_AFK()
set category = "GM"
world << "<center><b><font size=2><font color=#FF4466>AFK Check!"
for(var/mob/M in world)
M.AFK_Check()


mob/proc
AFK_Check()
for(var/mob/M in world)
M.said = 0
var/talk = input(M,"Say something, or be booted.")as null|text
if(M.talk)
M.said = 1
world << "[M] has been checked. He will not be booted."
else if(!talk)
sleep(600)
world << "<center><b><font size=2><font color=#FF4466>AFK Check has ended."
if(!M.talk)
world << "[M] has been booted due to being AFK."
sleep(10)
del(M)


Problem description:
It shouts AFK Check!, and lets [M] type something, but doesn't do anything else. Can someone help me?

Akito Bakasui wrote:
> mob/proc
> AFK_Check()
> said = 0
> var/talk = input("Say something, or be booted.")as null|text
> if(talk)
> said = 1
> world << "[name] has been checked. He will not be booted."
> else if(!talk)
> sleep(600)
> world << "<center><b><font size=2><font color=#FF4466>AFK Check has ended."
> if(!talk)
> world << "[name] has been booted due to being AFK."
> sleep(10)
> del(src)
>
>


Because your Check_For_AFK() verb is looping through all the mobs in the world, and then calling that mob's AFK_Check() proc. That proc is then, looping through all the mobs in the world again, and checking their variables, except the else if(!talk) line, which is checking the src instead.

You don't need the loop in the AFK_Check() proc, just use src instead.
In response to Xooxer
Also, don't make the person type something out to prove they're not AFK. Just check thier client.inactivity varaible instead.

mob
proc
AFK_Check()
// This checks if they disconnected, or
// if they haven't been active in the past
// 15 minutes. inactivity is the number of ticks
// since a command was received from the client
if(!client || (client.inactivity > 9000) // it's OVER NINE THOUSAND! (15 minutes)
// ... do your removal stuff here
else // they're still active
In response to Xooxer
Xooxer wrote:
Also, don't make the person type something out to prove they're not AFK. Just check thier client.inactivity varaible instead.

> mob
> proc
> AFK_Check()
> // This checks if they disconnected, or
> // if they haven't been active in the past
> // 15 minutes. inactivity is the number of ticks
> // since a command was received from the client
> if(!client || (client.inactivity > 9000) // it's OVER NINE THOUSAND! (15 minutes)
> // ... do your removal stuff here
> else // they're still active
>


I did the typing thing because some people do prefer to sit there and watch the game.
In response to Akito Bakasui
And they also prefer to be pestered by the game?
In response to Garthor
They'll be pestered either way. If the AFK Check is necessary, I think the way he is going about it is great and his own decision.
A spam check would kill your fork hax. fail.
In response to Garthor
Garthor wrote:
[...]

Yeah, I also think it's rather bad implementation to input() or alert() out of nowhere. Especially when it's player-initiated, they can use it to their advantage and harass people. Hell, I know I tried it a few times in a game(s) I don't remember, before attacking someone I used something like a PM() verb to give him an alert() so he can't move while I attack. :O Too easy to abuse.


----------
Besides, this implementation won't even work. The proc sits there and waits for the input() to return, and it won't until the player has answered. So the proc will never continue and he won't get kicked either. If you want to do it using input()/alert() you need to do it a little differently.

And checking the inactivity var is only good for seeing who is AFK in a Who() verb or something - in a check that kicks, you'll want to be checking things like auto macroing ("EZ macros" or "AFK macros") which can bypass that easily as well as that input() test above. But you could the game like ask a simple random question every time so you can't predict it and answer it automatically, and stuff like that.
In response to Kaioken
Or, you could make a game where you DON'T gain an advantage from punching a goddamn log.
Akito Bakasui wrote:
Code:
> mob/host
> verb
> Check_For_AFK()
> set category = "GM"
> world << "<center><b><font size=2><font color=#FF4466>AFK Check!"
> for(var/mob/M in world)
> M.AFK_Check()
>

> mob/proc
> AFK_Check()
> for(var/mob/M in world)
> M.said = 0
> var/talk = input(M,"Say something, or be booted.")as null|text
> if(M.talk)
> M.said = 1
> world << "[M] has been checked. He will not be booted."
> else if(!talk)
> sleep(600)
> world << "<center><b><font size=2><font color=#FF4466>AFK Check has ended."
> if(!M.talk)
> world << "[M] has been booted due to being AFK."
> sleep(10)
> del(M)
>
>

Problem description:
It shouts <font color=#FF4466>AFK Check!</font color=#FF4466>, and lets [M] type something, but doesn't do anything else. Can someone help me?

Could i get help on this i liked to have this for my DBZ game and i added it and it says undefined var to m said =1 m.said = 0 what do i do?
In response to Christopher52488
You stop copying other people's code.
In response to Garthor
what i figured this is a good code for me
In response to Christopher52488
Christopher52488 wrote:
what i figured this is a good code for me
Do you not even comprehend what programming is?
You can't just copy / paste "codes".
Besides, that's a terrible way of doing it.
In response to Flame Sage
well i like how the code is so im trying to figure out how to get it working on mine
In response to Flame Sage
ok what ever ill figure it out myself