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

Lua script error

GOD Esteve

New Member
Joined
May 18, 2011
Messages
87
Reaction score
1
Hello guys.

First of all i am using TFS 1.0


I have this function to my Castle24H to remove all the players that is inside the castle when
the other guild stepin on the throne.

Code:
function doCastleRemoveEnemies()
for index, creature in ipairs(getOnlinePlayers()) do
if isInRange(getThingPos(creature), COH_AREA[1], COH_AREA[2]) then
if getPlayerGuildName(creature) ~= getGlobalStorageValue(COH_STATUS) then
doTeleportThing(creature, exit)
end
end
end
return true
end

but i have a small problem that i don't khown how to solve,

Lua script error: moveevents interface
data/movements/script/castle24.lua:eek:nStepIn
data/lib/compat.lua:847: attempt to compare number with string stack traceback:
[c]: in ufnction `___le`
data/lib/compact/compact.lua:847 in function `getThingPos`
data/movements/script/castle24.lua:92: in function `doCastleRemoveEnimes`

I will be glad if somebody help me to fix.

Thank You
 
Post the whole script.


Code:
function onStepIn(cid, item, pos, fromPosition)
COH_AREA = {{x = 368, y = 25, z = 7}, {x = 414, y = 61, z = 7}}
exit = {x = 393, y = 50, z = 7}
pos = getThingPos(cid)
COH_STATUS = 201320111714
COH_PREPARE1 = 201320111715 
COH_PREPARE2 = 201320111717
COH_PUSHSTOR = 201320111716
COH_PUSHTIME = 10800
if item.actionid == 3232 then
        if not isPlayer(cid) then
            return true
        end

        if getGlobalStorageValue(COH_STATUS) == getPlayerGuildName(cid) then
            doSendAnimatedText("PKNBaiak", pos, math.random(1, 255))
            doSendMagicEffect(getThingPos(cid), 28)
        else
            doTeleportThing(cid, fromPosition, false)
            doSendMagicEffect(getThingPos(cid), 2)
            doPlayerSendCancel(cid, "Você não pertence á guild "..getGlobalStorageValue(COH_STATUS)..".")
        end
    return true
end

if item.actionid == 3233 then
        if not isPlayer(cid) then
            return true
        end

        if getPlayerGuildId(cid) > 0 then
            if (getGlobalStorageValue(COH_STATUS) ~= getPlayerGuildName(cid)) then
                doPlayerSendTextMessage(cid, 20, "Você e sua guild estão no comando do Castle24H, os antigos donos ["..tostring(getGlobalStorageValue(COH_STATUS)).."] podem se vingar!")
                setGlobalStorageValue(COH_PREPARE1, -1)
                setGlobalStorageValue(COH_PREPARE2, -1)
                setGlobalStorageValue(COH_STATUS, getPlayerGuildName(cid))
                doCastleRemoveEnemies()
                         
            else
                doSendMagicEffect(pos, 2) 
                doTeleportThing(cid, fromPosition, false)
                doPlayerSendCancel(cid, "Este castelo ja pertence a sua guild.")
                end
        else
            doSendMagicEffect(pos, 2) 
            doTeleportThing(cid, fromPosition, false)
            doPlayerSendCancel(cid, "Você não possui uma guild.")
        end
    return true
end

if item.actionid == 3230 then
        if not isPlayer(cid) then
            return true
        end

        if getPlayerGuildId(cid) > 0 then
            if (getGlobalStorageValue(COH_STATUS) == getPlayerGuildName(cid)) then
                doPlayerSendTextMessage(cid, 20, "ESTE CASTELO AINDA PERTENCE A SUA GUILD!")
                return true
            end
            if (getGlobalStorageValue(COH_PREPARE1) ~= getPlayerGuildName(cid)) and ((getGlobalStorageValue(COH_PREPARE2) ~= getPlayerGuildName(cid))) then
                setGlobalStorageValue(COH_PREPARE1, getPlayerGuildName(cid))
                broadcastMessage("Atenção! A guild "..getPlayerGuildName(cid).." está tentando dominar o castelo, preparem-se!")
            end
        else
            doSendMagicEffect(pos, 2) 
            doTeleportThing(cid, fromPosition, false)
            doPlayerSendCancel(cid, "Você não possui uma guild.")
        end
    return true
