Ir para conteúdo
  • 0
Pharos

Scripting Globalevent criar teleport OnTime de zombie event da Printer

Pergunta

Pharos    1
Pharos

Base: The Forgotten Server 1.3, Versão: 8.6

 

Qual é a sua pergunta? Eu Preciso de globalvent para me ajudar a ativar os eventos zumbis automaticamente e cree el teleport(teleport movements abaixo na spoiler). Estou usando alguns scripts criados por printer (otland). Atualmente, o que ativa o evento é uma talkaction.

 

Você tem o código disponível? Se tiver poste-o na caixa de código que está dentro do spoiler abaixo:

Spoiler

<talkaction words="!zombie" separator=" " script="zombieEventCommands.lua" />

function onSay(player, words, param)
    local split = param:split(",")

    if split[1] == "join" then
        -- If it's a staff member, just teleport inside and do not count as a participant
        if player:getGroup():getAccess() then
            player:teleportTo(ze_WaitingRoomStartPosition)
            return false
        end

        -- If the state of the event is closed or started, stop them from join
        if isInArray({ze_EVENT_CLOSED, ze_EVENT_STARTED}, getZombieEventState()) then
            return false
        end

        -- If player got pz, forbid them to join
        if player:isPzLocked() then
            player:sendCancelMessage("You cannot join while your in a fight.")
            return false
        end

        -- If there is max players joined, stop them from join
        if getZombieEventJoinedCount() >= ze_maxPlayers then
            player:sendCancelMessage("The event is already full.")
            return false
        end

        -- Execute join event
        player:joinZombieEvent()
    elseif split[1] == "start" then
        -- If not staff member, they stop them from setup a event
        if not player:getGroup():getAccess() then
            return false
        end

        local minPlayers = tonumber(split[2])
        local maxPlayers = tonumber(split[3])
        local waitTime = tonumber(split[4])

        local failStart = false
        if minPlayers == nil or minPlayers < 1 then
            failStart = true
        elseif maxPlayers == nil or maxPlayers > Game.getPlayerCount() then
            failStart = true
        elseif waitTime == nil or waitTime < 1 then
            failStart = true
        end

        if failStart then
            player:sendCancelMessage("!zombie start, [minPlayers, maxPlayers, waitTime].")
            return false
        end

        -- Set the new variables and setup the event
        setupZombieEvent(minPlayers, maxPlayers, waitTime)
    end

    return false
end

 <!-- Zombie Event -->
    <movevent event="StepIn" actionid="7000" script="zombieEventTeleport.lua" />

function onStepIn(creature, item, position, fromPosition)

    local player = creature:getPlayer()

    if not player == nil then
        return true
    end

    -- If it's a staff memeber, just teleport inside and do not count as participant
    if player:getGroup():getAccess() then
        player:teleportTo(ze_WaitingRoomStartPosition)
        return true
    end

    -- If the event state is closed or started, then stop players from enter
    if isInArray({ze_EVENT_CLOSED, ze_EVENT_STARTED}, getZombieEventState()) then
        player:teleportTo(fromPosition, true)
        fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
        return true
    end

    -- Check if the event has already max players
    if getZombieEventJoinedCount() >= ze_maxPlayers then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "The Zombie Event is already full.")
        player:teleportTo(fromPosition, true)
        fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
        return true
    end

    -- Execute join event
    player:joinZombieEvent()
    return true
end

 <!-- Zombie Event -->
    <event type="preparedeath" name="ZombiePlayerDeath" script="player/zombieEventDeath.lua" />
    <event type="death" name="ZombieOnDeath" script="player/zombieEventDeath.lua" />

function onDeath(monster, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    -- Send text and effect
    monster:say("I WILL BE BACK!", TALKTYPE_MONSTER_YELL)
    monster:getPosition():sendMagicEffect(CONST_ME_MORTAREA)

    -- Remove zombie count, when it dies
    Game.setStorageValue(ze_zombieCountGlobalStorage, getZombieEventZombieCount() - 1)

    -- Store player kills
    local killerId = killer:getId()
    if zombieKillCount[killerId] ~= nil then
        zombieKillCount[killerId] = zombieKillCount[killerId] + 1
    else
        zombieKillCount[killerId] = 1
    end

    return true
end

function onPrepareDeath(player, killer)
    -- Remove player from count
    local count = getZombieEventJoinedCount()
    Game.setStorageValue(ze_joinCountGlobalStorage, count - 1)

    -- Reset player after death
    player:teleportTo(player:getTown():getTemplePosition())
    player:setStorageValue(ze_joinStorage, 0)
    player:addHealth(player:getMaxHealth())
    player:addMana(player:getMaxMana())
    player:unregisterEvent("ZombiePlayerDeath")

    -- Let's reward the 3 last players
    if count <= 3 then
        local playerName =  player:getName()

        local trophy = ze_trophiesTable[count]
        local item = player:addItem(trophy.itemid, 1)
        if item then
            item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, string.format("%s %s\n%s.", playerName, trophy.description, os.date("%x")))
        end

        -- Store kill count and remove from table to avoid memory leak
        local playerId, killCount = player:getId(), 0
        if zombieKillCount[playerId] ~= nil then
            killCount = zombieKillCount[playerId]
            zombieKillCount[playerId] = nil
        end

        -- Broadcast
        Game.broadcastMessage(string.format("%d place goes to %s of Zombie Event versus %d Zombies and slained %d Zombies.", count, playerName, getZombieEventZombieCount(), killCount))

        -- The last player died, let's reset the event
        if count <= 1 then
            resetZombieEvent()
        end
    end

    return false
end

data/zombieEvent.lua 
http://pastebin.com/frkjmi1v

 

 

Você tem alguma imagem que possa auxiliar no problema? Se sim, anexe-a dentro do spoiler abaixo:

Spoiler

 

 

Editado por Pharos

Compartilhar este post


Link para o post
Compartilhar em outros sites

1 resposta a esta questão

Recommended Posts

  • 0
Pharos    1
Pharos

 

Eu apliquei a lógica, vi algumas scripts de talkaction e globalevents.

<globalevent name="Zombie Arena"  time="8:18:30" script="zombie_arena.lua" />
function onTime(interval, lastExecution)
	local minPlayers = 3 --
	local maxPlayers = 3 --
	local waitTime = 1 --
	
	local playersOnline = #getOnlinePlayers()

    if playersOnline >= maxPlayers then
		Game.broadcastMessage("Zombie Event it's coming...", MESSAGE_STATUS_WARNING)
		print('...Game.broadcastMessage("Zombie Event Starting...", MESSAGE_STATUS_WARNING)...')
        -- Set the new variables and setup the event
        setupZombieEvent(minPlayers, maxPlayers, waitTime)
    else
	  Game.broadcastMessage("[Zombie Event]: Insufficient online players to open the event", MESSAGE_STATUS_WARNING)
	  print('[Zombie Event]: Insufficient online players to open the event')
	end
	
    return false
end

 

Compartilhar este post


Link para o post
Compartilhar em outros sites
Visitante
Este tópico está impedido de receber novos posts.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×