• 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 Block Attack on Player Using

hyz

Member
Joined
Oct 30, 2008
Messages
39
Reaction score
16
Is there a possibility that this script doesn't attack the player using the item?

Lua:
local combat = COMBAT_FIREDAMAGE
local effect = 28
local text_color = TEXTCOLOR_ORANGE
local disteffect = 28
local Range = 2;
local item = 14971
local mana = 100
local block = 0

function Player.moveSlotToBackpack(self, slot)
    if slot == CONST_SLOT_BACKPACK then
        return false
    end
    local item = self:getSlotItem(slot)
    if item then
        local backpack = self:getSlotItem(CONST_SLOT_BACKPACK)
        if backpack then
            return item:moveTo(backpack)
        end
    end
    return false
end

local function sendAttack(cid)   

    local title = Tile(Position(x, y, z))
    local player = Player(cid)   
    local hit_min = player:getLevel()*0.05 + 100
    local hit_max = player:getLevel()*0.10 + 500   
    local specs = Game.getSpectators(player:getPosition(),false, false, Range, Range, Range, Range)
            
    for i = 1, #specs do
        if specs[i]:isPlayer() or specs[i]:isMonster() then
            if isSightClear(player:getPosition(), specs[i]:getPosition(), true) then
                if specs[i]:getMaster() == nil    then
                    doTargetCombatHealth(player, Creature(specs[i]), combat, -hit_min, -hit_max, effect)                   
                end               
            end   
        end
    end
end


local function Aura(cid)   
    
    local player = Player(cid)
    if Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
        player:moveSlotToBackpack(CONST_SLOT_NECKLACE)
        return false
    end
    
    --mana
    if player:getMana() >= mana then
        player:addMana(-mana)
        player:addManaSpent(mana)
        local pos = player:getPosition()
        Position(pos.x+2, pos.y+1, pos.z):sendDistanceEffect(Position(pos.x+2, pos.y-1, pos.z), disteffect)
        Position(pos.x+2, pos.y-1, pos.z):sendDistanceEffect(Position(pos.x+1, pos.y-2, pos.z), disteffect)
        Position(pos.x+1, pos.y-2, pos.z):sendDistanceEffect(Position(pos.x-1, pos.y-2, pos.z), disteffect)
        Position(pos.x-1, pos.y-2, pos.z):sendDistanceEffect(Position(pos.x-2, pos.y-1, pos.z), disteffect)
        Position(pos.x-2, pos.y-1, pos.z):sendDistanceEffect(Position(pos.x-2, pos.y+1, pos.z), disteffect)
        Position(pos.x-2, pos.y+1, pos.z):sendDistanceEffect(Position(pos.x-1, pos.y+2, pos.z), disteffect)
        Position(pos.x-1, pos.y+2, pos.z):sendDistanceEffect(Position(pos.x+1, pos.y+2, pos.z), disteffect)
        Position(pos.x+1, pos.y+2, pos.z):sendDistanceEffect(Position(pos.x+2, pos.y+1, pos.z), disteffect)       
        sendAttack(player.uid)
            
        if getPlayerSlotItem(cid, CONST_SLOT_NECKLACE).itemid == item then
            addEvent(Aura, 200, player.uid)   
        end
    else
        player:getPosition():sendMagicEffect(CONST_ME_POFF)   
    end
    
    
end



--Funcion principal
function onEquip(player, item, slot, var)
    if Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
        player:moveSlotToBackpack(CONST_SLOT_NECKLACE)
        return true
    end
    
    contador = 0
    Aura(player)   
    
    return true
end
 
change your function to check if the spectator is the person casting the spell
Lua:
local function sendAttack(cid)   
    local title = Tile(Position(x, y, z))
    local player = Player(cid)   
    local hit_min = player:getLevel()*0.05 + 100
    local hit_max = player:getLevel()*0.10 + 500   
    local specs = Game.getSpectators(player:getPosition(),false, false, Range, Range, Range, Range)
            
    for i = 1, #specs do
        if spec[i] ~= player then -- added this
            if specs[i]:isPlayer() or specs[i]:isMonster() then
                if isSightClear(player:getPosition(), specs[i]:getPosition(), true) then
                    if specs[i]:getMaster() == nil    then
                        doTargetCombatHealth(player, Creature(specs[i]), combat, -hit_min, -hit_max, effect)                   
                    end               
                end   
            end
        end
    end
end
 
Back
Top