end
if item.actionid == 3231 then
        if not isPlayer(cid) then
            return true
        end

        if (getGlobalStorageValue(COH_PREPARE2) ~= getPlayerGuildName(cid)) then
            setGlobalStorageValue(COH_PREPARE2, getPlayerGuildName(cid))
            broadcastMessage("Atenção! A guild "..getPlayerGuildName(cid).." está muito próxima do domínio, ataquem!")
        end
    return true
end

return true
end

function doCastleRemoveEnemies()
for index, creature in ipairs(getOnlinePlayers()) do
if isInArray(getThingPos(creature), COH_AREA[1], COH_AREA[2]) then
if getPlayerGuildName(creature) ~= getGlobalStorageValue(COH_STATUS) then
doTeleportThing(creature, exit)
end
end
end
return true
end

Here is, i think could solve only with function xD
 
Code:
function onStepIn(cid, item, pos, fromPosition)
COH_AREA = {
    {x = 414, y = 61, z = 7}, -- max
    {x = 368, y = 25, z = 7} -- min
}
exit = {x = 393, y = 50, z = 7}
pos = getThingPos(cid)
COH_STATUS = 201320111714
COH_PREPARE1 = 201320111715
COH_PREPARE2 = 201320111717
COH_PUSHSTOR = 201320111716
COH_PUSHTIME = 10800
if item.actionid == 3232 then
        if not isPlayer(cid) then
            return true
        end

        if getGlobalStorageValue(COH_STATUS) == getPlayerGuildName(cid) then
            doSendAnimatedText("PKNBaiak", pos, math.random(1, 255))
            doSendMagicEffect(getThingPos(cid), 28)
        else
            doTeleportThing(cid, fromPosition, false)
            doSendMagicEffect(getThingPos(cid), 2)
            doPlayerSendCancel(cid, "Você não pertence á guild "..getGlobalStorageValue(COH_STATUS)..".")
        end
    return true
end

if item.actionid == 3233 then
        if not isPlayer(cid) then
            return true
        end

        if getPlayerGuildId(cid) > 0 then
            if (getGlobalStorageValue(COH_STATUS) ~= getPlayerGuildName(cid)) then
                doPlayerSendTextMessage(cid, 20, "Você e sua guild estão no comando do Castle24H, os antigos donos ["..tostring(getGlobalStorageValue(COH_STATUS)).."] podem se vingar!")
                setGlobalStorageValue(COH_PREPARE1, -1)
                setGlobalStorageValue(COH_PREPARE2, -1)
                setGlobalStorageValue(COH_STATUS, getPlayerGuildName(cid))
                doCastleRemoveEnemies()
                        
            else
                doSendMagicEffect(pos, 2)
                doTeleportThing(cid, fromPosition, false)
                doPlayerSendCancel(cid, "Este castelo ja pertence a sua guild.")
                end
        else
            doSendMagicEffect(pos, 2)
            doTeleportThing(cid, fromPosition, false)
            doPlayerSendCancel(cid, "Você não possui uma guild.")
        end
    return true
end

