Ir para conteúdo
  • Cadastre-se

Scripting Countdown horário dos próximos eventos


Posts Recomendados

Fiz tudo isso que vc disse e deu isso aqui toda vez que chegava perto do lugar que era pra aparecer a mensagem:

Spoiler

[Error - GlobalEvent Interface]
data/globalevents/scripts/eventcheck.lua:onThink
Description:
data/globalevents/scripts/eventcheck.lua:28: attempt to call global 'timeString' (a nil value)
stack traceback:
        data/globalevents/scripts/eventcheck.lua:28: in function <data/globalevents/scripts/eventcheck.lua:17>

 

meu eventcheck ficou assim com os horários dos meus eventos:

Spoiler

local EventsListalist = {
        {time = "01:00", name = "Snowball Event"},        
        {time = "17:00", name = "Capture The Flag"},
        {time = "15:00", name = "FireStorm Event"},
        {time = "20:00", name = "Defend The Tower"},
        {time = "14:00", name = "Snowball Event"},
        {time = "12:00", name = "Capture The Flag"},
        {time = "19:00", name = "FireStorm Event"},
        {time = "11:00", name = "Battlefield Event"},
        {time = "18:00", name = "Snowball Event"},
        {time = "21:30", name = "Mundo Castle"},
        {time = "19:30", name = "Battlefield Event"}
}
    
local position = {x = 166, y = 49, z = 7} -- posição do mapa onde o efeito vai sair

function onThink(interval, lastExecution) 
local people = getPlayersOnline()
if #people == 0 then
    return true
end
    
local Count = 0
for _, t in ipairs(EventsListalist) do
    local eventTime = hourToNumber(t.time)
    local realTime = hourToNumber(os.date("%H:%M:%S"))
    if eventTime >= realTime then
        doCreatureSay(people[1], "Proximo evento as {"..t.time.."h} "..t.name..", faltam "..timeString(eventTime - realTime)..".", TALKTYPE_ORANGE_1, false, 0, position) -- não use acentos aqui ou eles serão alterados por simbolos ingame
        return true
    end
    Count = Count + 1
end

return true
end

 

além do meu server fechar sozinho sem nenhum tipo de outro erro ocorrer na distro, só parou de dar erro quando eu tirei a linha do globalevents e voltei o arquivo das libs pro que era antes.

 

minha lib ficou assim, é a penultima function:

Spoiler

 local query = db.getResult("SELECT `name` FROM `guilds` WHERE `id` = '"..gid.."'")
    if query:getID() == -1 then
        return false
    end
    local name = query:getDataString("name")
    query:free()
    return name
end

function isWalkable(pos, creature, proj, pz)
    if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
    if getTopCreature(pos).uid > 0 and creature then return false end
    if getTileInfo(pos).protection and pz then return false, true end
    local n = not proj and 3 or 2
    for i = 0, 255 do
        pos.stackpos = i
        local tile = getTileThingByPos(pos)
        if tile.itemid ~= 0 and not isCreature(tile.uid) then
            if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                return false
            end
        end
    end
    return true
end

function isInArray(array, value, caseSensitive)
    if(caseSensitive == nil or caseSensitive == false) and type(value) == "string" then
        local lowerValue = value:lower()
        for _, _value in ipairs(array) do
            if type(_value) == "string" and lowerValue == _value:lower() then
                return true
            end
        end
    else
        for _, _value in ipairs(array) do
            if (value == _value) then return true end
        end
    end

    return false
end

