TalkAction 8.54 AFK System

Ryxan

Spanish Crew
Joined
Dec 19, 2008
Messages
37
Best answers
0
Reaction score
0
Location
Spain - Barcelona
Credits:
Damadgerz
JDB
Ryxan
[AFK SYSTEM]

Working for TFS 0.3.+

First:
Open "Talkactions Folder" in the (Talkaction.xml) add:
XML:
Code:
<talkaction words="!afk" event="script" value="afk.lua"/>
Second: Open your Talkaction Folder/Script, and create new: "afk.lua" and copy and paste this.

AFK.LUA

Code:
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
If you want to change the Message:
Code:
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[SIZE="2"][FONT="Arial Black"][FONT="Comic Sans MS"][I][COLOR="Red"]Write here![/COLOR][/I][/FONT][/FONT][/SIZE].")
..

REMEMBER:
/commands:
Code:
1-!afk on [SIZE="2"][I](For Start the Script)[/I][/SIZE]
2-!afk off [SIZE="2"][I](For Stop the Script)[/I][/SIZE]

Sreenshoots:

Thanks,
Yours Ryxan.
 
Last edited:

cbrm

Top Class brunet scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,585
Best answers
3
Reaction score
851
Location
Caribbean Sea
better the globalevent one ^^
 

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
6,667
Best answers
202
Reaction score
1,375
Location
Norway, Oslo
Potential for improvement:

Suggestion: Status message.
/status "afk
/status "hunting
/status "buy hams!
/status "Selling magicsword!

After writing those commands, it pops up every sec or each 2 - 3 sec the message. So it works as a player status message.

Would be great idea. :D
 
OP
Ryxan

Ryxan

Spanish Crew
Joined
Dec 19, 2008
Messages
37
Best answers
0
Reaction score
0
Location
Spain - Barcelona
Potential for improvement:

Suggestion: Status message.
/status "afk
/status "hunting
/status "buy hams!
/status "Selling magicsword!

After writing those commands, it pops up every sec or each 2 - 3 sec the message. So it works as a player status message.

Would be great idea. :D

Yeah, it would be a great idea!

Example:
"!Hunting ON"
HUNTING.Lua
PHP:
local time = 10 -- 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),"Hunting!", 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),"Hunting",math.random(01,255))
            end
            say_events[getPlayerGUID(cid)] = addEvent(SayText, time * 1000, cid)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Hunting do not disturb.")
            doCreatureSetNoMove(cid, true)
            setPlayerStorageValue(cid, storage, 1)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are already Hunting Mode.")
        end
     elseif (param == "off") then
        stopEvent(say_events[getPlayerGUID(cid)])
        say_events[getPlayerGUID(cid)] = nil
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You stopped the Hunting.!")
        doCreatureSetNoMove(cid, false)
        setPlayerStorageValue(cid, storage, -1)
    end
    return TRUE
end
 
Last edited:

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,894
Best answers
4
Reaction score
817
you'll have memory leak with this script ;d
 
OP
Ryxan

Ryxan

Spanish Crew
Joined
Dec 19, 2008
Messages
37
Best answers
0
Reaction score
0
Location
Spain - Barcelona
you'll have memory leak with this script ;d

Its just a EXAMPLE.

And about the suggestion of Znote, Cykotitan can u help us with this?

Potential for improvement:

Suggestion: Status message.
/status "afk <done>
/status "hunting
/status "buy hams!
/status "Selling magicsword!

After writing those commands, it pops up every sec or each 2 - 3 sec the message. So it works as a player status message.

Would be great idea. :D
 
Last edited:

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,894
Best answers
4
Reaction score
817
If I help you with it, there'll be even more memory leaks.
 

zakius

Enter the Ninja!
Joined
Apr 30, 2009
Messages
2,635
Best answers
0
Reaction score
61
Location
with Taiga
remember that te animated text cannot be too long(if you want to allow longer text use doCreature say with orange text instead)
 

Tibia Rox

Member
Joined
Feb 4, 2009
Messages
1,181
Best answers
0
Reaction score
9
Location
U.S.A
Totally took my suggestion on the tibia forums!

Owell, nice!
 

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
Code:
local time = 10
function onThink(cid, interval)
	for _, cid in ipairs(getPlayersOnline()) do
		if(getPlayerIdleTime(cid) >= time * 60 * 1000) then
			doSendAnimatedText(getCreaturePosition(cid), "AFK", TEXTCOLOR_WHITE)
		end
		return true
	end
end
 

Fallen

Freelancer
Joined
Aug 21, 2009
Messages
3,713
Best answers
0
Reaction score
247
Location
Egypt
xDD
Lua:
local time = 10
local colors = {5, 18, 35, 66, 78, 89, 112, 120, 129, 144, 152, 154, 156, 180}
function onThink(cid, interval)
	for _, cid in ipairs(getPlayersOnline()) do
		if(getPlayerIdleTime(cid) >= time * 60 * 1000) then
			doSendAnimatedText(getCreaturePosition(cid), "AFK", colors[math.random(1, #colors)])
		end
		return true
	end
end
 

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
No need for local, math.random(01,255) :huh:
 

Dramix

New Member
Joined
Jun 26, 2009
Messages
289
Best answers
0
Reaction score
1
Credits:


[AFK SYSTEM]

Working for TFS 0.3.+

First:
Open "Talkactions Folder" in the (Talkaction.xml) add:
XML:
Code:
<talkaction words="!afk" event="script" value="afk.lua"/>
Second: Open your Talkaction Folder/Script, and create new: "afk.lua" and copy and paste this.

AFK.LUA

Code:
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
If you want to change the Message:
Code:
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "[SIZE="2"][FONT="Arial Black"][FONT="Comic Sans MS"][I][COLOR="Red"]Write here![/COLOR][/I][/FONT][/FONT][/SIZE].")
..

REMEMBER:
/commands:
Code:
1-!afk on [SIZE="2"][I](For Start the Script)[/I][/SIZE]
2-!afk off [SIZE="2"][I](For Stop the Script)[/I][/SIZE]

Sreenshoots:

Thanks,
Yours Ryxan.

you can use this while pvping?, can u make new one, that u cant use while pvping?
 
Top