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

spawn time

ConAn Edujawa

Member
Joined
Feb 23, 2015
Messages
457
Reaction score
17
how i can know spawn time by talkaction
example
i have one boss name Horshema
when say !heroshema get msg heroshema will spwan in x min and x second

tfs .4
 
Last edited:
XML:
<talkaction words="!heroshema" event="script" value="heroshema.lua"/>
Lua:
function onSay(cid, words, param, channel)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "heroshema will spwan in x min and x second")
    return true
end
 
XML:
<talkaction words="!heroshema" event="script" value="heroshema.lua"/>
Lua:
function onSay(cid, words, param, channel)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "heroshema will spwan in x min and x second")
    return true
end
no bro i mean when someone kill heroshema and i need to know when heroshema will spawn again
 
login.lua near the bottom with other registered events.
Lua:
registerCreatureEvent(cid, "heroshema")

creaturescripts.xml
XML:
<event type="kill" name="heroshema" event="script" value="heroshema.lua"/>

creaturescripts/scripts/heroshema.lua
Lua:
local global_storage = 45001
local global_storage_timer = 600 -- time to respawn in seconds.

function onKill(cid, target, damage, flags)
    if isPlayer(target) then
        return true
    end
    if getCreatureName(target):lower() == "heroshema" then
        local new_time = os.time() + global_storage_timer
        setGlobalStorageValue(global_storage, new_time)
    end
    return true
end

talkactions.xml
XML:
<talkaction words="!heroshema" event="script" value="heroshema.lua"/>

talkactions/scripts/heroshema.lua
Lua:
local global_storage = 45001

function onSay(cid, words, param, channel)
    local timer = getGlobalStorageValue(global_storage) - os.time()
    if timer > 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Heroshema will spawn in ".. os.date("!%Hh %Mm %Ss", timer) ..".")
        return true
    end
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Heroshema has spawned.")
    return true
end
 
Last edited:
login.lua near the bottom with other registered events.
Lua:
registerCreatureEvent(cid, "heroshema")

creaturescripts.xml
XML:
<event type="kill" name="heroshema" event="script" value="heroshema.lua"/>

creaturescripts/scripts/heroshema.lua
Lua:
local global_storage = 45001
local global_storage_timer = 600 -- time to respawn in seconds.

function onKill(cid, target, damage, flags)
    if isPlayer(target) then
        return true
    end
    if getCreatureName(target):lower() == "heroshema" then
        local new_time = os.time() + global_storage_timer
        setGlobalStorageValue(global_storage, new_time)
    end
    return true
end

talkactions.xml
XML:
<talkaction words="!heroshema" event="script" value="heroshema.lua"/>

talkactions/scripts/heroshema.lua
Lua:
local global_storage = 45001

function onSay(cid, words, param, channel)
    local timer = getGlobalStorageValue(global_storage) - os.time()
    if timer > 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Heroshema will spawn in ".. os.date("!%Hh %Mm %Ss", timer) ..".")
        return true
    end
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Heroshema has spawned.")
    return true
end
nice bro but if i have more boss and i need to add different time like Heroshema 10 min and Getry 20 min and Amandyi 30 min and need all come in doShowTextDialog how i can do it
 
last time I'm replying.

Constantly adding new things to the script after the first request is annoying.
I don't want to come back and constantly rescript something because you were too lazy to request it properly in the first place.

Lua:
registerCreatureEvent(cid, "boss_timers")
XML:
<event type="kill" name="boss_timers" event="script" value="boss_timers.lua"/>
Lua:
local config = {
    -- ["boss_name - Must be lowercase letters"] = {global_storage, timer_in_seconds},
    ["heroshema"] = {45001, 600},
    ["getry"]     = {45002, 1200},
    ["amandyi"]   = {45003, 1800}
}

function onKill(cid, target, damage, flags)
    if isPlayer(target) then
        return true
    end
    local x = config[getCreatureName(target):lower()]
    if x then
        local new_time = os.time() + x[2]
        setGlobalStorageValue(x[1], new_time)
    end
    return true
end
XML:
<talkaction words="!bosstimer" event="script" value="bosstimer.lua"/>
Lua:
local config = {
    -- ["boss_name - Must be lowercase letters"] = {global_storage},
    ["heroshema"] = {45001},
    ["getry"]     = {45002},
    ["amandyi"]   = {45003}
}