ARMY = {
    [1] = {50, 350, "Soldado Raso", 1}, -- [Número] = {Pontos Kill, Points para UP, "Nome",PLATINIUM COINS POR KILL},
    [2] = {50, 1500, "Soldado de Primeira Classe", 50000000},
    [3] = {50, 2000, "Cabo", 60000000},
    [4] = {50, 3000, "Sargento", 70000000},
    [5] = {50, 3500, "Sargento-Ajudante 1", 90000000},
    [6] = {50, 5000, "Sargento-Ajudante 2", 11000000},
    [7] = {50, 5500, "Sargento-Chefe", 15000000},
    [8] = {50, 6000, "Sargento-Mestre 1", 18000000},
    [9] = {50, 6500, "Sargento-Mestre 2", 20000000},
    [10] = {50, 7000, "Sargento-Mestre 3", 22000000},
    [11] = {50, 7600, "Sargento-Mestre 4", 24000000},
    [12] = {50, 8200, "Sargento-Mor do Comando", 26000000},
    [13] = {50, 9000, "Segundo-Tenente 1", 28000000},
    [14] = {50, 9600, "Segundo-Tenente 2", 30000000},
    [15] = {50, 10200, "Segundo-Tenente 3", 32000000},
    [16] = {50, 11000, "Segundo-Tenente 4", 34000000},
    [17] = {50, 11500, "Primeiro-Tenente 1", 36000000},
    [18] = {50, 12000, "Primeiro-Tenente 2", 38000000},
    [19] = {50, 13000, "Primeiro-Tenente 3", 40000000},
    [20] = {50, 14000, "Primeiro-Tenente 4", 45000000},
    [21] = {50, 15000, "Primeiro-Tenente 5", 55000000},
    [22] = {50, 16000, "Capitao 1", 60000000},
    [23] = {50, 17000, "Capitao 2", 70000000},
    [24] = {50, 18000, "Capitao 3", 80000000},
    [25] = {50, 19000, "Capitao 4", 90000000},
    [26] = {50, 20000, "Capitao 5", 100000000},
    [27] = {50, 21000, "Major 1", 110000000},
    [28] = {50, 21500, "Major 2", 120000000},
    [29] = {50, 22000, "Major 3", 130000000},
    [30] = {50, 23000, "Major 4", 140000000},
    [31] = {50, 23500, "Major 5", 150000000},
    [32] = {50, 24000, "Tenente-Coronel 1", 160000000},
    [33] = {50, 25000, "Tenente-Coronel 2", 170000000},
    [34] = {50, 26000, "Tenente-Coronel 3", 180000000},
    [35] = {50, 27000, "Tenente-Coronel 4", 190000000},
    [36] = {50, 28000, "Tenente-Coronel 5", 200000000},
    [37] = {50, 29000, "Coronel 1", 210000000},
    [38] = {50, 30000, "Coronel 2", 220000000},
    [39] = {50, 31000, "Coronel 3", 230000000},
    [40] = {50, 32000, "Coronel 4", 400000000},
    [41] = {50, 35000, "Coronel 5", 500000000},
    [42] = {50, 100000, "General", 1000000000},
    
    
}                           
ARMY_LEVEL = 2014159
ARMY_EXPERIENCE = 2014160

function doAddPoints(cid, points)
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end

function doPlayerGiveItem(cid, itemid, amount, subType)
    local item = 0
    if(isItemStackable(itemid)) then
        item = doCreateItemEx(itemid, amount)
        if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
            return false
        end
    else
        for i = 1, amount do
            item = doCreateItemEx(itemid, subType)
            if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
                return false
            end
        end
    end

    return true
end


function doPlayerGiveItemContainer(cid, containerid, itemid, amount, subType)
    for i = 1, amount do
        local container = doCreateItemEx(containerid, 1)
        for x = 1, getContainerCapById(containerid) do
            doAddContainerItem(container, itemid, subType)
        end

        if(doPlayerAddItemEx(cid, container, true) ~= RETURNVALUE_NOERROR) then
            return false
        end
    end

    return true
end

function doPlayerTakeItem(cid, itemid, amount)
    return getPlayerItemCount(cid, itemid) >= amount and doPlayerRemoveItem(cid, itemid, amount)
end

function doPlayerSellItem(cid, itemid, count, cost)
    if(not doPlayerTakeItem(cid, itemid, count)) then
        return false
    end

    if(not doPlayerAddMoney(cid, cost)) then
        error('[doPlayerSellItem] Could not add money to: ' .. getPlayerName(cid) .. ' (' .. cost .. 'gp).')
    end

    return true
end

function doPlayerWithdrawMoney(cid, amount)
    if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
        return false
    end

    local balance = getPlayerBalance(cid)
    if(amount > balance or not doPlayerAddMoney(cid, amount)) then
        return false
    end

    doPlayerSetBalance(cid, balance - amount)
    return true
end

function doPlayerDepositMoney(cid, amount)
    if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
        return false
    end

    if(not doPlayerRemoveMoney(cid, amount)) then
        return false
    end

    doPlayerSetBalance(cid, getPlayerBalance(cid) + amount)
    return true
end

function doPlayerAddStamina(cid, minutes)
    return doPlayerSetStamina(cid, getPlayerStamina(cid) + minutes)
end

function isPremium(cid)
    return (isPlayer(cid) and (getPlayerPremiumDays(cid) > 0 or getBooleanFromString(getConfigValue('freePremium'))))
end

function getMonthDayEnding(day)
    if(day == "01" or day == "21" or day == "31") then
        return "st"
    elseif(day == "02" or day == "22") then
        return "nd"
    elseif(day == "03" or day == "23") then
        return "rd"
    end

    return "th"
end

function getMonthString(m)
    return os.date("%B", os.time{year = 1970, month = m, day = 1})
