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

[MOD] Castle War TFS 0.4

Mokk

New Member
Joined
Jun 2, 2023
Messages
12
Reaction score
4
Hi guys, I'm creating a castle guild war MOD, it works as follows:By giving the command !startcc the event is started, a message is sent in the broadcast to everyone and a teleport appears that leads to the castle, in the castle you find 2 tiles one that is responsible for announcing the invasion of some player, this tile also has a level limitation, the second tile is the one that dominates the castle, In addition, there is also another !endcc talk that closes the event.

Below is the MOD:

<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Cyber Castle 48" version="1.0" author="SeuNome" contact="seusite.com" enabled="yes">
<config name="cybercastle48_config"><![CDATA[
cybercastle48_config = {
storages = {1700, 1701, 1702}, -- Armazenamento global para controle do evento
arena = {{x = 1000, y = 1000, z = 7}, {x = 1100, y = 1100, z = 7}}, -- Área da arena
teleportAppear = {x = 1025, y = 1026, z = 7}, -- Posição do teleport que aparece
teleportDestination = {x = 912, y = 1267, z = 7}, -- Posição para onde o jogador é teleportado ao entrar no teleport
respawnTime = 5, -- Tempo de respawn dos monstros em minutos
eventDuration = 1, -- Tempo de duração do evento em minutos
rewards = {items = {{1234, 10}, {5678, 5}}, trophy = 8765}, -- Prêmios para os ganhadores do evento
minLevelToAccess = 50, -- Nível mínimo para acessar o teleport
castleOwnerStorage = 1703, -- Armazenamento para controlar a guilda dona do castelo
castleDominatingGuild = 0, -- Variável para armazenar temporariamente a guilda que está dominando o castelo
}
]]></config>

<talkaction words="!startcc" access="5" event="buffer"><![CDATA[
domodlib('cybercastle48_config')
local teleportItem = doCreateItem(1387, 1, cybercastle48_config.teleportAppear)
doItemSetAttribute(teleportItem, "aid", 19872) -- Adicione um action id ao teleport para identificação
doBroadcastMessage("[Cyber Castle 48] O evento começou! Use o teleport para entrar na arena.", MESSAGE_STATUS_WARNING)
setGlobalStorageValue(cybercastle48_config.storages[3], 1) -- Marca o início do evento
]]></talkaction>

<talkaction words="!endcc" access="5" event="buffer"><![CDATA[
domodlib('cybercastle48_config')
local removeTeleport = getTileItemById(cybercastle48_config.teleportAppear, 1387).uid

if removeTeleport > 0 then
doRemoveItem(removeTeleport)
doBroadcastMessage("[Cyber Castle 48] O evento foi encerrado! O teleport foi removido.", MESSAGE_STATUS_WARNING)

-- Verifique se alguma guilda está disputando o castelo
if cybercastle48_config.castleDominatingGuild > 0 then
local dominatingGuild = cybercastle48_config.castleDominatingGuild
local guildName = getGuildName(dominatingGuild)

if guildName then
-- Anuncie a guilda vencedora
doBroadcastMessage("[Cyber Castle 48] A guilda " .. guildName .. " domina o castelo!", MESSAGE_STATUS_WARNING)
setGlobalStorageValue(cybercastle48_config.castleOwnerStorage, dominatingGuild)
end
else
-- Nenhuma guilda disputou o castelo
doBroadcastMessage("[Cyber Castle 48] Nenhuma guilda dominou o castelo durante o evento.", MESSAGE_STATUS_WARNING)
end

-- Reseta o estado do evento e a guilda dominante
setGlobalStorageValue(cybercastle48_config.storages[3], 0)
cybercastle48_config.castleDominatingGuild = 0
else
doPlayerSendCancel(cid, "O evento não está acontecendo.")
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
end
]]></talkaction>

<movevent type="StepIn" actionid="19872" event="script"><![CDATA[
domodlib('cybercastle48_config')
local playerLevel = getPlayerLevel(cid)
if playerLevel >= cybercastle48_config.minLevelToAccess then
doTeleportThing(cid, cybercastle48_config.teleportDestination, false)
else
doPlayerSendCancel(cid, "Você não tem o nível mínimo necessário para entrar no evento.")
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
end
]]></movevent>

<movevent type="StepIn" actionid="19873" event="script"><![CDATA[
function onStepIn(cid, item, position, fromPosition)
local guildId = getPlayerGuildId(cid)

if guildId > 0 then
-- O jogador pertence a uma guilda, permita a passagem
local guildName = getPlayerGuildName(cid) -- Use esta função alternativa
if guildName then
doBroadcastMessage("[Cyber Castle 48] " .. getCreatureName(cid) .. " da guilda " .. guildName .. " está invadindo o Cyber Castle 48!", MESSAGE_STATUS_CONSOLE_ORANGE)
return true
end
end

-- O jogador não pertence a uma guilda, bloqueie a passagem e mova-o de volta à posição anterior
doPlayerSendCancel(cid, "Você não pode passar por aqui sem estar em uma guilda.")
doTeleportThing(cid, fromPosition, false)
return false
end
]]></movevent>

<movevent type="StepIn" actionid="19874" event="script"><![CDATA[
domodlib('cybercastle48_config')
local playerGuildId = getPlayerGuildId(cid)

if playerGuildId > 0 then
-- O jogador pertence a uma guilda, permita a tentativa de dominar o castelo
local guildName = getPlayerGuildName(cid)

if guildName then
-- Verifique se o castelo já foi dominado por outra guilda
local currentDominatingGuild = getGlobalStorageValue(cybercastle48_config.castleOwnerStorage)

if currentDominatingGuild > 0 then
-- Castelo já dominado, verifique se a guilda atual é diferente
if currentDominatingGuild ~= playerGuildId then
-- Transferir o domínio para a nova guilda
setGlobalStorageValue(cybercastle48_config.castleOwnerStorage, playerGuildId)
cybercastle48_config.castleDominatingGuild = playerGuildId -- Atualize a guilda dominante

-- Emitir mensagem informando sobre a mudança de domínio
doBroadcastMessage("[Cyber Castle 48] O castelo foi dominado pela guilda " .. guildName .. "!", MESSAGE_STATUS_CONSOLE_ORANGE)
else
-- A guilda atual está defendendo seu domínio
doBroadcastMessage("[Cyber Castle 48] O jogador " .. getCreatureName(cid) .. " da guild " .. guildName .. " está defendendo o Cyber Castle 48!", MESSAGE_STATUS_CONSOLE_ORANGE)
end
else
-- O castelo ainda não foi dominado, a guilda atual o domina agora
setGlobalStorageValue(cybercastle48_config.castleOwnerStorage, playerGuildId)
cybercastle48_config.castleDominatingGuild = playerGuildId -- Atualize a guilda dominante

-- Emitir mensagem informando sobre o domínio inicial
doBroadcastMessage("[Cyber Castle 48] O castelo foi dominado pela guilda " .. guildName .. "!", MESSAGE_STATUS_CONSOLE_ORANGE)
end

return true
end
end

-- O jogador não pertence a uma guilda, bloqueie a tentativa de dominar o castelo
doPlayerSendCancel(cid, "Você não pode tentar dominar o castelo sem estar em uma guilda.")
return false
]]></movevent>

</mod>

The mistake is as follows: At the end of the event it says that no guild has taken over the castle even if it does, if anyone can help with this part I would appreciate it!
 

Similar threads

Back
Top