• 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!

[LUA] Simple tool for gamemasters

wdvx

Sniper 7.4 War
Joined
Mar 5, 2013
Messages
263
Reaction score
14
Wrote a simple script in lua that can be used by gamemasters when they're afk.
It will send animated text over your head saying "AFK" in red text color
Script only tested on Avesta revision 93 ~

Code:
function onSay(cid, item, param)
    if param == "start" then
        c = function()
            doSendAnimatedText(getPlayerPosition(cid), "AFK", TEXTCOLOR_RED)
            k = addEvent(c, 2000)
        end
        addEvent(c, 2000)
    elseif param == "end" then
        stopEvent(k)
    end
end
 
what if gms log out or are kicked?
 
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
 
People have to stop using that on and off bullshit(@OP, @Amiroslo). I haven't read up on Events yet(based it on OP), but here's mine:

PHP:
local storage = 38417
function onSay(cid, words, param, channel)
    if ( words and isPlayer(cid) ) then
        if getPlayerStorageValue(cid, storage) == -1 then
        local function call()
        doSendAnimatedText(getPlayerPosition(cid), 'AFK', TEXTCOLOR_RED)
        event = addEvent(call, 2000)
        end
        addEvent(call, 2000)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'ON')
        doCreatureSetNoMove(cid, true)
        setPlayerStorageValue(cid, storage, 1)
        else
        stopEvent(event)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'OFF')
        doCreatureSetNoMove(cid, false)
        setPlayerStorageValue(cid, storage, -1)
        end
    end 
    return true
end
 
Why not just go invis/gm island instead of standing in dp afk showing off?
 
I'm using this AFK-Script and quite happy with it :) Credits to Sonik as far as I remember :D

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
 
Back
Top