function onSay(cid, words, param, channel)
    if param == "" then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Requires an additional parameter. example: !bosstimer heroshema")
        return true
    end
    param = param:lower()
    local x = config[param]
    if x then
        local timer = getGlobalStorageValue(x[1]) - os.time()
        if timer > 0 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "" .. (param:gsub("^%l", string.upper)) .. " will spawn in ".. os.date("!%Hh %Mm %Ss", timer) ..".")
            return true
        end
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, (param:gsub("^%l", string.upper)) .. " has spawned.")
        return true
    end
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Boss timer " .. param .. " does not exist.")
    return true
end
 
last time I'm replying.

Constantly adding new things to the script after the first request is annoying.
I don't want to come back and constantly rescript something because you were too lazy to request it properly in the first place.

Lua:
registerCreatureEvent(cid, "boss_timers")
XML:
<event type="kill" name="boss_timers" event="script" value="boss_timers.lua"/>
Lua:
local config = {
    -- ["boss_name - Must be lowercase letters"] = {global_storage, timer_in_seconds},
    ["heroshema"] = {45001, 600},
    ["getry"]     = {45002, 1200},
    ["amandyi"]   = {45003, 1800}
}

function onKill(cid, target, damage, flags)
    if isPlayer(target) then
        return true
    end
    local x = config[getCreatureName(target):lower()]
    if x then
        local new_time = os.time() + x[2]
        setGlobalStorageValue(x[1], new_time)
    end
    return true
end
XML:
<talkaction words="!bosstimer" event="script" value="bosstimer.lua"/>
Lua:
local config = {
    -- ["boss_name - Must be lowercase letters"] = {global_storage},
    ["heroshema"] = {45001},
    ["getry"]     = {45002},
    ["amandyi"]   = {45003}
}

function onSay(cid, words, param, channel)
    if param == "" then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Requires an additional parameter. example: !bosstimer heroshema")
        return true
    end
    param = param:lower()
    local x = config[param]
    if x then
        local timer = getGlobalStorageValue(x[1]) - os.time()
        if timer > 0 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "" .. (param:gsub("^%l", string.upper)) .. " will spawn in ".. os.date("!%Hh %Mm %Ss", timer) ..".")
            return true
        end
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, (param:gsub("^%l", string.upper)) .. " has spawned.")
        return true
    end
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Boss timer " .. param .. " does not exist.")
    return true
end
thx bro but i need all in one doShowTextDialog when say !monsterlive get doShowTextDialog have all boss is boss alive say alive if dead say spawn in x min
 
thx bro but i need all in one doShowTextDialog when say !monsterlive get doShowTextDialog have all boss is boss alive say alive if dead say spawn in x min
Sigh.
Lua:
local config = {
    {"heroshema", 45001},
    {"getry", 45002},
    {"amandyi", 45003}
}

function onSay(cid, words, param, channel)
    local text = "Boss Timers:\n\n"
    for i = 1, #config do
        local timer, boss = getGlobalStorageValue(config[i][2]) - os.time(), config[i][1]
        if text ~= "Boss Timers:\n\n" then
            text = text .. "\n"
        end
        if timer > 0 then
            text = text .. "" .. (boss:gsub("^%l", string.upper)) .. " will spawn in ".. os.date("!%Hh %Mm %Ss", timer) .."."
        else
            text = text .. "" .. (boss:gsub("^%l", string.upper)) .. " has spawned."
        end
    end
    doShowTextDialog(cid, 2810, text)
end
 
Sigh.
Lua:
local config = {
    {"heroshema", 45001},
    {"getry", 45002},
    {"amandyi", 45003}
}

function onSay(cid, words, param, channel)
    local text = "Boss Timers:\n\n"
    for i = 1, #config do
        local timer, boss = getGlobalStorageValue(config[i][2]) - os.time(), config[i][1]
        if text ~= "Boss Timers:\n\n" then
            text = text .. "\n"
        end
        if timer > 0 then
            text = text .. "" .. (boss:gsub("^%l", string.upper)) .. " will spawn in ".. os.date("!%Hh %Mm %Ss", timer) .."."
        else
            text = text .. "" .. (boss:gsub("^%l", string.upper)) .. " has spawned."
        end
    end
    doShowTextDialog(cid, 2810, text)
end
always say heroshema has spawned. and i killed heroshema
 
Back
Top