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

RevScripts Item that speaks by itself 1.5 7.72

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
941
Solutions
7
Reaction score
129
Location
Brazil
YouTube
caruniawikibr
Just as there are dolls that speak when you click on them, I would like to know if anyone has a script for items that speak alone, in this doll script format it would be interesting, to have several items that speak alone, without needing to use it or create a script per item.

Lua:
local dollsTable = {
    [5080] = {"Hug me!"},
    [5379] = {"NO ONE WILL STOP ME THIS TIME!", "THE POWER IS MINE!", "THE POWER IN CARUNIA!", "Mwahaha!"},
    [5705] = {"Only warriors of great faith and pure heart can remove the sword!"},
    [5708] = {"3478 67 90871 97664 3466 0 345!", "486486 holds the answers to some of your questions. But what have you done to justify the attention of our ancient race?", "Oculi plus vident, quam oculus.", "Oh...It is you again, |PLAYERNAME|. Get out of my sight, two-eyed creature.", "The price for that knowledge is your mind, body and soul. Still want to proceed?"},
}


Lua:
local cooldownTime = 7 -- Cooldown time in seconds
local lastUsage = {} -- Table to track last usage time for each player

local dolls = Action()

function dolls.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local sounds = dollsTable[item.itemid]
    if not sounds then
        return false
    end

    if fromPosition.x == CONTAINER_POSITION then
        fromPosition = player:getPosition()
    end

    local currentTime = os.time()
    local lastTime = lastUsage[player:getId()] or 0

    if currentTime - lastTime < cooldownTime then
        
        return false
    end

    local chance = math.random(#sounds)
    local sound = sounds[chance]

    sound = sound:gsub('|PLAYERNAME|', player:getName())
    player:say(sound, TALKTYPE_MONSTER_SAY, false, 0, fromPosition)
    lastUsage[player:getId()] = currentTime
    return true
end

for k, v in pairs(dollsTable) do
    dolls:id(k)
end
dolls:register()
 
Back
Top