if item.actionid == 3230 then
        if not isPlayer(cid) then
            return true
        end

        if getPlayerGuildId(cid) > 0 then
            if (getGlobalStorageValue(COH_STATUS) == getPlayerGuildName(cid)) then
                doPlayerSendTextMessage(cid, 20, "ESTE CASTELO AINDA PERTENCE A SUA GUILD!")
                return true
            end
            if (getGlobalStorageValue(COH_PREPARE1) ~= getPlayerGuildName(cid)) and ((getGlobalStorageValue(COH_PREPARE2) ~= getPlayerGuildName(cid))) then
                setGlobalStorageValue(COH_PREPARE1, getPlayerGuildName(cid))
                broadcastMessage("Atenção! A guild "..getPlayerGuildName(cid).." está tentando dominar o castelo, preparem-se!")
            end
        else
            doSendMagicEffect(pos, 2)
            doTeleportThing(cid, fromPosition, false)
            doPlayerSendCancel(cid, "Você não possui uma guild.")
        end
    return true
end
if item.actionid == 3231 then
        if not isPlayer(cid) then
            return true
        end

        if (getGlobalStorageValue(COH_PREPARE2) ~= getPlayerGuildName(cid)) then
            setGlobalStorageValue(COH_PREPARE2, getPlayerGuildName(cid))
            broadcastMessage("Atenção! A guild "..getPlayerGuildName(cid).." está muito próxima do domínio, ataquem!")
        end
    return true
end

return true
end

function isInArea(a, b, c)
    if b.x >= a.x and c.x <= a.x then
        if b.y >= a.y and c.y <= a.y then
            if b.z == a.z and c.z == a.z then
                return true
            end
        end
    end
    return false
end

function doCastleRemoveEnemies()
    for index, creature in ipairs(getOnlinePlayers()) do
        if isInArea(getThingPos(creature), COH_AREA[1], COH_AREA[2]) then
            if getPlayerGuildName(creature) ~= getGlobalStorageValue(COH_STATUS) then
                doTeleportThing(creature, exit)
            end
        end
    end
    return true
end
 
Last edited:
Code:
function onStepIn(cid, item, pos, fromPosition)
COH_AREA = {
    {x = 414, y = 61, z = 7}, -- max
    {x = 368, y = 25, z = 7} -- min
}
exit = {x = 393, y = 50, z = 7}
pos = getThingPos(cid)
COH_STATUS = 201320111714
COH_PREPARE1 = 201320111715
COH_PREPARE2 = 201320111717
COH_PUSHSTOR = 201320111716
COH_PUSHTIME = 10800
if item.actionid == 3232 then
        if not isPlayer(cid) then
            return true
        end

        if getGlobalStorageValue(COH_STATUS) == getPlayerGuildName(cid) then
            doSendAnimatedText("PKNBaiak", pos, math.random(1, 255))
            doSendMagicEffect(getThingPos(cid), 28)
        else
            doTeleportThing(cid, fromPosition, false)
            doSendMagicEffect(getThingPos(cid), 2)
            doPlayerSendCancel(cid, "Você não pertence á guild "..getGlobalStorageValue(COH_STATUS)..".")
        end
    return true
end

if item.actionid == 3233 then
        if not isPlayer(cid) then
            return true
        end

        if getPlayerGuildId(cid) > 0 then
            if (getGlobalStorageValue(COH_STATUS) ~= getPlayerGuildName(cid)) then
                doPlayerSendTextMessage(cid, 20, "Você e sua guild estão no comando do Castle24H, os antigos donos ["..tostring(getGlobalStorageValue(COH_STATUS)).."] podem se vingar!")
                setGlobalStorageValue(COH_PREPARE1, -1)
                setGlobalStorageValue(COH_PREPARE2, -1)
                setGlobalStorageValue(COH_STATUS, getPlayerGuildName(cid))
                doCastleRemoveEnemies()
                      
            else
                doSendMagicEffect(pos, 2)
                doTeleportThing(cid, fromPosition, false)
                doPlayerSendCancel(cid, "Este castelo ja pertence a sua guild.")
                end
        else
            doSendMagicEffect(pos, 2)
            doTeleportThing(cid, fromPosition, false)
            doPlayerSendCancel(cid, "Você não possui uma guild.")
        end
    return true
end

