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

TFS 0.X Talkactions On/Off

Forkz

Well-Known Member
Joined
Jun 29, 2020
Messages
360
Solutions
1
Reaction score
76
Hi otlanders,

I'm using this system below as a vocation aura, but I would like to make a type command! Auraon - !auraoff could someone help me?

data/creaturescripts
Lua:
local config = {
    delay = 1000,
    colors = {
        [9] = 101,
        [10] = 66,
        [11] = 180,
        [12] = 210
    },

    effects = {"'  .   ,", ",  .  '"}
}

function sendUltimateEffect(cid)
    if isPlayer(cid) then
        local color = config.colors[getPlayerVocation(cid)]
        if color then
            doSendAnimatedText(getThingPos(cid), config.effects[math.random(#config.effects)], color)
            addEvent(sendUltimateEffect, config.delay, cid)
        end
    end
end

function onLogin(cid)
    sendUltimateEffect(cid)
    return true
end
 
data/talkactions (!auraon)
Lua:
function onSay(cid, words, param, channel)
    setPlayerStorageValue(cid, auraConfig.storage, 1)
    sendUltimateEffect(cid)
    return true
end


data/talkactions (!auraoff)
Lua:
function onSay(cid, words, param, channel)
    setPlayerStorageValue(cid, auraConfig.storage, 0)
    return true
end


data/creaturescripts (instead of what you have, you can also delete it and add the function call to login.lua)
Lua:
function onLogin(cid)
    sendUltimateEffect(cid)
    return true
end

data/libs/auraSystem.lua (or whatever other name u want)
Lua:
auraConfig = {
    delay = 1000,
    storage = 123123, --< change it
    colors = {
        [9] = 101,
        [10] = 66,
        [11] = 180,
        [12] = 210
    },

    effects = {"'  .   ,", ",  .  '"}
}

function sendUltimateEffect(cid)
    if isPlayer(cid) then
        local color = auraConfig.colors[getPlayerVocation(cid)]
        if color then
            doSendAnimatedText(getThingPos(cid), auraConfig.effects[math.random(#auraConfig.effects)], color)
            if getPlayerStorageValue(cid, auraConfig.storage) >= 1 then
                addEvent(sendUltimateEffect, auraConfig.delay, cid)
            end
        end
    end
end
 
data/talkactions (!auraon)
Lua:
function onSay(cid, words, param, channel)
    setPlayerStorageValue(cid, auraConfig.storage, 1)
    sendUltimateEffect(cid)
    return true
end


data/talkactions (!auraoff)
Lua:
function onSay(cid, words, param, channel)
    setPlayerStorageValue(cid, auraConfig.storage, 0)
    return true
end


data/creaturescripts (instead of what you have, you can also delete it and add the function call to login.lua)
Lua:
function onLogin(cid)
    sendUltimateEffect(cid)
    return true
end

data/libs/auraSystem.lua (or whatever other name u want)
Lua:
auraConfig = {
    delay = 1000,
    storage = 123123, --< change it
    colors = {
        [9] = 101,
        [10] = 66,
        [11] = 180,
        [12] = 210
    },

    effects = {"'  .   ,", ",  .  '"}
}

function sendUltimateEffect(cid)
    if isPlayer(cid) then
        local color = auraConfig.colors[getPlayerVocation(cid)]
        if color then
            doSendAnimatedText(getThingPos(cid), auraConfig.effects[math.random(#auraConfig.effects)], color)
            if getPlayerStorageValue(cid, auraConfig.storage) >= 1 then
                addEvent(sendUltimateEffect, auraConfig.delay, cid)
            end
        end
    end
end
Code:
[Error - TalkAction Interface]
data/talkactions/scripts/auraon.lua:onSay
Description:
data/talkactions/scripts/auraon.lua:2: attempt to index global 'auraConfig' (a nil value)
stack traceback:
        data/talkactions/scripts/auraon.lua:2: in function <data/talkactions/scripts/auraon.lua:1>
 
Code:
[Error - TalkAction Interface]
data/talkactions/scripts/auraon.lua:onSay
Description:
data/talkactions/scripts/auraon.lua:2: attempt to index global 'auraConfig' (a nil value)
stack traceback:
        data/talkactions/scripts/auraon.lua:2: in function <data/talkactions/scripts/auraon.lua:1>
When you create the file in data/lib/core/auraSystem.lua you must also register this file in data/lib/core/core.lua

dofile('data/lib/core/auraSystem.lua')
 
Back
Top