ID:264350
 
Code:
mob
proc
AFKCHECK()
var/A
spawn(30)
if(A)
src<<"Deemed Here"
return 0
else
src<<"Deemed AFK"
return 1
A = input("Please type something in the box to show you are not AFK") as text
            AFKCheck()
for(var/mob/M in world)
if(M.AFKCHECK())
del(M)

Problem description:

Lmao, There is no direct problem with it..it just doesn't work. I'm probably just going at it wrong, is there a better way to do it? client.inactivity is not what I'm looking for though, because if there clicking a button to train it resets thus allowing afk-training. (Eh, I cant spell so sorry for any spelling mistakes? xD Auto correct does wonders though)
You define a variable A, but with no value, so if the input() box ever does show up, nothing will happen.

mob/proc
AFK_Check()
var/A = input("","AFK Check") as null|text
if(A)
src<<"Good"
return TRUE
else if(!A) //I like to do else if() rather than else
src<<"Bad"
return FALSE
AFK_Loop()
for(var/client/C) //loops through clients, rather than every mob in the game
if(C.mob.AFK_Check()) del C //if AFK_Check returns true, delete their client


Also, for added "anti-afk-training" you can throw in a rand() in that spawn() of yours, so they can't guess when exactly they're going to get the AFK check message, thus preventing bots ^-^
spawn(rand(30,100)) //wait between 3 and 10 seconds...
In response to Spunky_Girl
Ahh, but it does show up, the spawn(30), allows the code that follows it to be executed so the input box does show up, except even after you type something in the input box, it registers that A is null. and with the code you posted, it allows the input box to just be ignored, so it really doesn't work for what I want it to, but it does work for what I'm trying to accomplish.
In response to King killer 113711
Ah, sorry. Try putting a spawn in the loop then.

mob/proc
AFK_Check()
var/A = input() as null|text
AFK_Loop()
for(var/client/C)
spawn C.mob.AFK_Check()
sleep(rand(30,100))
if(!A) del C
In response to Spunky_Girl
Spunky_Girl wrote:
Ah, sorry. Try putting a spawn in the loop then.

> mob/proc
> AFK_Check()
> var/A = input() as null|text
> AFK_Loop()
> for(var/client/C)
> spawn C.mob.AFK_Check()
> sleep(rand(30,100))
> if(!A) del C

1) input() defaults to usr. usr in proc. Bad

2) 'A' is a local variable to AFK_Check() and therefore you can't check it from AFK_Loop(). This won't even compile.

No matter what, putting that loop under mob is way wrong. And 3 seconds to ten seconds to respond? That means if I'm on the toilet I'll be deleted, or getting a drink, or even just looking away for a moment.

On the whole, this is a really horrible idea and a completely borked implementation of that horrible idea.
In response to Spunky_Girl
...I'm going to have to wonder what you meant to put there. I think you either meant to put something else? or you left some lines off the code there or you just didn't read what you were writing. Sorry for sounding harsh I'm not trying to be. Its just, I'm not sure what you even meant.
In response to Alathon
Alathon wrote:

No matter what, putting that loop under mob is way wrong. And 3 seconds to ten seconds to respond? That means if I'm on the toilet I'll be deleted, or getting a drink, or even just looking away for a moment.

On the whole, this is a really horrible idea and a completely borked implementation of that horrible idea.

The 3 seconds is for debug for me, I'm not waiting 3-5 minutes every-time I click the verb to try to debug it

Edit: Oh by the way, If I were to say, make the delay 3 to 5 minutes Would it still be such a horrible idea? Is the idea of the 3 second the only thing behind you labeling it a bad idea?
In response to King killer 113711
Yes, I did mean to put something else. I wasn't thinking about this at the time of writing it; I was thinking about food ^-^; (my dad came up and said "supper time!" *stomach growls*).

But now that I look at it, and try to think of a way to get the Check to return a TRUE/FALSE value, I can't think of what to put in for that A >.<
The problem is probably that you're trying to get input from every mob in the world. This isn't good because chances are you have mobs that aren't players; loop through all the clients globally (for(var/client/C)) instead. Your funky input()-spawn() arrangement might also be a problem, but I would fix the client thing first.
In response to Jeff8500
Well, Besides the fact I currently am the ONLY mob in my test world, it doesn't currently matter. Later on though, I would have gotten some runtime errors from that, so thanks for pointing it out.
In response to King killer 113711
King killer 113711 wrote:
Edit: Oh by the way, If I were to say, make the delay 3 to 5 minutes Would it still be such a horrible idea? Is the idea of the 3 second the only thing behind you labeling it a bad idea?

I suppose that depends why you even have the AFK check. What is the problem you're trying to solve? If you're just trying to prevent players from sitting around doing nothing in your game, I have two questions:

1) Why does it matter? They're logged in, that helps your game
2) Why do it this way? there is a variable called client.inactivity that tracks when the client last did an action, that you can use to automatically check if someone is AFK.
In response to Jeff8500
Jeff8500 wrote:
This isn't good because chances are you have mobs that aren't players; loop through all the clients globally (for(var/client/C)) instead.

ID: 690154 - I've already touched on this, though I didn't give a reason why you should loop through clients. So thanks for adding clarity :)
In response to Alathon
Alathon wrote:

1) Why does it matter? They're logged in, that helps your game

If they are sitting online AFK Training, its helping the status of the game, but its not exactly fair to everyone else.

2) Why do it this way? there is a variable called client.inactivity that tracks when the client last did an action, that you can use to automatically check if someone is AFK.

By clicking on a verb, randomly clicking the mouse, or walking one step client.inactivity resets to 0, So basically its doing absolutely nothing against AFK Training. Now if your going to tell me, Base training solely off of killing monsters or something that wouldn't allow people to look away, Even something along those lines can be AFK'd with a simple macro recording program.
In response to King killer 113711
If you have AFK training in your game, you have a deeper problem. You can never stop macroing or people creating bots, what you can do is one of two things:

1) Make the game interesting enough to not want to AFK train

2) Vary training methods enough to make it awfully difficult.

Those are more or less the only viable solutions, really. They're harder to cope with, yes - But in the end you'll have a far better game from it.

This AFK check verb is just as easy to bypass as client.inactivity is. Some people will always bot, either ban them when you find out and/or increase the fun factor of being there. Someone isn't going to go AFK if they have a fun time being there, or the challenge is difficult enough that they can't create a bot to reliably solve it.
In response to Alathon
Alathon wrote:

1) Make the game interesting enough to not want to AFK train
Well, Even making the game as interesting as you can, There's always that, So In attempt, I'm trying to make a way for it just to cut down on AFK Training, With a good anti-AFK Training system It can reduces peoples thoughts of trying to.

2) Vary training methods enough to make it awfully difficult.
Well, What would you suggest? There's PVP, PVM, and Grinding/Quests. Questing is Basically the only one safe enough to prevent people from AFKing.

This AFK check verb is just as easy to bypass as client.inactivity is. Some people will always bot, either ban them when you find out and/or increase the fun factor of being there. Someone isn't going to go AFK if they have a fun time being there, or the challenge is difficult enough that they can't create a bot to reliably solve it.

Then if this AFK Check verb is so easy to bypass, how do you suggest a better way to handle this?
In response to Alathon
Alathon wrote:
...or the challenge is difficult enough that they can't create a bot to reliably solve it.

That's why I said to put a rand() in his spawn() delay ^-^ You can't accurately guess a random :D
In response to King killer 113711
He gave a better way to handle this o.O Quest grinding :)
In response to Spunky_Girl
Spunky_Girl wrote:
He gave a better way to handle this o.O Quest grinding :)

I meant a better way to handle the AFK Check, He said that the AFK check was easily bypassed. If it is so easily bypassed, then there has to be a better way to handle it so its not as easily bypassed.
In response to King killer 113711
Yeah, with what I told you to do with the rand() inside the delay :) You can't guess a random ;p
In response to Spunky_Girl
That's all well and good, but now back to the problem, The code itself wont work and the code is called on a verb click, nothing is more random then the human mind itself.
Page: 1 2