if item.actionid == 3230 then
        if not isPlayer(cid) then
            return true
        end

        if getPlayerGuildId(cid) > 0 then
            if (getGlobalStorageValue(COH_STATUS) == getPlayerGuildName(cid)) then
                doPlayerSendTextMessage(cid, 20, "ESTE CASTELO AINDA PERTENCE A SUA GUILD!")
                return true
            end
            if (getGlobalStorageValue(COH_PREPARE1) ~= getPlayerGuildName(cid)) and ((getGlobalStorageValue(COH_PREPARE2) ~= getPlayerGuildName(cid))) then
                setGlobalStorageValue(COH_PREPARE1, getPlayerGuildName(cid))
                broadcastMessage("Atenção! A guild "..getPlayerGuildName(cid).." está tentando dominar o castelo, preparem-se!")
            end
        else
            doSendMagicEffect(pos, 2)
            doTeleportThing(cid, fromPosition, false)
            doPlayerSendCancel(cid, "Você não possui uma guild.")
        end
    return true
end
if item.actionid == 3231 then
        if not isPlayer(cid) then
            return true
        end

        if (getGlobalStorageValue(COH_PREPARE2) ~= getPlayerGuildName(cid)) then
            setGlobalStorageValue(COH_PREPARE2, getPlayerGuildName(cid))
            broadcastMessage("Atenção! A guild "..getPlayerGuildName(cid).." está muito próxima do domínio, ataquem!")
        end
    return true
end

return true
end

function isInArea(a, b, c)
    if b.x >= a.x and c.x <= a.x then
        if b.y >= a.y and c.y <= a.y then
            if b.z == a.z and c.z == a.z then
                return true
            end
        end
    end
    return false
end

function doCastleRemoveEnemies()
    for index, creature in ipairs(getOnlinePlayers()) do
        if isInArea(getThingPos(creature), COH_AREA[1], COH_AREA[2]) then
            if getPlayerGuildName(creature) ~= getGlobalStorageValue(COH_STATUS) then
                doTeleportThing(creature, exit)
            end
        end
    end
    return true
end

Still with erro =/
dA2jxrG.jpg
 
Code:
function onStepIn(cid, item, pos, fromPosition)
COH_AREA = {
    {x = 414, y = 61, z = 7}, -- max
    {x = 368, y = 25, z = 7} -- min
}
exit = {x = 393, y = 50, z = 7}
pos = getThingPos(cid)
COH_STATUS = 201320111714
COH_PREPARE1 = 201320111715
COH_PREPARE2 = 201320111717
COH_PUSHSTOR = 201320111716
COH_PUSHTIME = 10800
if item.actionid == 3232 then
        if not isPlayer(cid) then
            return true
        end

        if getGlobalStorageValue(COH_STATUS) == getPlayerGuildName(cid) then
            doSendAnimatedText("PKNBaiak", pos, math.random(1, 255))
            doSendMagicEffect(getThingPos(cid), 28)
        else
            doTeleportThing(cid, fromPosition, false)
            doSendMagicEffect(getThingPos(cid), 2)
            doPlayerSendCancel(cid, "Você não pertence á guild "..getGlobalStorageValue(COH_STATUS)..".")
        end
    return true
end

if item.actionid == 3233 then
        if not isPlayer(cid) then
            return true
        end

        if getPlayerGuildId(cid) > 0 then
            if (getGlobalStorageValue(COH_STATUS) ~= getPlayerGuildName(cid)) then
                doPlayerSendTextMessage(cid, 20, "Você e sua guild estão no comando do Castle24H, os antigos donos ["..tostring(getGlobalStorageValue(COH_STATUS)).."] podem se vingar!")
                setGlobalStorageValue(COH_PREPARE1, -1)
                setGlobalStorageValue(COH_PREPARE2, -1)
                setGlobalStorageValue(COH_STATUS, getPlayerGuildName(cid))
                doCastleRemoveEnemies()
                        
            else
                doSendMagicEffect(pos, 2)
                doTeleportThing(cid, fromPosition, false)
                doPlayerSendCancel(cid, "Este castelo ja pertence a sua guild.")
                end
        else
            doSendMagicEffect(pos, 2)
            doTeleportThing(cid, fromPosition, false)
            doPlayerSendCancel(cid, "Você não possui uma guild.")
        end
    return true