end

function getArticle(str)
    return str:find("[AaEeIiOoUuYy]") == 1 and "an" or "a"
end

function doNumberFormat(i)
    local str, found = string.gsub(i, "(%d)(%d%d%d)$", "%1,%2", 1), 0
    repeat
        str, found = string.gsub(str, "(%d)(%d%d%d),", "%1,%2,", 1)
    until found == 0
    return str
end

function doPlayerAddAddons(cid, addon)
    for i = 0, table.maxn(maleOutfits) do
        doPlayerAddOutfit(cid, maleOutfits, addon)
    end

    for i = 0, table.maxn(femaleOutfits) do
        doPlayerAddOutfit(cid, femaleOutfits, addon)
    end
end

function getTibiaTime(num)
    local minutes, hours = getWorldTime(), 0
    while (minutes > 60) do
        hours = hours + 1
        minutes = minutes - 60
    end

    if(num) then
        return {hours = hours, minutes = minutes}
    end

    return {hours =  hours < 10 and '0' .. hours or '' .. hours, minutes = minutes < 10 and '0' .. minutes or '' .. minutes}
end

function doWriteLogFile(file, text)
    local f = io.open(file, "a+")
    if(not f) then
        return false
    end

    f:write("[" .. os.date("%d/%m/%Y %H:%M:%S") .. "] " .. text .. "\n")
    f:close()
    return true
end

function getExperienceForLevel(lv)
    lv = lv - 1
    return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end

function doMutePlayer(cid, time)
    local condition = createConditionObject(CONDITION_MUTED, (time == -1 and time or time * 1000))
    return doAddCondition(cid, condition, false)

end

function doSummonCreature(name, pos)
    local cid = doCreateMonster(name, pos, false, false)
    if(not cid) then
        cid = doCreateNpc(name, pos)
    end

    return cid
end

function getPlayersOnlineEx()
    local players = {}
    for i, cid in ipairs(getPlayersOnline()) do
        table.insert(players, getCreatureName(cid))
    end

    return players
end

function getPlayerByName(name)
    local cid = getCreatureByName(name)
    return isPlayer(cid) and cid or nil
end

function isPlayer(cid)
    return isCreature(cid) and cid >= AUTOID_PLAYERS and cid < AUTOID_MONSTERS
end

function isPlayerGhost(cid)
    return isPlayer(cid) and (getCreatureCondition(cid, CONDITION_GAMEMASTER, GAMEMASTER_INVISIBLE, CONDITIONID_DEFAULT) or getPlayerFlagValue(cid, PLAYERFLAG_CANNOTBESEEN))
end

function isMonster(cid)
    return isCreature(cid) and cid >= AUTOID_MONSTERS and cid < AUTOID_NPCS
end

function isNpc(cid)
    -- Npc IDs are over int32_t range (which is default for lua_pushnumber),
    -- therefore number is always a negative value.
    return isCreature(cid) and (cid < 0 or cid >= AUTOID_NPCS)
end

function isUnderWater(cid)
    return isInArray(underWater, getTileInfo(getCreaturePosition(cid)).itemid)
end

function doPlayerAddLevel(cid, amount, round)
    local experience, level, amount = 0, getPlayerLevel(cid), amount or 1
    if(amount > 0) then
        experience = getExperienceForLevel(level + amount) - (round and getPlayerExperience(cid) or getExperienceForLevel(level))
    else
        experience = -((round and getPlayerExperience(cid) or getExperienceForLevel(level)) - getExperienceForLevel(level + amount))
    end

    return doPlayerAddExperience(cid, experience)
end

function doPlayerAddMagLevel(cid, amount)
    local amount = amount or 1
    for i = 1, amount do
        doPlayerAddSpentMana(cid, getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid), false)
    end

    return true
end

function doPlayerAddSkill(cid, skill, amount, round)
    local amount = amount or 1
    if(skill == SKILL__LEVEL) then
        return doPlayerAddLevel(cid, amount, round)
    elseif(skill == SKILL__MAGLEVEL) then
        return doPlayerAddMagLevel(cid, amount)
    end

    for i = 1, amount do
        doPlayerAddSkillTry(cid, skill, getPlayerRequiredSkillTries(cid, skill, getPlayerSkillLevel(cid, skill) + 1) - getPlayerSkillTries(cid, skill), false)
    end

    return true
end

function isPrivateChannel(channelId)
    return channelId >= CHANNEL_PRIVATE
end

