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

Remove summon when entering Protection Zone.

Yuumii

New Member
Joined
Jun 27, 2018
Messages
12
Reaction score
2
Remova a invocação ao entrar na Zona de Proteção, Narutibia.
 
removesummons.lua
Lua:
local removeSummons_system = {}

function removeSummons_system:HasSummons(cid)
    if not cid then
       return nil
    end
    local list = getCreatureSummons(cid)
    if #list <= 0 then
       return false
    end
    return true
end

function removeSummons_system:deleteSummons(cid)
    if not cid then
       return nil
    end
    local list = getCreatureSummons(cid)
    for index, summon_uid in pairs(list) do
        if isCreature(summon_uid) then
           local pos = getCreaturePosition(summon_uid)
           doSendMagicEffect(pos, CONST_ME_POFF)
           doRemoveThing(summon_uid)
        end
    end
end

function removeSummons_system:shouldRemove(cid)
    if not cid then
       return nil
    end
   
    if not removeSummons_system:HasSummons(cid) then
       return false
    end
 
    local pos = getCreaturePosition(cid)
    if getTilePzInfo(pos) then
       return true
    end
    return false
end

function onLogin(cid)
    registerCreatureEvent(cid, "onThink_removesummons")
    return true
end

function onThink(cid, interval)

   if not removeSummons_system:shouldRemove(cid) then
      return true
   end
   removeSummons_system:deleteSummons(cid)
   return true
end

XML:
    <event type="login" name="onLogin_removesummons" event="script" value="remove summons.lua"/>
    <event type="think" name="onThink_removesummons" event="script" value="remove summons.lua"/>

Thats my proposition by using creaturescripts event
 
removesummons.lua
Lua:
local removeSummons_system = {}

function removeSummons_system:HasSummons(cid)
    if not cid then
       return nil
    end
    local list = getCreatureSummons(cid)
    if #list <= 0 then
       return false
    end
    return true
end

function removeSummons_system:deleteSummons(cid)
    if not cid then
       return nil
    end
    local list = getCreatureSummons(cid)
    for index, summon_uid in pairs(list) do
        if isCreature(summon_uid) then
           local pos = getCreaturePosition(summon_uid)
           doSendMagicEffect(pos, CONST_ME_POFF)
           doRemoveThing(summon_uid)
        end
    end
end

function removeSummons_system:shouldRemove(cid)
    if not cid then
       return nil
    end
  
    if not removeSummons_system:HasSummons(cid) then
       return false
    end
 
    local pos = getCreaturePosition(cid)
    if getTilePzInfo(pos) then
       return true
    end
    return false
end

function onLogin(cid)
    registerCreatureEvent(cid, "onThink_removesummons")
    return true
end

function onThink(cid, interval)

   if not removeSummons_system:shouldRemove(cid) then
      return true
   end
   removeSummons_system:deleteSummons(cid)
   return true
end

XML:
    <event type="login" name="onLogin_removesummons" event="script" value="remove summons.lua"/>
    <event type="think" name="onThink_removesummons" event="script" value="remove summons.lua"/>

Thats my proposition by using creaturescripts event
unfortunately it doesn't work, and it didn't return any error
 

Attachments

  • Naruto 2022-06-11 04-00-35.gif
    Naruto 2022-06-11 04-00-35.gif
    2.5 MB · Views: 5 · VirusTotal
creaturescripts brother, not movements, its not possible to register the tile into movements ( u would need to register every tile)
 
removesummons.lua
Lua:
local removeSummons_system = {}

function removeSummons_system:HasSummons(cid)
    if not cid then
       return nil
    end
    local list = getCreatureSummons(cid)
    if #list <= 0 then
       return false
    end
    return true
end

function removeSummons_system:deleteSummons(cid)
    if not cid then
       return nil
    end
    local list = getCreatureSummons(cid)
    for index, summon_uid in pairs(list) do
        if isCreature(summon_uid) then
           local pos = getCreaturePosition(summon_uid)
           doSendMagicEffect(pos, CONST_ME_POFF)
           doRemoveThing(summon_uid)
        end
    end
end

function removeSummons_system:shouldRemove(cid)
    if not cid then
       return nil
    end
 
    if not removeSummons_system:HasSummons(cid) then
       return false
    end
 
    local pos = getCreaturePosition(cid)
    if getTilePzInfo(pos) then
       return true
    end
    return false
end

function onLogin(cid)
    registerCreatureEvent(cid, "onThink_removesummons")
    return true
end

function onThink(cid, interval)

   if not removeSummons_system:shouldRemove(cid) then
      return true
   end
   removeSummons_system:deleteSummons(cid)
   return true
end

XML:
    <event type="login" name="onLogin_removesummons" event="script" value="remove summons.lua"/>
    <event type="think" name="onThink_removesummons" event="script" value="remove summons.lua"/>

Thats my proposition by using creaturescripts event
I don't understand the point of all the extra code tho xD

just make it like 7 lines inside of onThink

Lua:
function onLogin(cid)
    registerCreatureEvent(cid, "onThink_removesummons")
    return true
end

function onThink(cid, interval)
    if getTilePzInfo(getCreaturePosition(cid)) == true then
        local summons = getCreatureSummons(cid)
        if #summons > 0 then
            for i = #summons, 1, -1 do
                doSendMagicEffect(getCreaturePosition(summons[i]), CONST_ME_POFF)
                doRemoveThing(summons[i])
            end
        end
    end
    return true
end
 
I don't understand the point of all the extra code tho xD

just make it like 7 lines inside of onThink

Lua:
function onLogin(cid)
    registerCreatureEvent(cid, "onThink_removesummons")
    return true
end

function onThink(cid, interval)
    if getTilePzInfo(getCreaturePosition(cid)) == true then
        local summons = getCreatureSummons(cid)
        if #summons > 0 then
            for i = #summons, 1, -1 do
                doSendMagicEffect(getCreaturePosition(summons[i]), CONST_ME_POFF)
                doRemoveThing(summons[i])
            end
        end
    end
    return true
end
I just practice for myself to make code like that for more complicated systems ^^.
 
Back
Top