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

RevScripts check outfit(tfs1x)

alcapone

Member
Joined
Jan 13, 2021
Messages
73
Reaction score
6
I'm having trouble getting him to check if the player has the outfit if the player is without the outfit he will take the damage from the spell

local lookType = 1065
local lockSpell = false
local chance = 30 -- %
local fromPos = Position(32715, 32712, 10)
local toPos = Position(32733, 32729, 10)

local function sendSpell(cid)
local creature = Creature(cid)
if creature then
for x = fromPos.x, toPos.x do
for y = fromPos.y, toPos.y do
for z = fromPos.z, toPos.z do
if Tile(Position(x, y, z)) then
Position(x, y, z):sendMagicEffect(CONST_ME_BIGCLOUDS)
local p = Tile(Position(x, y, z)):getTopCreature()
if p and (p:isPlayer() or p:getMaster()) then
doTargetCombatHealth(creature, p, COMBAT_ENERGYDAMAGE, -99999, -999999, CONST_ME_NONE)
end
end
end
end
end
local cPos = creature:getPosition()
local cHealth = creature:getHealth()
local monster = Game.createMonster('Mazzinor', cPos, true)
creature:remove()
lockSpell = false
end
end

function onCastSpell(creature, var)
if not lockSpell then
local r = math.random(1, 100)
if r <= chance then
lockSpell = true
local cPos = creature:getPosition()
local cHealth = creature:getHealth()
local monster = Game.createMonster('Supercharged Mazzinor', cPos, true)
creature:remove()
if monster then
monster:addHealth(-(monster:getHealth() - cHealth))
monster:say('MAZZINOR PREPARES TO ELECTROCTUTE THE WHOLE ROOM!', TALKTYPE_MONSTER_SAY)
monster:registerEvent('mazzinorHealth')
addEvent(sendSpell, 8*1000, monster:getId())
end
end
end
return true
end
 
Solution
Try this. Haven't tested.
Lua:
local cfg = {
    lookType   = 1065,
    lockSpell  = false,
    spellDelay = 8, -- seconds
    chance     = 30,
    fromPos    = Position(32715, 32712, 10),
    toPos      = Position(32733, 32729, 10),
    dmgMin     = 99999,
    dmgMax     = 999999
}

local function sendSpell(cid)
    local creature = Creature(cid)
    if not creature then
        return
    end

    for z = cfg.fromPos.z, cfg.toPos.z do
        for y = cfg.fromPos.y, cfg.toPos.y do
            for x = cfg.fromPos.x, cfg.toPos.x do
                if Tile(Position(x, y, z)) then
                    Position(x, y, z):sendMagicEffect(CONST_ME_BIGCLOUDS)
                    local p = Tile(Position(x, y, z)):getTopCreature()...

jacqen

Active Member
Joined
Jul 10, 2017
Messages
30
Solutions
5
Reaction score
42
First, please post the code with the correct format, it make easier for us to read.
If I understood the code correctly then you need to do that:
Change:
Lua:
if p and (p:isPlayer() or p:getMaster()) then
To:
Lua:
if p and ( (p:isPlayer() and not (p:getOutfit()).lookType == lookType) or p:getMaster()) then
 

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,244
Solutions
71
Reaction score
554
Location
Hell
Try this. Haven't tested.
Lua:
local cfg = {
    lookType   = 1065,
    lockSpell  = false,
    spellDelay = 8, -- seconds
    chance     = 30,
    fromPos    = Position(32715, 32712, 10),
    toPos      = Position(32733, 32729, 10),
    dmgMin     = 99999,
    dmgMax     = 999999
}

local function sendSpell(cid)
    local creature = Creature(cid)
    if not creature then
        return
    end

    for z = cfg.fromPos.z, cfg.toPos.z do
        for y = cfg.fromPos.y, cfg.toPos.y do
            for x = cfg.fromPos.x, cfg.toPos.x do
                if Tile(Position(x, y, z)) then
                    Position(x, y, z):sendMagicEffect(CONST_ME_BIGCLOUDS)
                    local p = Tile(Position(x, y, z)):getTopCreature()
                    if p and p:isPlayer() and p:getOutfit().lookType ~= cfg.lookType then
                        doTargetCombatHealth(creature, p, COMBAT_ENERGYDAMAGE, -cfg.dmgMin, -cfg.dmgMin, CONST_ME_NONE)
                    end
                end
            end
        end
    end
    local cPos = creature:getPosition()
    local cHealth = creature:getHealth()
    local monster = Game.createMonster('Mazzinor', cPos, true)
    creature:remove()
    cfg.lockSpell = false
end

function onCastSpell(creature, var)
    if cfg.lockSpell then
        return true
    end

    local r = math.random(1, 100)
    if r > cfg.chance then
        return true
    end

    cfg.lockSpell = true
    local cPos = creature:getPosition()
    local cHealth = creature:getHealth()
    local monster = Game.createMonster('Supercharged Mazzinor', cPos, true)
    creature:remove()

    if not monster then
        return true
    end

    monster:addHealth(-(monster:getHealth() - cHealth))
    monster:say('MAZZINOR PREPARES TO ELECTROCTUTE THE WHOLE ROOM!', TALKTYPE_MONSTER_SAY)
    monster:registerEvent('mazzinorHealth')
    addEvent(sendSpell, cfg.spellDelay * 1000, monster:getId())
    return true
end
 
Solution
Top