ID:164134
 
I i have just become host of a new game and i've been doing some coding as well but there is no way to tell if a player is training while afk. So i was wondering if anyone could tell me how to code in an AFK check.
mob
var/afk

verb/say(T as text)
AFKcheck()
world <<"[src]: [html_encode(T)]"

proc
AwayFromKeyboard()
sleep(XXXXX)
if(!afk)
afk = 1
world <<"[src] has gone AFK."
src.AwayFromKeyboard()
AFKcheck()
if(afk)
world <<"[src] has come back from AFK!"
afk = null
else
return

Login()
src.AwayFromKeyboard()
..()


Place how long you want them to wait before becoming AFK in the xxxxx spot. You might want to run the AFKcheck() everytime the user does something, like move, talk, punch, etc.

By the way this code might be horrible, and I'm sure any second Lummox will be here to confirm it.
In response to Siientxx
Why not just do:
world
New()
..()
while(world)
sleep(10)
for(var/mob/M in world)
if(M.client)
if(M.client.inactivity >= 500)//set the time
M.Logout()


Note: This won't stop someone from using bots, but think of this. Where are people using bots? Training? Why do they use bots during training? It is boring. When people use bots it gives you a clear sign that that part of the game is boring, and that you have to change it to make it more fun.
In response to Smokey Joe
Yeah sorry I had no idea there was "M.client.inactivity". :S
In response to Siientxx
Siientxx wrote:
Yeah sorry I had no idea there was "M.client.inactivity". :S

You should give the reference guide a quick read once in a while. You might just find a solution to that problem you can't figure out.
In response to Smokey Joe
I would like to thank u all for helping me i will incorporate this into my game immediately thank u so much. One more thing i forgot to mention is there a way i can make it Auto as well as manual and be able to set the timelimit as to how often it check automatically
In response to Smokey Joe
Smokey Joe wrote:
Why not just do:
> world
> New()
> ..()
> while(world)
> sleep(10)
> for(var/mob/M in world)
> if(M.client)
> if(M.client.inactivity >= 500)//set the time
> M.Logout()
>

Note: This won't stop someone from using bots, but think of this. Where are people using bots? Training? Why do they use bots during training? It is boring. When people use bots it gives you a clear sign that that part of the game is boring, and that you have to change it to make it more fun.

i know about the bots but when i put this code in when i use it you know how like some games say afk check say somethin in the ooc in the next min or you'll get booted. then give a 10 second warning then 5 4 3 2 1 etc like that.
In response to Jason515
No offense, but I think thats stupid.
What if someone goes to the bathroom and right after they leave the check comes on.
In response to Smokey Joe
Smokey Joe wrote:
No offense, but I think thats stupid.
What if someone goes to the bathroom and right after they leave the check comes on.
Yeah i know because i keep getting booted but since i am also host it'll help reduce lag from players afk training and as long as they aren't macro training and they have a time between 0.1 and about 1.0 is pwipe it'll prevent players from getting an advantage and not being at their computers or having a secondary program train for them.
In response to Jason515
If you balance out your game, you could prevent players from becoming too strong. As for the training, maybe you could use a different method of advancement, training is extremely boring which is probably the reason people use bots.

If you make training more fun, and different, you probably wont even need these 'afk checks' that you're talking about.
In response to Smokey Joe
Smokey Joe wrote:
If you balance out your game, you could prevent players from becoming too strong. As for the training, maybe you could use a different method of advancement, training is extremely boring which is probably the reason people use bots.

If you make training more fun, and different, you probably wont even need these 'afk checks' that you're talking about.


Not true. There's always gonna be people out there wanting to take the easiest shortcut to become "the best". Players are evil, and very few should be trusted.
In response to Teh Governator
well the game i have the lvl is extremely easy with super high caps giving players a fun time. but i just want to stop players from being afk while training so even tho the training is easy it's still unfair for them not to be at the computer while other players are.
If you're talking about preventing players setting up their computer to repeat a macro while they're not even at the keyboard, then thats a difficult thing to do. If you're talking about checking to see if the player has actively done anything, check client.inactivity.

If you're faced with the first problem, then the solution isn't to make a check to see if the player is macroing while away, its to make a game that can't be played by repeating the same macro over and over.
In response to Foomer
Foomer wrote:
make a game that can't be played by repeating the same macro over and over.

Exactly.
In response to Smokey Joe
Smokey Joe wrote:
Why not just do:
> world
> New()
> ..()
> while(world)
> sleep(10)
> for(var/mob/M in world)
> if(M.client)
> if(M.client.inactivity >= 500)//set the time
> M.Logout()
>

Note: This won't stop someone from using bots, but think of this. Where are people using bots? Training? Why do they use bots during training? It is boring. When people use bots it gives you a clear sign that that part of the game is boring, and that you have to change it to make it more fun.




Cool but how do i attach a message saying that he has been booted for being idle. the code is in and it works but i've been trying to input a message and i get undefined var. Also i wanted to add when the player logs out so i can see when they leave because i feel like a jackass trying to talk to them when i don't even notice that they have left. thanks