function doBroadcastMessage(text, class)
    local class = class or MESSAGE_STATUS_WARNING
    if(type(class) == 'string') then
        local className = MESSAGE_TYPES[class]
        if(className == nil) then
            return false
        end

        class = className
    elseif(class < MESSAGE_FIRST or class > MESSAGE_LAST) then
        return false
    end

    for _, pid in ipairs(getPlayersOnline()) do
        doPlayerSendTextMessage(pid, class, text)
    end

    print("> Broadcasted message: \"" .. text .. "\".")
    return true
end

function doPlayerBroadcastMessage(cid, text, class, checkFlag, ghost)
    local checkFlag, ghost, class = checkFlag or true, ghost or false, class or TALKTYPE_BROADCAST
    if(checkFlag and not getPlayerFlagValue(cid, PLAYERFLAG_CANBROADCAST)) then
        return false
    end

    if(type(class) == 'string') then
        local className = TALKTYPE_TYPES[class]
        if(className == nil) then
            return false
        end

        class = className
    elseif(class < TALKTYPE_FIRST or class > TALKTYPE_LAST) then
        return false
    end

    for _, pid in ipairs(getPlayersOnline()) do
        doCreatureSay(cid, text, class, ghost, pid)
    end

    print("> " .. getCreatureName(cid) .. " broadcasted message: \"" .. text .. "\".")
    return true
end

function doCopyItem(item, attributes)
    local attributes = ((type(attributes) == 'table') and attributes or { "aid" })

    local ret = doCreateItemEx(item.itemid, item.type)
    for _, key in ipairs(attributes) do
        local value = getItemAttribute(item.uid, key)
        if(value ~= nil) then
            doItemSetAttribute(ret, key, value)
        end
    end

    if(isContainer(item.uid)) then
        for i = (getContainerSize(item.uid) - 1), 0, -1 do
            local tmp = getContainerItem(item.uid, i)
            if(tmp.itemid > 0) then
                doAddContainerItemEx(ret, doCopyItem(tmp, true).uid)
            end
        end
    end

    return getThing(ret)
end

function doSetItemText(uid, text, writer, date)
    local thing = getThing(uid)
    if(thing.itemid < 100) then
        return false
    end

    doItemSetAttribute(uid, "text", text)
    if(writer ~= nil) then
        doItemSetAttribute(uid, "writer", tostring(writer))
        if(date ~= nil) then
            doItemSetAttribute(uid, "date", tonumber(date))
        end
    end

    return true
end

function getItemWeightById(itemid, count, precision)
    local item, count, precision = getItemInfo(itemid), count or 1, precision or false
    if(not item) then
        return false
    end

    if(count > 100) then
        -- print a warning, as its impossible to have more than 100 stackable items without "cheating" the count
        print('[Warning] getItemWeightById', 'Calculating weight for more than 100 items!')
    end

    local weight = item.weight * count
    return precission and weight or math.round(weight, 2)
end