end

if item.actionid == 3230 then
        if not isPlayer(cid) then
            return true
        end

        if getPlayerGuildId(cid) > 0 then
            if (getGlobalStorageValue(COH_STATUS) == getPlayerGuildName(cid)) then
                doPlayerSendTextMessage(cid, 20, "ESTE CASTELO AINDA PERTENCE A SUA GUILD!")
                return true
            end
            if (getGlobalStorageValue(COH_PREPARE1) ~= getPlayerGuildName(cid)) and ((getGlobalStorageValue(COH_PREPARE2) ~= getPlayerGuildName(cid))) then
                setGlobalStorageValue(COH_PREPARE1, getPlayerGuildName(cid))
                broadcastMessage("Atenção! A guild "..getPlayerGuildName(cid).." está tentando dominar o castelo, preparem-se!")
            end
        else
            doSendMagicEffect(pos, 2)
            doTeleportThing(cid, fromPosition, false)
            doPlayerSendCancel(cid, "Você não possui uma guild.")
        end
    return true
end
if item.actionid == 3231 then
        if not isPlayer(cid) then
            return true
        end

        if (getGlobalStorageValue(COH_PREPARE2) ~= getPlayerGuildName(cid)) then
            setGlobalStorageValue(COH_PREPARE2, getPlayerGuildName(cid))
            broadcastMessage("Atenção! A guild "..getPlayerGuildName(cid).." está muito próxima do domínio, ataquem!")
        end
    return true
end

return true
end

function isInArea(a, b, c)
    if b.x >= a.x and c.x <= a.x then
        if b.y >= a.y and c.y <= a.y then
            if b.z == a.z and c.z == a.z then
                return true
            end
        end
    end
    return false
end

function doCastleRemoveEnemies()
    for index, creature in ipairs(getOnlinePlayers()) do
        if isInArea(getThingPos( getCreatureByName(creature) ), COH_AREA[1], COH_AREA[2]) then
            if getPlayerGuildName( getCreatureByName(creature) ) ~= getGlobalStorageValue(COH_STATUS) then
                doTeleportThing(creature, exit)
            end
        end
    end
    return true
end
 
Code:
function onStepIn(cid, item, pos, fromPosition)
COH_AREA = {
    {x = 414, y = 61, z = 7}, -- max
    {x = 368, y = 25, z = 7} -- min
}
exit = {x = 393, y = 50, z = 7}
pos = getThingPos(cid)
COH_STATUS = 201320111714
COH_PREPARE1 = 201320111715
COH_PREPARE2 = 201320111717
COH_PUSHSTOR = 201320111716
COH_PUSHTIME = 10800
if item.actionid == 3232 then
        if not isPlayer(cid) then
            return true
        end

        if getGlobalStorageValue(COH_STATUS) == getPlayerGuildName(cid) then
            doSendAnimatedText("PKNBaiak", pos, math.random(1, 255))
            doSendMagicEffect(getThingPos(cid), 28)
        else
            doTeleportThing(cid, fromPosition, false)
            doSendMagicEffect(getThingPos(cid), 2)
            doPlayerSendCancel(cid, "Você não pertence á guild "..getGlobalStorageValue(COH_STATUS)..".")
        end
    return true
end

if item.actionid == 3233 then
        if not isPlayer(cid) then
            return true
        end

        if getPlayerGuildId(cid) > 0 then
            if (getGlobalStorageValue(COH_STATUS) ~= getPlayerGuildName(cid)) then
                doPlayerSendTextMessage(cid, 20, "Você e sua guild estão no comando do Castle24H, os antigos donos ["..tostring(getGlobalStorageValue(COH_STATUS)).."] podem se vingar!")
                setGlobalStorageValue(COH_PREPARE1, -1)
                setGlobalStorageValue(COH_PREPARE2, -1)
                setGlobalStorageValue(COH_STATUS, getPlayerGuildName(cid))
                doCastleRemoveEnemies()
                     
            else
                doSendMagicEffect(pos, 2)
                doTeleportThing(cid, fromPosition, false)
                doPlayerSendCancel(cid, "Este castelo ja pertence a sua guild.")
                end
        else
            doSendMagicEffect(pos, 2)
            doTeleportThing(cid, fromPosition, false)
            doPlayerSendCancel(cid, "Você não possui uma guild.")
        end
    return true
end

if item.actionid == 3230 then
        if not isPlayer(cid) then
            return true
        end

        if getPlayerGuildId(cid) > 0 then
            if (getGlobalStorageValue(COH_STATUS) == getPlayerGuildName(cid)) then
                doPlayerSendTextMessage(cid, 20, "ESTE CASTELO AINDA PERTENCE A SUA GUILD!")
                return true
            end
            if (getGlobalStorageValue(COH_PREPARE1) ~= getPlayerGuildName(cid)) and ((getGlobalStorageValue(COH_PREPARE2) ~= getPlayerGuildName(cid))) then
                setGlobalStorageValue(COH_PREPARE1, getPlayerGuildName(cid))
                broadcastMessage("Atenção! A guild "..getPlayerGuildName(cid).." está tentando dominar o castelo, preparem-se!")
            end
        else
            doSendMagicEffect(pos, 2)
            doTeleportThing(cid, fromPosition, false)
            doPlayerSendCancel(cid, "Você não possui uma guild.")
        end
    return true
end
if item.actionid == 3231 then
        if not isPlayer(cid) then
            return true
        end

        if (getGlobalStorageValue(COH_PREPARE2) ~= getPlayerGuildName(cid)) then
            setGlobalStorageValue(COH_PREPARE2, getPlayerGuildName(cid))
            broadcastMessage("Atenção! A guild "..getPlayerGuildName(cid).." está muito próxima do domínio, ataquem!")
        end
    return true
end

return true
end

function isInArea(a, b, c)
    if b.x >= a.x and c.x <= a.x then
        if b.y >= a.y and c.y <= a.y then
            if b.z == a.z and c.z == a.z then
                return true
            end
        end
    end
    return false
end

function doCastleRemoveEnemies()
    for index, creature in ipairs(getOnlinePlayers()) do
        if isInArea(getThingPos( getCreatureByName(creature) ), COH_AREA[1], COH_AREA[2]) then
            if getPlayerGuildName( getCreatureByName(creature) ) ~= getGlobalStorageValue(COH_STATUS) then
                doTeleportThing(creature, exit)
            end
        end
    end
    return true
end

Hey Codex NG really thanks to try to help me, but that script you send have a bug in getCreatureByName function but i try another method here and got sucess.
We can say that u solve 99% of bug cause u give me the way to solve that.
Really Really Thanks For That.
You Are Awesome.

OBS: I need change the check if player have guild too.

Here is the scripts working:

