• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction 0.4/0.3.6 AFK System!

JoSePh15_

Well-Known Member
Joined
Jan 28, 2010
Messages
1,766
Reaction score
59
Thats the talkaction script
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
Credits for the talkaction script goes to
Damadgerz
JDB
Ryxan

And for me adding that...
in Creaturescripts add
LUA:
function onLogin(cid)
	if getPlayerStorageValue(cid, 38417) > 0 then
		doCreatureSetNoMove(cid, true)
		doSendAnimatedText(getPlayerPosition(cid),"AFK", math.random(01,255))
	end
return TRUE
end
Ok let me explain... there was a bug in the script is that when someone logouts and logs in again he doesn't get the afk on command even if he didnt say !afk off, and he can move freely so by adding this creaturescripts it will be fixed

@edit
Thanks Damadger for that idea :o
make a new file call it afk.lua and paste this
LUA:
function onLogout(cid)
	if getPlayerStorageValue(cid, 38417) > 0 then
		setPlayerStorageValue(cid, 38417, -1)
	end
return TRUE
end
Now go to login.lua and add
LUA:
registerCreatureEvent(cid, "Afk")
just after
LUA:
registerCreatureEvent(cid, "ReportBug")
now write in creaturescripts.xml
LUA:
<event type="logout" name="Afk" event="script" value="afk.lua"/>
And that's all.
Rep++ me if i helped ya And thanks Damadger for that idea :D
 
Last edited:
I think you should better make it on logout if is afk then remove the storage. :)

As obviously if somone logout and login again sure he isnt afk and that will be annoying
 
auto idel one is in the thread where you get that script from , there is like 3 scripts of auto idel there
 
better too

to make players can push u

i tested it script like that before and found that players can go in some places that have one Squ and stand and make AFK then no1 can push them :S

Hope you understand sorry for bad english
 
Np, I'm doing an auto afk script which is compatible with 0.4/0.3.6 PL1 cuz chojrak's script didn't work for 0.4 :D
Just wait :P
 
Simply a globalevent and you set the interval .
For 0.4
LUA:
local timee = 15   -- idle time where after it player willl have auto afk message on him
function onThink(interval)

  for _, cid in ipairs(getPlayersOnline()) do
     if getPlayerIdleTime(cid) > timee * 1000 then
	    doSendAnimatedText(getThingPos(cid),"AFK",math.random(1,256))
	 end
  end
 return true
 end
 
Last edited:
hahaaha it just has the same problem i had :D
LUA:
local time =  60 -- idle time where after it player willl have auto afk message on him IN SECONDS
function onThink(interval)
 
  for _, cid in ipairs(getPlayersOnline()) do
     if getPlayerIdleTime(cid) > time * 1000 then
	    doSendAnimatedText(getThingPos(cid),"AFK",math.random(1,256))
	 end
  end
 return true
 end
i fixed the time up there :P
And it has a problem it spams AFK, im trieng to fix that :D
 
lol this will be like 8382 min ..... mine works fine .
it spam it because in 0.4 server the global event interval is time * 1000 = time in seconds


So every 1 sec will be : interval="1000"
 
Ye read well what i say..

Code:
 <globalevent name="test" interval="4000" event="script" value="timer.lua"/>
 
Then you fail.... CreatureEvent dosnt have intervals

So event if you try to make addevent or somthng it will be alright on first excution but after that it will spam. Use global as in my script.
 
i can use the command in war, how to make that u cant use the spell while pz?
 
Back
Top