function choose(...)
    local arg, ret = {...}

    if type(arg[1]) == 'table' then
        ret = arg[1][math.random(#arg[1])]
    else
        ret = arg[math.random(#arg)]
    end

    return ret
end

function doPlayerAddExpEx(cid, amount)
    if(not doPlayerAddExp(cid, amount)) then
        return false
    end

    local position = getThingPosition(cid)
    doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE, "You gained " .. amount .. " experience.", amount, COLOR_WHITE, position)

    local spectators, name = getSpectators(position, 7, 7), getCreatureName(cid)
    for _, pid in ipairs(spectators) do
        if(isPlayer(pid) and cid ~= pid) then
            doPlayerSendTextMessage(pid, MESSAGE_EXPERIENCE_OTHERS, name .. " gained " .. amount .. " experience.", amount, COLOR_WHITE, position)
        end
    end

    return true
end

function getItemTopParent(uid)
    local parent = getItemParent(uid)
    if(not parent or parent.uid == 0) then
        return nil
    end

    while(true) do
        local tmp = getItemParent(parent.uid)
        if(tmp and tmp.uid ~= 0) then
            parent = tmp
        else
            break
        end
    end

    return parent
end

function getItemHolder(uid)
    local parent = getItemParent(uid)
    if(not parent or parent.uid == 0) then
        return nil
    end

    local holder = nil
    while(true) do
        local tmp = getItemParent(parent.uid)
        if(tmp and tmp.uid ~= 0) then
            if(tmp.itemid == 1) then -- a creature
                holder = tmp
                break
            end

            parent = tmp
        else
            break
        end
    end

    return holder
end

function valid(f)
    return function(p, ...)
        if(isCreature(p)) then
            return f(p, ...)
        end
    end
end

function addContainerItems(container,items)
    local items_mod = {}
    for _, it in ipairs(items) do
        if( isItemStackable(it.id) and it.count > 100) then
            local c = it.count
            while( c > 100 ) do
                table.insert(items_mod,{id = it.id,count = 100})
                c = c - 100
            end
            if(c > 0) then
                table.insert(items_mod,{id = it.id,count = c})
            end
        else
            table.insert(items_mod,{id = it.id,count = 1})
        end
    end

    local free = getContainerCap(container.uid) - (getContainerSize(container.uid) )
    local count = math.ceil(#items_mod/ free)
    local main_bp = container.uid
    local insert_bp = main_bp
    local counter = 1
    for c,it in ipairs(items_mod) do
        local _c = isItemStackable(it.id) and (it.count > 100 and 100 or it.count) or 1
        if count > 1 then
            if (counter < free) then
                doAddContainerItem(insert_bp, it.id, _c)
            else
                insert_bp = doAddContainerItem(insert_bp, container.itemid, 1)
                count = (#items_mod)-(free-1)
                free = getContainerCap(insert_bp) 
                count = math.ceil(count/ free)
                doAddContainerItem(insert_bp, it.id, _c)
                counter = 1
            end
            counter = counter + 1
        else
            doAddContainerItem(insert_bp, it.id, _c)
        end
    end

    return main_bp
end

WAR_TYPE_STORAGE = 22222

function isGuildLeader(cid)
    return getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER
end

function isInAnyArray(array, value)
    if not type(array) == 'table' then
        return false
    end
    for k, v in pairs(array) do
        if type(v) == 'table' then
            ret = isInAnyArray(v, value)
            if ret ~= false then
                return true, k
            end
        else
            if v == value then
                return true, k
            end
        end
    end
    return false
end

function setPlayerWarType(cid, value)
    return doCreatureSetStorage(cid, WAR_TYPE_STORAGE, value)
end

function getPlayerWarType(cid)
    return getCreatureStorage(cid, WAR_TYPE_STORAGE)
end

function isGuildAntiEntrosa(guildId)
if not type(guildId) == 'number' then
    return false
end
    for _, v in pairs(Wars) do
        if type(v) == "table" then
            if v:isGuildOnWar(guildId) then
                return true
            end
        end
    end
    return false
end

function hourToNumber(str) -- By Killua
    local hour = (tonumber(str:sub(1,2))*3600) + (tonumber(str:sub(4,5)) * 60)
    if #str > 5 then
        hour = hour + tonumber(str:sub(7,8))
    end
    return hour
end

function table.elements(tabela)
local i = 0
    for _,v in pairs(tabela) do
        if v ~= nil then
            i = i + 1
        end
    end
    return i
end

 

Meu TFS é dessa versão ai:

image.png.5048bbd9b65e16954137435dbac598e0.png

Link para o post
Compartilhar em outros sites

@Quatroqueijos  poe isso no fim da sua lib

 

function timeString(timeDiff,english) -- créditos: Killua
    local dateFormat = {}

    if english then

        dateFormat = {
            {"day", timeDiff / 60 / 60 / 24},
            {"hour", timeDiff / 60 / 60 % 24},
            {"minute", timeDiff / 60 % 60},
            {"second", timeDiff % 60}
        }

    else

        dateFormat = {
            {"dia", timeDiff / 60 / 60 / 24},
            {"hora", timeDiff / 60 / 60 % 24},
            {"minuto", timeDiff / 60 % 60},
            {"segundo", timeDiff % 60}
        }
        
    end

    local out = {}
    for k, t in ipairs(dateFormat) do
        local v = math.floor(t[2])
        if(v > 0) then
            table.insert(out, (k < #dateFormat and (#out > 0 and ', ' or '') or ' e ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or ''))
        end
    end
    
    return table.concat(out)
end

 

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.


  • Conteúdo Similar

    • Por Imperius
      O propósito é criar uma nova função em creaturescripts que será acionada toda vez que um novo report (CTRL + R) for aberto.
       
      Eu implementei para enviar uma notificação no grupo do Telegram, contendo os dados do report.
       
      Isso garantirá que os GMs tenham acesso aos reports dos jogadores mesmo quando não estiverem logados, e também evitará que algum report seja perdido caso o jogador saia do servidor.
      A parte do Telegram é apenas um exemplo. Você pode ajustar o script para executar outras ações desejadas.
       
      creatureevent.cpp:
      Dentro deste arquivo, localize a função:
       
      uint32_t CreatureEvent::executeChannelLeave(Player* player, uint16_t channelId, UsersMap usersMap)  
      abaixo dela, adicione:
       
      uint32_t CreatureEvent::executeOpenRuleViolation(Player* player, std::string message) { if (!m_interface->reserveEnv()) { std::clog << "[Error - CreatureEvent::executeOpenRuleViolation] Call stack overflow." << std::endl; return 0; } ScriptEnviroment* env = m_interface->getEnv(); env->setScriptId(m_scriptId, m_interface); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); lua_pushstring(L, message.c_str()); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; }  
      Após, procure por:
       
      std::string CreatureEvent::getScriptEventName() const  
      abaixo de:
       
      case CREATURE_EVENT_CHANNEL_LEAVE: return "onLeaveChannel";  
      adicione:
       
      case CREATURE_EVENT_OPEN_RULE_VIOLATION: return "onOpenRuleViolation";  
      Agora, procure por:
       
      std::string CreatureEvent::getScriptEventParams() const  
      abaixo de:
       
      case CREATURE_EVENT_CHANNEL_LEAVE: return "cid, channel, users";  
      adicione:
       
      case CREATURE_EVENT_OPEN_RULE_VIOLATION: return "cid, message";  
      Procure por:
       
      bool CreatureEvent::configureEvent(xmlNodePtr p)  
      abaixo de:
       
      else if(tmpStr == "leavechannel") m_type = CREATURE_EVENT_CHANNEL_LEAVE;  
      adicione:
       
      else if(tmpStr == "openruleviolation") m_type = CREATURE_EVENT_OPEN_RULE_VIOLATION;  
       
      creatureevent.h:
      Dentro deste arquivo, localize:
       
      enum CreatureEventType_t  
      adicione "CREATURE_EVENT_OPEN_RULE_VIOLATION" como o último item de enum CreatureEventType_t
       
      Exemplo:
       
      enum CreatureEventType_t { // ... CREATURE_EVENT_OPEN_RULE_VIOLATION };  
      Agora, procure por:
       
      uint32_t executeChannelLeave(Player* player, uint16_t channelId, UsersMap usersMap);  
      abaixo dela, adicione:
       
      uint32_t executeOpenRuleViolation(Player* player, std::string message);  
      game.cpp:
      Dentro deste arquivo, localize:
       
      bool Game::playerReportRuleViolation(Player* player, const std::string& text)  
      e substitua por:
       
      bool Game::playerReportRuleViolation(Player* player, const std::string& text) { //Do not allow reports on multiclones worlds since reports are name-based if(g_config.getNumber(ConfigManager::ALLOW_CLONES)) { player->sendTextMessage(MSG_INFO_DESCR, "Rule violation reports are disabled."); return false; } cancelRuleViolation(player); boost::shared_ptr<RuleViolation> rvr(new RuleViolation(player, text, time(NULL))); ruleViolations[player->getID()] = rvr; ChatChannel* channel = g_chat.getChannelById(CHANNEL_RVR); if(!channel) return false; for(UsersMap::const_iterator it = channel->getUsers().begin(); it != channel->getUsers().end(); ++it) it->second->sendToChannel(player, SPEAK_RVR_CHANNEL, text, CHANNEL_RVR, rvr->time); CreatureEventList joinEvents = player->getCreatureEvents(CREATURE_EVENT_OPEN_RULE_VIOLATION); for(CreatureEventList::iterator it = joinEvents.begin(); it != joinEvents.end(); ++it) (*it)->executeOpenRuleViolation(player, text); return true; }  
      Agora é só compilar a source.
       
      depois em "data > creaturescripts > creaturescripts.xml", adicione:
       
      <event type="login" name="loginNotifyRuleViolation" script="notifyRuleViolation.lua"/> <event type="openruleviolation" name="openNotifyRuleViolation" script="notifyRuleViolation.lua"/>  
      em "data > creaturescripts > scripts", crie um arquivo notifyRuleViolation.lua e adicione:
       
      function onOpenRuleViolation(cid, message) local config = { token = "", -- Token do seu BOT no Telegram chatId = "" -- ID do chat do Telegram que será enviado a notificação. } local message = "Player: "..getCreatureName(cid).."\n\nReport:\n"..message.."" message = string.gsub(message, "\n", "%%0A") local url = "https://api.telegram.org/bot"..config.token.."/sendMessage" local data = "chat_id="..config.chatId.."&text="..message.."" local curl = io.popen('curl -d "'..data..'" "'..url..'"'):read("*a") return true end function onLogin(cid) registerCreatureEvent(cid, "openNotifyRuleViolation") return true end  
       
      Demonstração:
      1. Jogador abre um novo report (CTRL + R)

      2. notifyRuleViolation.lua, definido em creaturescripts.xml, é acionado para enviar uma notificação ao grupo do Telegram.
       

       
    • Por cloudrun2023
      CloudRun - Sua Melhor Escolha para Hospedagem de OTServer!
      Você está procurando a solução definitiva para hospedar seu OTServer com desempenho imbatível e segurança inigualável? Não procure mais! Apresentamos a CloudRun, sua parceira confiável em serviços de hospedagem na nuvem.
       
      Recursos Exclusivos - Proteção DDoS Avançada:
      Mantenha seu OTServer online e seguro com nossa robusta proteção DDoS, garantindo uma experiência de jogo ininterrupta para seus jogadores.
       
      Servidores Ryzen 7 Poderosos: Desfrute do poder de processamento superior dos servidores Ryzen 7 para garantir um desempenho excepcional do seu OTServer. Velocidade e estabilidade garantidas!
       
      Armazenamento NVMe de Alta Velocidade:
      Reduza o tempo de carregamento do jogo com nosso armazenamento NVMe ultrarrápido. Seus jogadores vão adorar a rapidez com que podem explorar o mundo do seu OTServer.
       
      Uplink de até 1GB:
      Oferecemos uma conexão de alta velocidade com até 1GB de largura de banda, garantindo uma experiência de jogo suave e livre de lag para todos os seus jogadores, mesmo nos momentos de pico.
       
      Suporte 24 Horas:
      Estamos sempre aqui para você! Nossa equipe de suporte está disponível 24 horas por dia, 7 dias por semana, para resolver qualquer problema ou responder a qualquer pergunta que você possa ter. Sua satisfação é a nossa prioridade.
       
      Fácil e Rápido de Começar:
      Configurar seu OTServer na CloudRun é simples e rápido. Concentre-se no desenvolvimento do seu jogo enquanto cuidamos da hospedagem.
       
      Entre em Contato Agora!
      Website: https://central.cloudrun.com.br/index.php?rp=/store/cloud-ryzen-brasil
      Email: [email protected]
      Telefone: (47) 99902-5147

      Não comprometa a qualidade da hospedagem do seu OTServer. Escolha a CloudRun e ofereça aos seus jogadores a melhor experiência de jogo possível. Visite nosso site hoje mesmo para conhecer nossos planos e começar!
       
      https://central.cloudrun.com.br/index.php?rp=/store/cloud-ryzen-brasil
       
      CloudRun - Onde a Velocidade Encontra a Confiabilidade!
       

    • Por FeeTads
      SALVE rapaziada do TK, esses dias vim pensando em novos scripts pro meu OT, e em um deles eu precisava que determinada area não contasse frag pro player que matasse outros, PORÉM eu precisava que os players que morressem nessa area ainda assim tivessem as penalidades da sua morte, procurei por ai, achei alguns scripts que apenas tiravam o SKULL e não realmente o FRAG do player.

      **script atualizado 22/10/2023** - melhorado e otimizado, levei o script pra puxar as infos por .lua / creatureScripts

      vou disponibilizar o code aqui, e o que fazer pra determinada area não contar frag.

      SOURCE OTX 2 / TFS 0.x, Funciona em TFS 1.x mudando as tags e ajeitando as sintaxes.

      vá em creatureevent.cpp

      procure por:
      else if(type == "preparedeath") _type = CREATURE_EVENT_PREPAREDEATH;
      Adiciona abaixo:
      else if(type == "nocountfrag") _type = CREATURE_EVENT_NOCOUNTFRAG;

      procure por:
      case CREATURE_EVENT_PREPAREDEATH: return "onPrepareDeath";  
      Adicione abaixo: 
      case CREATURE_EVENT_NOCOUNTFRAG: return "noCountFragArea";

      procure por:
      case CREATURE_EVENT_PREPAREDEATH: return "cid, deathList";
      Adicione abaixo:
      case CREATURE_EVENT_NOCOUNTFRAG: return "cid, target";

      agora no mesmo arquivo, vá até o final do arquivo e adicione essa função:
      uint32_t CreatureEvent::executeNoCountFragArea(Creature* creature, Creature* target) { //noCountFragArea(cid, target) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::ostringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local target = " << env->addThing(target) << std::endl; if(m_scriptData) scriptstream << *m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ std::ostringstream desc; desc << creature->getName(); env->setEvent(desc.str()); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, env->addThing(target)); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::clog << "[Error - CreatureEvent::noCountFragArea] Call stack overflow." << std::endl; return 0; } }

      agora vá em creatureevent.h

      procure por:
      CREATURE_EVENT_PREPAREDEATH
      adicione abaixo:
      CREATURE_EVENT_NOCOUNTFRAG

      procure por:
      uint32_t executePrepareDeath(Creature* creature, DeathList deathList);
      Adicione abaixo:
      uint32_t executeNoCountFragArea(Creature* creature, Creature* target);

      agora vá em player.cpp

      procure por:
      bool Player::onKilledCreature(Creature* target, DeathEntry& entry)
      abaixo de:
      War_t enemy; if(targetPlayer->getEnemy(this, enemy)) { if(entry.isLast()) IOGuild::getInstance()->updateWar(enemy); entry.setWar(enemy); }
      Adicione o seguinte código:
      if (targetPlayer){ CreatureEventList killEvents = getCreatureEvents(CREATURE_EVENT_NOCOUNTFRAG); for (const auto &event : killEvents) { if (!event->executeNoCountFragArea(this, target)) { return true; } } }

      //

      Feito isso, tudo completo na sua source, agora é necessário adicionar o creaturescript dentro do servidor

      vá até creaturescripts/scripts
      crie um arquivo chamado, "noCountFragInArea.lua"
      e dentro dele cole o código:
       
      --[[ script feito por feetads / TibiaKing ]]-- --[[ discord: feetads / FeeTads#0246 ]]-- -- Add positions here for which you do not want to count frags local areas = { [1] = {from = {x = 91, y = 122, z = 7}, to = {x = 98, y = 127, z = 7}}, -- from = area superior esquerda / to = area inferior direita (formando um quadrado) } local onlyKillerInArea = false -- only killer need to be in area? function noCountFragArea(cid, target) if not isCreature(cid) or not isCreature(target) then return true end local posKiller = getPlayerPosition(cid) local posTarget = getPlayerPosition(target) for i = 1, #areas do local area = areas[i] if isInArea(posKiller, area.from, area.to) then if onlyKillerInArea then return false elseif isInArea(posTarget, area.from, area.to) then return false end end end return true end
      agora em creaturescripts.xml
      <event type="nocountfrag" name="fragarea" event="script" value="noCountFragInArea.lua"/>
      agora em creaturescripts/scripts/login.lua
       procure por OU semelhante a esse:
      registerCreatureEvent(cid, "AdvanceSave")
      e abaixo adicione:
      registerCreatureEvent(cid, "fragarea")

      //


      Agora tudo certo, quando quiser adiciona uma area que não pega frag, vá até o script e apenas coloque a area, igual o demonstrado no script

      Exemplo:
      local areas = { [1] = {from = {x = 91, y = 122, z = 7}, to = {x = 98, y = 127, z = 7}}, [2] = {from = {x = 1000, y = 1000, z = 7}, to = {x = 1100, y = 1100, z = 7}}, }
      assim somente colocando a area no script e abrindo o server ou dando /reload, já funcionará a area como não pegar frag.
      Esse sistema pode ser bom pra areas de pvp ativo, onde você ainda quer que o player que morrer perca os atributos, como se fosse uma morte normal, porém não conta frag pra quem matar.
      Bom pra sistemas tipo castle 48h (guild war), onde há diversas mortes e risco de pegar red, atrapalhando a war.

      Façam bom proveito dos scripts, e deixem os créditos no script rsrs

      **Eu fiz as alterações e o simples código por isso vim disponibilizar, créditos meus**
    • Por Muvuka
      Abri canal a força creaturescript acho que funcione no creaturescript cria script creaturescript
       
      <channel id="9" name="HELP" logged="yes"/>
      <channel id="12" name="Report Bugs" logged="yes"/>
      <channel id="13" name="Loot" logged="yes"/>
      <channel id="14" name="Report Character Rules Tibia Rules" logged="yes"/>
      <channel id="15" name="Death Channel"/>
      <channel id="6548" name="DexSoft" level="1"/>
      <channel id="7" name="Reports" logged="yes"/>
       
      antes de 
              if(lastLogin > 0) then adicione isso:
                      doPlayerOpenChannel(cid, CHANNEL_HELP) doPlayerOpenChannel(cid, 1,  2, 3) = 1,2 ,3 Channels, entendeu? NÃO FUNCIONA EU QUERO UM MEIO DE ABRI SEM USA A SOURCE
       
      EU NÃO CONSEGUI ABRI EU NÃO TENHO SOURCE
       
       
    • Por bolachapancao
      Rapaziada seguinte preciso de um script que ao utilizar uma alavanca para até 4 jogadores.
      Os jogadores serão teleportados para hunt durante uma hora e depois de uma hora os jogadores serão teleportados de volta para o templo.
       
      Observação: caso o jogador morra ou saia da hunt o evento hunt é cancelado.

      Estou a base canary
      GitHub - opentibiabr/canary: Canary Server 13.x for OpenTibia community.
       
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo