ID:141446
 
Code:
world/var/Checking = 0 //This defines the variable Checking
world/var/list/AFK = list() //This defines the variable AFK to be a list


Problem description: The problem is that it says that Checking: variable declaration not allowed here, same thing with AFK I know if its possible to use the global var such as this:

var/Checking = 0
var/list/AFK = list()


But I can't use that so how would I go about defining a world variable?

You cannot define a variable for the world. A global variable is pretty much the equivalent, though, so deal with it.
In response to Jeff8500 (#1)
Well then that leads me to a totally different topic, so how would I go about this?

var
Checking = 0
list
AFK = list()
mob
var
Afk = 1 //Defines the mobs Afk variable
world/proc
Call_AFK_Check() //This proc is ment to warn the world of the AFK check
while(!world.Checking) //Calls this proc as long as the world's variable is not over zero(0)
world.Checking = 1 //Stops repeating the proc
world << "<b>There is now an AFK Check in progress please talk in OOC to avoid being booted!" //This tells the world the message
spawn(50) //Sleep some amount of time you can replace this with your desired time
world<<"<b>Time is almost up please hurry!" //This tells the world the message
spawn(20) //Same as above
AFK_Check() //Calls the proc AFK_Check
spawn(500) //Same as above
world.Checking = 0 //Allows the proc to recall
AFK_Check(var/mob/M) //This proc determines who to boot and who to keep it also defines M as any mob in the world
if(M.client) // If it is a real player and not an NPC
if(M.Afk) //If the mobs Afk variable is greater than 0
world.AFK.Add(M) //It adds it to the list
if(!M.Afk) //If it is not Afk
AFK.Remove(M) //It takes the mob from the list
if(AFK == M) //If the world's Afk list consists of the mob
world<<"<b>[M] has been booted for being idle!" //This tells the world the message
AFK.Remove(M) //Removes the mob from the AFK list
del(M) //The mob gets deleted
else //If it doesnt consist of the mob
return //Return
else //If it isn't
return //Return
mob
verb
Activate_AFK_Check() //This is the name of the verb
set category = "GM" //This is the category the verb will be in
world.Call_AFK_Check() //This calls the proc
OOC(msg as text) //Defines the variable message as the text you enter
set category = "Commands" //Again the category
if(world.Checking) //If the world is checking
usr.Afk = 0 //Make it so its Afk = 0
world<<"<b>[usr]: [msg]" //Sends the message to the world
else
usr.Afk = 1 //Make it so its Afk = 1 until the next AFK Check
world<<"<b>[usr]: [msg]" //Sends the message to the world


Everytime I use world.Checking or world.AFK it says the variable is undefined however when I just leave it Checking or AFK it compiles but doesn't work, any ideas?
In response to SadoSoldier (#2)
One thing...nothing to help you...but are you sure you want to give Regular Players the Activate AFK thing w.e it is the verb? Cause' far as I know, they might spam it causing your game to crash...
In response to AlZeRith (#3)
I remove all GM verbs upon login then give them to the right people.

EDIT: And why is there nothing to help me? I coded it correctly it's just the variables.. I think..
In response to SadoSoldier (#4)
I meant what I was going to say...Everything is abled to be supproted...

-Edit

If I knew how to operate AFK Checks, I would've ben able to help you, but no, i'm jsut a novice Programmer :p
In response to AlZeRith (#5)
Same here :( I wish Schnitzelnagler was here...
In response to SadoSoldier (#6)
I need an AFK Checker on my game...THats why I'm keep scrolling through this Forum to see if there is any help...so far nope ^_^
In response to AlZeRith (#7)
Lol I usually don't try to code something like this, normally I would have looped it through a mob's proc or used it through the movement proc but I decided I didn't like those ideas and I wanted to try something new... I guess my reward was wasted time :\ none-the-less I will keep waiting till someone can help.
Check out the inactivity var in DM Help. It should be fairly simple to keep an eye on that and auto-boot the players that havn't done anything in x amount of time. I know this is a common way for AFKers to be booted. This is totally untested code that I just threw together. It might work... maybe not...

proc
afk_check()
for(var/client/c in world)
if(c.inactivity >= 9000)
c.mob << "You have been auto-booted for being AFK too long."
c.mob.Logout()
spawn(3000)
afk_check()


What this should do is check every 5 minutes all clients in the world and see if they have been AFK for 15 minutes or more, and if so, they get kicked out. Someone else might see something horribly wrong with it, but, I have never done something like this.
In response to Satans Spawn (#9)
I think that SadoSoldier wanted to go with a more direct attempt, trying to get players using simple macros to be booted as well.

mob
var
checking = 0

gm

verb
AFK_Check()
set category = "GM"
var/Li[0]
var/question = input("Compile a little AFK-check question please", "AFK-check question", "How much is [rand(1,5)] + [rand(1,5)]?") as text
for(var/client/c)
c.mob.checking = 1
spawn() Li[c.mob] = input(c, "Please answer this question, due to an AFK check:\n[question]", "AFK-check") as text
sleep(200)
for(var/client/c)
if(!(c.mob in Li))
if(c.mob.checking)
c.mob.checking = 0
world << "<b>[c.mob] has been booted for being idle!"
c.mob.Logout()

var/m
for(m in Li)
usr << "[m] replied: [Li[m]]"
Li.Cut()


Something along the lines of this.

Edited snippet to take care of players logging in during the check.
In response to Schnitzelnagler (#10)
Yay! Thanks Schnitzel :D