Code:
function onStepIn(cid, item, pos, fromPosition)
COH_AREA = {
    {x = 414, y = 61, z = 7}, -- max
    {x = 368, y = 25, z = 7} -- min
}
exit = {x = 393, y = 50, z = 7}
pos = getThingPos(cid)
COH_STATUS = 201320111714
COH_PREPARE1 = 201320111715
COH_PREPARE2 = 201320111717
COH_PUSHSTOR = 201320111716
COH_PUSHTIME = 10800

    if item.actionid == 3232 then
        if not isPlayer(cid) then
            return true
        end

        if getGlobalStorageValue(COH_STATUS) == getPlayerGuildName(cid) then
            doSendAnimatedText("PKNBaiak", pos, math.random(1, 255))
            doSendMagicEffect(getThingPos(cid), 28)
        else
            doTeleportThing(cid, fromPosition, false)
            doSendMagicEffect(getThingPos(cid), 2)
            doPlayerSendCancel(cid, "Você não pertence á guild "..getGlobalStorageValue(COH_STATUS)..".")
        end
    return true
    end

    if item.actionid == 3233 then
        if not isPlayer(cid) then
            return true
        end

        if getPlayerGuildLevel(cid) > 0 then
            if (getGlobalStorageValue(COH_STATUS) ~= getPlayerGuildName(cid)) then
                doPlayerSendTextMessage(cid, 20, "Você e sua guild estão no comando do Castle24H, os antigos donos ["..tostring(getGlobalStorageValue(COH_STATUS)).."] podem se vingar!")
                setGlobalStorageValue(COH_PREPARE1, -1)
                setGlobalStorageValue(COH_PREPARE2, -1)
                setGlobalStorageValue(COH_STATUS, getPlayerGuildName(cid))
                doCastleRemoveEnemies()                        
            else
                doSendMagicEffect(pos, 2)
                doTeleportThing(cid, fromPosition, false)
                doPlayerSendCancel(cid, "Este castelo ja pertence a sua guild.")
            end
        else
            doSendMagicEffect(pos, 2)
            doTeleportThing(cid, fromPosition, false)
            doPlayerSendCancel(cid, "Você não possui uma guild.")
        end
    return true
    end

    if item.actionid == 3230 then
        if not isPlayer(cid) then
            return true
        end

        if getPlayerGuildLevel(cid) > 0 then
            if (getGlobalStorageValue(COH_STATUS) == getPlayerGuildName(cid)) then
                doPlayerSendTextMessage(cid, 20, "ESTE CASTELO AINDA PERTENCE A SUA GUILD!")
            end
            if (getGlobalStorageValue(COH_STATUS) ~= getPlayerGuildName(cid) and getGlobalStorageValue(COH_PREPARE1) ~= getPlayerGuildName(cid)) then
                setGlobalStorageValue(COH_PREPARE1, getPlayerGuildName(cid))
                broadcastMessage("Atenção! A guild "..getPlayerGuildName(cid).." está tentando dominar o castelo, preparem-se!")
            end
        else
            doSendMagicEffect(pos, 2)
            doTeleportThing(cid, fromPosition, false)
            doPlayerSendCancel(cid, "Você não possui uma guild.")
        end
    return true
    end

    if item.actionid == 3231 then
        if not isPlayer(cid) then
            return true
        end
       
        if (getGlobalStorageValue(COH_STATUS) == getPlayerGuildName(cid)) then
            doPlayerSendTextMessage(cid, 20, "ESTE CASTELO AINDA PERTENCE A SUA GUILD!")
        end

        if (getGlobalStorageValue(COH_STATUS) ~= getPlayerGuildName(cid) and getGlobalStorageValue(COH_PREPARE2) ~= getPlayerGuildName(cid)) then
            setGlobalStorageValue(COH_PREPARE2, getPlayerGuildName(cid))
            broadcastMessage("Atenção! A guild "..getPlayerGuildName(cid).." está muito próxima do domínio, ataquem!")
        end
    return true
    end
   
return true
end 

function isInArea(a, b, c)
    if b.x >= a.x and c.x <= a.x then
        if b.y >= a.y and c.y <= a.y then
            if b.z == a.z and c.z == a.z then
                return true
            end
        end
    end
    return false
end

function doCastleRemoveEnemies()
    for index, creature in ipairs(getOnlinePlayers()) do
        if isInArea(getThingPos(getPlayerByName(creature)), COH_AREA[1], COH_AREA[2]) then
            if getPlayerGuildName(getPlayerByName(creature)) ~= getGlobalStorageValue(COH_STATUS) then
                doTeleportThing(getPlayerByName(creature), exit)
            end
        end
    end
    return true
end
 
Back
Top