• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Request] /afk command.

Helga

GZH
Joined
Feb 19, 2009
Messages
622
Reaction score
1
Location
Sweden
Hello!

I've been searching for a /afk command but haven't found anything, so I'll ask here.

I was thinking about a /afk command that works like it does in World of Warcraft ;P

Example:
20:30 GM Helga: /afk eating
Then if someone writes to me he will get the message:
GM Helga is afk: eating
So it will be: <playername> is afk: <message>

Does this exists? If not, anyone wanna make one? Would be awesome!
 
Credits:
Damage~

Lua:
local time = 5 -- Seconds
local say_events = {}
local function SayText(cid)
    if isPlayer(cid) == TRUE then
         if say_events[getPlayerGUID(cid)] ~= nil then
             if isPlayer(cid) == TRUE then
                 doSendAnimatedText(getPlayerPosition(cid),"AFK", math.random(01,255))
             end
             say_events[getPlayerGUID(cid)] = addEvent(SayText, time * 1000 / 2, cid)       
         end                                                       
    end
    return TRUE
end
function onSay(cid, words, param, channel) 
    if(param == "") then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
    return TRUE
    end
     if (param == "on") then
        if (isPlayer(cid) == TRUE) then
            doSendAnimatedText(getPlayerPosition(cid),"AFK", math.random(01,255))
        end
        say_events[getPlayerGUID(cid)] = addEvent(SayText, time * 1000, cid)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You are AFK.")
        doCreatureSetNoMove(cid, true)
     elseif (param == "off") then
        stopEvent(say_events[getPlayerGUID(cid)])
        say_events[getPlayerGUID(cid)] = nil
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Welcome back!")
        doCreatureSetNoMove(cid, false)
    end
    return TRUE
end
 
Last edited:
this script works fine but i think it has a little thing i would add but i dont know how.. when you get into afk mode on for example /afk on... you can still use the same param over and over again so the player starts spaming tones of afk messages per second.... would be great if it can only be used once.. so as long as you are afk you cant use the same command again 'till you get back /afk off

BTW.. i dont know if its possible but would be awesome that if you are under afk mode and you move.. you automaticaly left the afk mode and go to normal... hope you get what i mean.. :)
 
Nice!
JDB could you add to script one function:
If player is afk then he can't move.

Ps. Sorry for my english xD
 
Please change script, becouse player say: /afk on, and /afk on, /afk on, /afk on ect. Please change this for only one /afk on.
If player tells the second time /afk on. Then script say: Sorry, you are afking now!

Please change this for me xD
 
Done

Lua:
local time = 3 -- Seconds
local say_events = {}
local function SayText(cid)
    if isPlayer(cid) == TRUE then
         if say_events[getPlayerGUID(cid)] ~= nil then
             if isPlayer(cid) == TRUE then
                 doSendAnimatedText(getPlayerPosition(cid),"AFK", math.random(01,255))
             end
             say_events[getPlayerGUID(cid)] = addEvent(SayText, time * 1000 / 2, cid)       
         end                                                       
    end
    return TRUE
end

local storage = 38417
function onSay(cid, words, param, channel)
local afkCheck = getPlayerStorageValue(cid, storage)
    if(param == "") then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
    return TRUE
    end
     if (param == "on") then
	if (afkCheck == -1) then
	    if (isPlayer(cid) == TRUE) then
		doSendAnimatedText(getPlayerPosition(cid),"AFK", math.random(01,255))
	    end
	    say_events[getPlayerGUID(cid)] = addEvent(SayText, time * 1000, cid)
	    doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You are now AFK.")
	    doCreatureSetNoMove(cid, true)
	    setPlayerStorageValue(cid, storage, 1)
	else
	    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are already AFK.")
	end
     elseif (param == "off") then
	stopEvent(say_events[getPlayerGUID(cid)])
	say_events[getPlayerGUID(cid)] = nil
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Welcome back!")
	doCreatureSetNoMove(cid, false)
	setPlayerStorageValue(cid, storage, -1)
    end
    return TRUE
end
 
Back
Top Bottom